1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
|
// BSD 3-Clause License; see https://github.com/scikit-hep/awkward-1.0/blob/main/LICENSE
#define FILENAME(line) \
FILENAME_FOR_EXCEPTIONS_CUDA("src/cuda-kernels/awkward_reduce_argmax.cu", \
line)
#include "standard_parallel_algorithms.h"
#include "awkward/kernels.h"
template <typename OUT, typename IN>
__global__ void
awkward_reduce_argmax_kernel(OUT* toptr,
const IN* fromptr,
const int64_t* parents,
int64_t lenparents) {
int64_t thread_id = blockIdx.x * blockDim.x + threadIdx.x;
if (thread_id < lenparents) {
int64_t parent = parents[thread_id];
if (toptr[parent] == -1 || (fromptr[thread_id] > (fromptr[toptr[parent]]))) {
toptr[parent] = thread_id;
}
}
}
template <typename OUT, typename IN>
ERROR
awkward_reduce_argmax(OUT* toptr,
const IN* fromptr,
const int64_t* parents,
int64_t lenparents,
int64_t outlength) {
HANDLE_ERROR(cudaMemset(toptr, -1, sizeof(OUT) * outlength));
dim3 blocks_per_grid = blocks(lenparents);
dim3 threads_per_block = threads(lenparents);
awkward_reduce_argmax_kernel<<<blocks_per_grid, threads_per_block>>>(
toptr, fromptr, parents, lenparents);
return success();
}
ERROR
awkward_reduce_argmax_int8_64(int64_t* toptr,
const int8_t* fromptr,
const int64_t* parents,
int64_t lenparents,
int64_t outlength) {
return awkward_reduce_argmax<int64_t, int8_t>(
toptr, fromptr, parents, lenparents, outlength);
}
ERROR
awkward_reduce_argmax_uint8_64(int64_t* toptr,
const uint8_t* fromptr,
const int64_t* parents,
int64_t lenparents,
int64_t outlength) {
return awkward_reduce_argmax<int64_t, uint8_t>(
toptr, fromptr, parents, lenparents, outlength);
}
ERROR
awkward_reduce_argmax_int16_64(int64_t* toptr,
const int16_t* fromptr,
const int64_t* parents,
int64_t lenparents,
int64_t outlength) {
return awkward_reduce_argmax<int64_t, int16_t>(
toptr, fromptr, parents, lenparents, outlength);
}
ERROR
awkward_reduce_argmax_uint16_64(int64_t* toptr,
const uint16_t* fromptr,
const int64_t* parents,
int64_t lenparents,
int64_t outlength) {
return awkward_reduce_argmax<int64_t, uint16_t>(
toptr, fromptr, parents, lenparents, outlength);
}
ERROR
awkward_reduce_argmax_int32_64(int64_t* toptr,
const int32_t* fromptr,
const int64_t* parents,
int64_t lenparents,
int64_t outlength) {
return awkward_reduce_argmax<int64_t, int32_t>(
toptr, fromptr, parents, lenparents, outlength);
}
ERROR
awkward_reduce_argmax_uint32_64(int64_t* toptr,
const uint32_t* fromptr,
const int64_t* parents,
int64_t lenparents,
int64_t outlength) {
return awkward_reduce_argmax<int64_t, uint32_t>(
toptr, fromptr, parents, lenparents, outlength);
}
ERROR
awkward_reduce_argmax_int64_64(int64_t* toptr,
const int64_t* fromptr,
const int64_t* parents,
int64_t lenparents,
int64_t outlength) {
return awkward_reduce_argmax<int64_t, int64_t>(
toptr, fromptr, parents, lenparents, outlength);
}
ERROR
awkward_reduce_argmax_uint64_64(int64_t* toptr,
const uint64_t* fromptr,
const int64_t* parents,
int64_t lenparents,
int64_t outlength) {
return awkward_reduce_argmax<int64_t, uint64_t>(
toptr, fromptr, parents, lenparents, outlength);
}
ERROR
awkward_reduce_argmax_float32_64(int64_t* toptr,
const float* fromptr,
const int64_t* parents,
int64_t lenparents,
int64_t outlength) {
return awkward_reduce_argmax<int64_t, float>(
toptr, fromptr, parents, lenparents, outlength);
}
ERROR
awkward_reduce_argmax_float64_64(int64_t* toptr,
const double* fromptr,
const int64_t* parents,
int64_t lenparents,
int64_t outlength) {
return awkward_reduce_argmax<int64_t, double>(
toptr, fromptr, parents, lenparents, outlength);
}
|