| 1 |
/* ---------------------------------------------------------------------------- |
| 2 |
* SymForce - Copyright 2025, Skydio, Inc. |
| 3 |
* This source code is under the Apache 2.0 license found in the LICENSE file. |
| 4 |
* ---------------------------------------------------------------------------- */ |
| 5 |
|
| 6 |
#pragma once |
| 7 |
|
| 8 |
#include <cstdint> |
| 9 |
|
| 10 |
#include <cuda_runtime.h> |
| 11 |
|
| 12 |
namespace caspar { |
| 13 |
|
| 14 |
/** |
| 15 |
* Struct used in shared index operations in a cuda block. See memops.cuh for usage. |
| 16 |
* |
| 17 |
* There is one shared index per thread in the block. |
| 18 |
* @param unique: The unique indices accessed by the thread block in sorted order. |
| 19 |
* Does not belong to a particular thread. |
| 20 |
* @param target: The target index of the thread. The following acces is valid (but inefficient): |
| 21 |
* loat var = data[shared_indices_out[shared_indices_out[threadIdx.x].target].unique]; |
| 22 |
* @param argsort: Indices making the access pattern sorted. i.e. the following is sorted: |
| 23 |
* sorted_data[threadIdx.x] = shared_indices_out[shared_indices_out[threadIdx.x].argsort].unique |
| 24 |
* This is used to for better warp coalescing in reduction operations. |
| 25 |
*/ |
| 26 |
struct SharedIndex { |
| 27 |
uint32_t unique; |
| 28 |
uint16_t target; |
| 29 |
uint16_t argsort; |
| 30 |
}; |
| 31 |
|
| 32 |
void SharedIndices(const unsigned int* const indices, SharedIndex* const shared_indices_out, |
| 33 |
const unsigned int size); |
| 34 |
|
| 35 |
}; // namespace caspar |