5 #include <cuda/std/utility>
10 namespace map_kernels {
12 template<
int block_size,
typename map_t,
typename K,
typename V>
13 __global__
void put_(map_t map, cuda::std::pair<K, V>* operations, V* output,
size_t size) {
15 int tidx = threadIdx.x;
16 int bidx = blockIdx.x;
20 if(tidx + bidx * block_size < size) {
21 key = operations[tidx + bidx * block_size].first;
22 val = operations[tidx + bidx * block_size].second;
25 V res = map.put(key, val, tidx + bidx * block_size < size);
27 if(tidx + bidx * block_size < size) {
28 output[tidx + bidx * block_size] = res;
32 template<
int block_size,
typename map_t,
typename K,
typename V>
33 __global__
void put_(map_t map, K* operations_keys, V* operations_values, V* output,
size_t size) {
35 int tidx = threadIdx.x;
36 int bidx = blockIdx.x;
40 if(tidx + bidx * block_size < size) {
41 key = operations_keys[tidx + bidx * block_size];
42 val = operations_values[tidx + bidx * block_size];
45 V res = map.put(key, val, tidx + bidx * block_size < size);
47 if(tidx + bidx * block_size < size) {
48 output[tidx + bidx * block_size] = res;
53 template<
int block_size,
typename map_t,
typename K,
typename V>
54 __global__
void get_(map_t map, K* operations, cuda::std::pair<bool, V>* output,
size_t size) {
56 int tidx = threadIdx.x;
57 int bidx = blockIdx.x;
61 if(tidx + bidx * block_size < size) {
62 key = operations[tidx + bidx * block_size];
65 bool res = map.get(key, value, tidx + bidx * block_size < size);
66 if(tidx + bidx * block_size < size) {
67 output[tidx + bidx * block_size] = {res, value};
72 template<
int block_size,
typename map_t,
typename K,
typename V>
73 __global__
void update_(map_t map, cuda::std::pair<K, V>* operations, cuda::std::pair<bool, V>* output,
size_t size) {
75 int tidx = threadIdx.x;
76 int bidx = blockIdx.x;
80 if(tidx + bidx * block_size < size) {
81 key = operations[tidx + bidx * block_size].first;
82 val = operations[tidx + bidx * block_size].second;
85 cuda::std::pair<bool, V> res = map.put(key, val, tidx + bidx * block_size < size);
86 if(tidx + bidx * block_size < size) {
87 output[tidx + bidx * block_size] = res;