From f5195c910413aa325429166bfd8ceb2427769afd Mon Sep 17 00:00:00 2001 From: Carl Pearson Date: Wed, 7 Jun 2023 16:29:18 -0600 Subject: [PATCH] move cuda_reset_device into scope ns, remove old impl --- CMakeLists.txt | 8 -------- cmake/modules/test_cudaDeviceProp.cpp | 5 ----- cmake/modules/try_cudaDeviceProp.cmake | 9 --------- include/scope/cuda.hpp | 4 +--- include/scope/device.hpp | 4 ---- src/cuda.cpp | 24 ++---------------------- 6 files changed, 3 insertions(+), 51 deletions(-) delete mode 100644 cmake/modules/test_cudaDeviceProp.cpp delete mode 100644 cmake/modules/try_cudaDeviceProp.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index be767f9..e815a98 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -175,14 +175,6 @@ if("CUDA" IN_LIST languages AND SCOPE_USE_CUDA) else() endif() -if (SCOPE_USE_CUDA) - # check if it's cudaDeviceProp - include(try_cudaDeviceProp) - if (SCOPE_HAVE_CUDA_DEVICE_PROP) - target_compile_definitions(scope PUBLIC -DSCOPE_HAVE_CUDA_DEVICE_PROP) - endif() -endif(SCOPE_USE_CUDA) - if(SCOPE_USE_HIP) message(STATUS "HIP enabled, compiling with -DSCOPE_USE_HIP=1") target_compile_definitions(scope PUBLIC -DSCOPE_USE_HIP=1) diff --git a/cmake/modules/test_cudaDeviceProp.cpp b/cmake/modules/test_cudaDeviceProp.cpp deleted file mode 100644 index a1dd17d..0000000 --- a/cmake/modules/test_cudaDeviceProp.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include - -int main(void) { - cudaDeviceProp p; -} \ No newline at end of file diff --git a/cmake/modules/try_cudaDeviceProp.cmake b/cmake/modules/try_cudaDeviceProp.cmake deleted file mode 100644 index 0ebaf7d..0000000 --- a/cmake/modules/try_cudaDeviceProp.cmake +++ /dev/null @@ -1,9 +0,0 @@ - - -try_compile( - SCOPE_HAVE_CUDA_DEVICE_PROP - ${CMAKE_BINARY_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/test_cudaDeviceProp.cpp - OUTPUT_VARIABLE OUTPUT -) -message(STATUS "Performing Test SCOPE_HAVE_CUDA_DEVICE_PROP=${SCOPE_HAVE_CUDA_DEVICE_PROP}") \ No newline at end of file diff --git a/include/scope/cuda.hpp b/include/scope/cuda.hpp index 333ccd1..5960fb1 100644 --- a/include/scope/cuda.hpp +++ b/include/scope/cuda.hpp @@ -6,8 +6,6 @@ #include "scope/error.hpp" -cudaError_t cuda_reset_device(const int &id); - namespace scope { namespace detail { inline void success_or_throw(cudaError err, const char *file, int line) { @@ -20,7 +18,7 @@ inline void success_or_throw(cudaError err, const char *file, int line) { } } // namespace detail -cudaError hip_reset_device(const int &id); +cudaError_t cuda_reset_device(const int &id); } // namespace scope diff --git a/include/scope/device.hpp b/include/scope/device.hpp index 0f7b263..8918b73 100644 --- a/include/scope/device.hpp +++ b/include/scope/device.hpp @@ -40,10 +40,6 @@ class Device { #endif #if defined(SCOPE_USE_CUDA) -#if defined(SCOPE_HAVE_CUDA_DEVICE_PROP) cudaDeviceProp cudaDeviceProp_; -#else - cudaDeviceProp_t cudaDeviceProp_; -#endif #endif }; diff --git a/src/cuda.cpp b/src/cuda.cpp index bccaf1d..55fb086 100644 --- a/src/cuda.cpp +++ b/src/cuda.cpp @@ -3,6 +3,7 @@ #include "scope/cuda.hpp" #include "scope/flags.hpp" +namespace scope { cudaError_t cuda_reset_device(const int &id) { cudaError_t err = cudaSetDevice(id); if (err != cudaSuccess) { @@ -10,25 +11,4 @@ cudaError_t cuda_reset_device(const int &id) { } return cudaDeviceReset(); } - -const std::vector unique_cuda_device_ids() { - std::vector ret; - int count; - if (PRINT_IF_ERROR(cudaGetDeviceCount(&count))) { - return ret; - } - - /* all GPUs if none specified */ - if (scope::flags::visibleGPUs.empty()) { - ret.resize(count); - std::iota(ret.begin(), ret.end(), 0); - return ret; - } else { /* one version of each GPU specified */ - for (int id : scope::flags::visibleGPUs) { - if (id < count && ret.end() == std::find(ret.begin(), ret.end(), id)) { - ret.push_back(id); - } - } - return ret; - } -} \ No newline at end of file +} // namespace scope