diff --git a/exercises/dot-product.cpp b/exercises/dot-product.cpp index 67ec877f89..c2830c6cb2 100644 --- a/exercises/dot-product.cpp +++ b/exercises/dot-product.cpp @@ -38,11 +38,6 @@ int main(int RAJA_UNUSED_ARG(argc), char **RAJA_UNUSED_ARG(argv[])) std::cout << "\n\nExercise: vector dot product...\n"; -#if defined(RAJA_ENABLE_SYCL) - memoryManager::sycl_res = new camp::resources::Resource{camp::resources::Sycl()}; - ::RAJA::sycl::detail::setQueue(memoryManager::sycl_res); -#endif - // // Define vector length // diff --git a/exercises/dot-product_solution.cpp b/exercises/dot-product_solution.cpp index a1bc7ad419..d0ae458171 100644 --- a/exercises/dot-product_solution.cpp +++ b/exercises/dot-product_solution.cpp @@ -40,11 +40,6 @@ int main(int RAJA_UNUSED_ARG(argc), char **RAJA_UNUSED_ARG(argv[])) std::cout << "\n\nExercise: vector dot product...\n"; -#if defined(RAJA_ENABLE_SYCL) - memoryManager::sycl_res = new camp::resources::Resource{camp::resources::Sycl()}; - ::RAJA::sycl::detail::setQueue(memoryManager::sycl_res); -#endif - // // Define vector length // @@ -113,7 +108,7 @@ int main(int RAJA_UNUSED_ARG(argc), char **RAJA_UNUSED_ARG(argv[])) RAJA::forall(RAJA::RangeSegment(0, N), [=] (int i) { ompdot += a[i] * b[i]; - }); + }); dot = ompdot.get(); // _rajaomp_dotprod_end diff --git a/exercises/vector-addition.cpp b/exercises/vector-addition.cpp index a266402224..dbe5260f6d 100644 --- a/exercises/vector-addition.cpp +++ b/exercises/vector-addition.cpp @@ -62,11 +62,6 @@ int main(int RAJA_UNUSED_ARG(argc), char **RAJA_UNUSED_ARG(argv[])) std::cout << "\n\nExercise: RAJA Vector Addition...\n"; -#if defined(RAJA_ENABLE_SYCL) - memoryManager::sycl_res = new camp::resources::Resource{camp::resources::Sycl()}; - ::RAJA::sycl::detail::setQueue(memoryManager::sycl_res); -#endif - // // Define vector length // diff --git a/exercises/vector-addition_solution.cpp b/exercises/vector-addition_solution.cpp index 31956601e0..3bbc070731 100644 --- a/exercises/vector-addition_solution.cpp +++ b/exercises/vector-addition_solution.cpp @@ -62,11 +62,6 @@ int main(int RAJA_UNUSED_ARG(argc), char **RAJA_UNUSED_ARG(argv[])) std::cout << "\n\nExercise: RAJA Vector Addition...\n"; -#if defined(RAJA_ENABLE_SYCL) - memoryManager::sycl_res = new camp::resources::Resource{camp::resources::Sycl()}; - ::RAJA::sycl::detail::setQueue(memoryManager::sycl_res); -#endif - // // Define vector length // @@ -179,7 +174,7 @@ int main(int RAJA_UNUSED_ARG(argc), char **RAJA_UNUSED_ARG(argv[])) RAJA::TypedRangeSegment(0, N), [=] (int i) { c[i] = a[i] + b[i]; } - ); + ); // _rajaomp_vector_add_end checkResult(c, c_ref, N); diff --git a/include/RAJA/policy/sycl/MemUtils_SYCL.hpp b/include/RAJA/policy/sycl/MemUtils_SYCL.hpp index 27d3209ae3..081a88dc23 100644 --- a/include/RAJA/policy/sycl/MemUtils_SYCL.hpp +++ b/include/RAJA/policy/sycl/MemUtils_SYCL.hpp @@ -64,10 +64,6 @@ extern syclInfo tl_status; extern std::unordered_map g_queue_info_map; -void setQueue(camp::resources::Resource* q); - -cl::sycl::queue* getQueue(); - } // namespace detail //! Allocator for pinned memory for use in basic_mempool @@ -77,7 +73,7 @@ struct PinnedAllocator { void* malloc(size_t nbytes) { void* ptr; - ::sycl::queue* q = ::RAJA::sycl::detail::getQueue(); + ::sycl::queue* q = ::camp::resources::Sycl::get_default().get_queue(); ptr = ::sycl::malloc_host(nbytes, *q); return ptr; } @@ -86,7 +82,7 @@ struct PinnedAllocator { // Will throw if ptr is not in q's context bool free(void* ptr) { - ::sycl::queue* q = ::RAJA::sycl::detail::getQueue(); + ::sycl::queue* q = ::camp::resources::Sycl::get_default().get_queue(); ::sycl::free(ptr, *q); return true; } @@ -99,7 +95,7 @@ struct DeviceAllocator { void* malloc(size_t nbytes) { void* ptr; - ::sycl::queue* q = ::RAJA::sycl::detail::getQueue(); + ::sycl::queue* q = ::camp::resources::Sycl::get_default().get_queue(); ptr = ::sycl::malloc_device(nbytes, *q); return ptr; } @@ -108,7 +104,7 @@ struct DeviceAllocator { // Will throw if ptr is not in q's context bool free(void* ptr) { - ::sycl::queue* q = ::RAJA::sycl::detail::getQueue(); + ::sycl::queue* q = ::camp::resources::Sycl::get_default().get_queue(); ::sycl::free(ptr, *q); return true; } @@ -122,7 +118,7 @@ struct DeviceZeroedAllocator { void* malloc(size_t nbytes) { void* ptr; - ::sycl::queue* q = ::RAJA::sycl::detail::getQueue(); + ::sycl::queue* q = ::camp::resources::Sycl::get_default().get_queue(); ptr = ::sycl::malloc_device(nbytes, *q); q->memset(ptr, 0, nbytes); return ptr; @@ -132,7 +128,7 @@ struct DeviceZeroedAllocator { // Will throw if ptr is not in q's context bool free(void* ptr) { - ::sycl::queue* q = ::RAJA::sycl::detail::getQueue(); + ::sycl::queue* q = ::camp::resources::Sycl::get_default().get_queue(); ::sycl::free(ptr, *q); return true; } diff --git a/include/RAJA/policy/sycl/reduce.hpp b/include/RAJA/policy/sycl/reduce.hpp index 58cb83d295..49d89b3cd2 100644 --- a/include/RAJA/policy/sycl/reduce.hpp +++ b/include/RAJA/policy/sycl/reduce.hpp @@ -107,12 +107,8 @@ struct Reduce_Data Reduce_Data(T initValue, T identityValue, Offload_Info &info) : value(initValue) { - cl::sycl::queue* q = ::RAJA::sycl::detail::getQueue(); + cl::sycl::queue* q = ::camp::resources::Sycl::get_default().get_queue(); - if(!q) { - camp::resources::Resource res = camp::resources::Sycl(); - q = res.get().get_queue(); - } device = reinterpret_cast(cl::sycl::malloc_device(sycl::MaxNumTeams * sizeof(T), *(q))); host = reinterpret_cast(cl::sycl::malloc_host(sycl::MaxNumTeams * sizeof(T), *(q))); @@ -140,7 +136,7 @@ struct Reduce_Data //! transfers from the host to the device -- exit() is called upon failure RAJA_INLINE void hostToDevice(Offload_Info &info) { - cl::sycl::queue* q = ::RAJA::sycl::detail::getQueue(); + cl::sycl::queue* q = ::camp::resources::Sycl::get_default().get_queue(); if(!q) { camp::resources::Resource res = camp::resources::Sycl(); @@ -158,7 +154,7 @@ struct Reduce_Data //! transfers from the device to the host -- exit() is called upon failure RAJA_INLINE void deviceToHost(Offload_Info &info) { - cl::sycl::queue* q = ::RAJA::sycl::detail::getQueue(); + cl::sycl::queue* q = ::camp::resources::Sycl::get_default().get_queue(); if(!q) { camp::resources::Resource res = camp::resources::Sycl(); @@ -169,18 +165,15 @@ struct Reduce_Data auto e = q->memcpy(reinterpret_cast(host), reinterpret_cast(device), sycl::MaxNumTeams * sizeof(T)); - + e.wait(); } //! frees all data from the offload information passed RAJA_INLINE void cleanup(Offload_Info &info) { - cl::sycl::queue* q = ::RAJA::sycl::detail::getQueue(); - if(!q) { - camp::resources::Resource res = camp::resources::Sycl(); - q = res.get().get_queue(); - } + cl::sycl::queue* q = ::camp::resources::Sycl::get_default().get_queue(); + if (device) { cl::sycl::free(reinterpret_cast(device), *q); device = nullptr; diff --git a/src/MemUtils_SYCL.cpp b/src/MemUtils_SYCL.cpp index 911ff132b6..0b5f1b8be6 100644 --- a/src/MemUtils_SYCL.cpp +++ b/src/MemUtils_SYCL.cpp @@ -48,24 +48,10 @@ syclInfo tl_status; #pragma omp threadprivate(tl_status) #endif -camp::resources::Resource* app_q = NULL; - -void setQueue(camp::resources::Resource* qu) { - app_q = qu; -} - //! State of raja sycl queue synchronization for sycl reducer objects std::unordered_map g_queue_info_map{ {cl::sycl::queue(), true}}; -cl::sycl::queue* getQueue() { - if (app_q != NULL) { - return app_q->get().get_queue(); - } - - return NULL; -} - } // namespace detail } // namespace sycl