Skip to content

Commit

Permalink
move cuda_reset_device into scope ns, remove old impl
Browse files Browse the repository at this point in the history
  • Loading branch information
cwpearson committed Jun 7, 2023
1 parent 5f1ae48 commit f5195c9
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 51 deletions.
8 changes: 0 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 0 additions & 5 deletions cmake/modules/test_cudaDeviceProp.cpp

This file was deleted.

9 changes: 0 additions & 9 deletions cmake/modules/try_cudaDeviceProp.cmake

This file was deleted.

4 changes: 1 addition & 3 deletions include/scope/cuda.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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

Expand Down
4 changes: 0 additions & 4 deletions include/scope/device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
24 changes: 2 additions & 22 deletions src/cuda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,12 @@
#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) {
return err;
}
return cudaDeviceReset();
}

const std::vector<int> unique_cuda_device_ids() {
std::vector<int> 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;
}
}
} // namespace scope

0 comments on commit f5195c9

Please sign in to comment.