Skip to content

Commit

Permalink
Merge pull request #3017 from JieyangChen7/fix-gpu-library-conflict-i…
Browse files Browse the repository at this point in the history
…ssue

Fix GPU library conflict issue
  • Loading branch information
JasonRuonanWang authored Jan 26, 2022
2 parents f6cf3d8 + d311ae1 commit ebc4c8d
Show file tree
Hide file tree
Showing 2 changed files with 478 additions and 8 deletions.
12 changes: 4 additions & 8 deletions source/adios2/helper/adiosCUDA.cu
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,18 @@
#define ADIOS2_HELPER_ADIOSCUDA_CU_

#include "adios2/common/ADIOSMacros.h"
#include <thrust/device_ptr.h>
#include <thrust/extrema.h>

#include "adiosCUDA.h"
#include "adiosCUDAReduceImpl.h"

namespace
{

template <class T>
void CUDAMinMaxImpl(const T *values, const size_t size, T &min, T &max)
{
thrust::device_ptr<const T> dev_ptr(values);
auto res = thrust::minmax_element(dev_ptr, dev_ptr + size);
cudaMemcpy(&min, thrust::raw_pointer_cast(res.first), sizeof(T),
cudaMemcpyDeviceToHost);
cudaMemcpy(&max, thrust::raw_pointer_cast(res.second), sizeof(T),
cudaMemcpyDeviceToHost);
min = reduce<T, MinOp>(size, 1024, 64, 1, values);
max = reduce<T, MaxOp>(size, 1024, 64, 1, values);
}
// types non supported on the device
void CUDAMinMaxImpl(const long double * /*values*/, const size_t /*size*/,
Expand Down
Loading

0 comments on commit ebc4c8d

Please sign in to comment.