diff --git a/include/nvexec/multi_gpu_context.cuh b/include/nvexec/multi_gpu_context.cuh index 704c83f3b..77a452245 100644 --- a/include/nvexec/multi_gpu_context.cuh +++ b/include/nvexec/multi_gpu_context.cuh @@ -38,7 +38,7 @@ namespace nv::execution auto operator==(multi_gpu_stream_scheduler const & other) const noexcept -> bool { - return ctx_.hub_ == other.ctx_.hub_; + return ctx_.hub_ == other.ctx_.hub_ && ctx_.priority_ == other.ctx_.priority_; } [[nodiscard]] diff --git a/include/nvexec/stream_context.cuh b/include/nvexec/stream_context.cuh index f5128f73f..5d5b60342 100644 --- a/include/nvexec/stream_context.cuh +++ b/include/nvexec/stream_context.cuh @@ -75,7 +75,7 @@ namespace nv::execution auto operator==(stream_scheduler const & other) const noexcept -> bool { - return ctx_.hub_ == other.ctx_.hub_; + return ctx_.hub_ == other.ctx_.hub_ && ctx_.priority_ == other.ctx_.priority_; } STDEXEC_ATTRIBUTE(nodiscard, host, device) auto schedule() const noexcept diff --git a/test/nvexec/CMakeLists.txt b/test/nvexec/CMakeLists.txt index 2d5b758f7..bad93eb0b 100644 --- a/test/nvexec/CMakeLists.txt +++ b/test/nvexec/CMakeLists.txt @@ -25,6 +25,7 @@ set(nvexec_test_sources split.cpp upon_stopped.cpp transfer.cpp + scheduler.cpp launch.cpp let_error.cpp let_stopped.cpp diff --git a/test/nvexec/scheduler.cpp b/test/nvexec/scheduler.cpp new file mode 100644 index 000000000..5c6f251e0 --- /dev/null +++ b/test/nvexec/scheduler.cpp @@ -0,0 +1,42 @@ +#include + +#include "nvexec/multi_gpu_context.cuh" +#include "nvexec/stream_context.cuh" + +namespace +{ + TEST_CASE("nvexec stream scheduler equality includes priority", "[cuda][stream][scheduler]") + { + nvexec::stream_context stream_ctx{}; + + auto high = stream_ctx.get_scheduler(nvexec::stream_priority::high); + auto normal = stream_ctx.get_scheduler(nvexec::stream_priority::normal); + auto low = stream_ctx.get_scheduler(nvexec::stream_priority::low); + + CHECK(high == stream_ctx.get_scheduler(nvexec::stream_priority::high)); + CHECK(normal == stream_ctx.get_scheduler(nvexec::stream_priority::normal)); + CHECK(low == stream_ctx.get_scheduler(nvexec::stream_priority::low)); + CHECK_FALSE(high == normal); + CHECK_FALSE(normal == low); + CHECK_FALSE(high == low); + + nvexec::stream_context other_stream_ctx{}; + CHECK_FALSE(high == other_stream_ctx.get_scheduler(nvexec::stream_priority::high)); + } + + TEST_CASE("nvexec multi-GPU scheduler equality includes priority", "[cuda][stream][scheduler]") + { + nvexec::multi_gpu_stream_context stream_ctx{}; + + auto high = stream_ctx.get_scheduler(nvexec::stream_priority::high); + auto normal = stream_ctx.get_scheduler(nvexec::stream_priority::normal); + auto low = stream_ctx.get_scheduler(nvexec::stream_priority::low); + + CHECK(high == stream_ctx.get_scheduler(nvexec::stream_priority::high)); + CHECK(normal == stream_ctx.get_scheduler(nvexec::stream_priority::normal)); + CHECK(low == stream_ctx.get_scheduler(nvexec::stream_priority::low)); + CHECK_FALSE(high == normal); + CHECK_FALSE(normal == low); + CHECK_FALSE(high == low); + } +} // namespace