12namespace gpucub = cub;
13using keyvalueindexT = int;
17#include <hipcub/hipcub.hpp>
18namespace gpucub = hipcub;
19#if defined(HIPCUB_VERSION) && HIPCUB_VERSION >= 300300
21using keyvalueindexT = long;
23using keyvalueindexT = int;
34 int64_t num_items = mylat.loop_end(par) - mylat.loop_begin(par);
38 T *data_in = this->field_buffer() + mylat.loop_begin(par);
39 gpucub::KeyValuePair<keyvalueindexT, T> *result_p, result;
41 gpuMalloc(&result_p,
sizeof(gpucub::KeyValuePair<keyvalueindexT, T>));
44 void *d_temp_storage =
nullptr;
45 size_t temp_storage_bytes = 0;
48 GPU_CHECK(gpucub::DeviceReduce::ArgMin(d_temp_storage, temp_storage_bytes, data_in,
49 result_p, num_items));
51 GPU_CHECK(gpucub::DeviceReduce::ArgMax(d_temp_storage, temp_storage_bytes, data_in,
52 result_p, num_items));
57 gpuMalloc(&d_temp_storage, temp_storage_bytes);
61 GPU_CHECK(gpucub::DeviceReduce::ArgMin(d_temp_storage, temp_storage_bytes, data_in,
62 result_p, num_items));
64 GPU_CHECK(gpucub::DeviceReduce::ArgMax(d_temp_storage, temp_storage_bytes, data_in,
65 result_p, num_items));
68 gpuFree(d_temp_storage);
70 gpuMemcpy(&result, result_p,
sizeof(gpucub::KeyValuePair<keyvalueindexT, T>),
71 gpuMemcpyDeviceToHost);
75 loc = mylat.coordinates(result.key + mylat.loop_begin(par));
T gpu_minmax(bool min_or_max, Parity par, CoordinateVector &loc) const
Declare gpu_reduce here, defined only for GPU targets.
Parity
Parity enum with values EVEN, ODD, ALL; refers to parity of the site. Parity of site (x,...