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 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
|
// 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_max.cu", line)
#include "standard_parallel_algorithms.h"
#include "awkward/kernels.h"
template <typename OUT, typename IN>
__global__ void
awkward_reduce_max_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) {
IN x = fromptr[thread_id];
toptr[parents[thread_id]] =
(x > toptr[parents[thread_id]] ? x : toptr[parents[thread_id]]);
}
}
template <typename OUT>
__global__ void
awkward_reduce_max_initialize_toptr(OUT* toptr,
OUT identity,
int64_t outlength) {
int64_t thread_id = blockIdx.x * blockDim.x + threadIdx.x;
if(thread_id < outlength) {
toptr[thread_id] = identity;
}
}
template <typename OUT, typename IN>
ERROR
awkward_reduce_max(OUT* toptr,
const IN* fromptr,
const int64_t* parents,
int64_t lenparents,
int64_t outlength,
OUT identity) {
dim3 blocks_per_grid = blocks(outlength);
dim3 threads_per_block = threads(outlength);
awkward_reduce_max_initialize_toptr<<<blocks_per_grid, threads_per_block>>>(
toptr,
identity,
outlength);
blocks_per_grid = blocks(lenparents);
threads_per_block = threads(lenparents);
awkward_reduce_max_kernel<<<blocks_per_grid, threads_per_block>>>(
toptr, fromptr, parents, lenparents);
return success();
}
ERROR
awkward_reduce_max_int8_int8_64(int8_t* toptr,
const int8_t* fromptr,
const int64_t* parents,
int64_t lenparents,
int64_t outlength,
int8_t identity) {
return awkward_reduce_max<int8_t, int8_t>(
toptr, fromptr, parents, lenparents, outlength, identity);
}
ERROR
awkward_reduce_max_uint8_uint8_64(uint8_t* toptr,
const uint8_t* fromptr,
const int64_t* parents,
int64_t lenparents,
int64_t outlength,
uint8_t identity) {
return awkward_reduce_max<uint8_t, uint8_t>(
toptr, fromptr, parents, lenparents, outlength, identity);
}
ERROR
awkward_reduce_max_int16_int16_64(int16_t* toptr,
const int16_t* fromptr,
const int64_t* parents,
int64_t lenparents,
int64_t outlength,
int16_t identity) {
return awkward_reduce_max<int16_t, int16_t>(
toptr, fromptr, parents, lenparents, outlength, identity);
}
ERROR
awkward_reduce_max_uint16_uint16_64(uint16_t* toptr,
const uint16_t* fromptr,
const int64_t* parents,
int64_t lenparents,
int64_t outlength,
uint16_t identity) {
return awkward_reduce_max<uint16_t, uint16_t>(
toptr, fromptr, parents, lenparents, outlength, identity);
}
ERROR
awkward_reduce_max_int32_int32_64(int32_t* toptr,
const int32_t* fromptr,
const int64_t* parents,
int64_t lenparents,
int64_t outlength,
int32_t identity) {
return awkward_reduce_max<int32_t, int32_t>(
toptr, fromptr, parents, lenparents, outlength, identity);
}
ERROR
awkward_reduce_max_uint32_uint32_64(uint32_t* toptr,
const uint32_t* fromptr,
const int64_t* parents,
int64_t lenparents,
int64_t outlength,
uint32_t identity) {
return awkward_reduce_max<uint32_t, uint32_t>(
toptr, fromptr, parents, lenparents, outlength, identity);
}
ERROR
awkward_reduce_max_int64_int64_64(int64_t* toptr,
const int64_t* fromptr,
const int64_t* parents,
int64_t lenparents,
int64_t outlength,
int64_t identity) {
return awkward_reduce_max<int64_t, int64_t>(
toptr, fromptr, parents, lenparents, outlength, identity);
}
ERROR
awkward_reduce_max_uint64_uint64_64(uint64_t* toptr,
const uint64_t* fromptr,
const int64_t* parents,
int64_t lenparents,
int64_t outlength,
uint64_t identity) {
return awkward_reduce_max<uint64_t, uint64_t>(
toptr, fromptr, parents, lenparents, outlength, identity);
}
ERROR
awkward_reduce_max_float32_float32_64(float* toptr,
const float* fromptr,
const int64_t* parents,
int64_t lenparents,
int64_t outlength,
float identity) {
return awkward_reduce_max<float, float>(
toptr, fromptr, parents, lenparents, outlength, identity);
}
ERROR
awkward_reduce_max_float64_float64_64(double* toptr,
const double* fromptr,
const int64_t* parents,
int64_t lenparents,
int64_t outlength,
double identity) {
return awkward_reduce_max<double, double>(
toptr, fromptr, parents, lenparents, outlength, identity);
}
|