Skip to main content

Rocky Solver SDK 2025 R2

api_backend

Last update: 16.07.2025
1// (C) 2024 ANSYS, Inc. Unauthorized use, distribution, or duplication is prohibited.
2#pragma once
3
4#include "rocky20/cuda/cuda_basics.hpp"
5
6#ifdef GPU_KERNEL_COMPILING_STAGE
7#include <rocky20/cuda/cuda_backend.hpp>
8#else
9#include <rocky20/device/omp_backend.hpp>
10#endif
11
12namespace backend
13{
14
15template <typename T>
16__host__ __device__ void atomic_add(T *address, T val)
17{
18#ifdef GPU_KERNEL_COMPILING_STAGE
19 CudaBackend::AtomicAdd(address, val);
20#else
21 OMPBackend::AtomicAdd(address, val);
22#endif
23}
24
25template <typename T>
26__host__ __device__ void atomic_add(T *address, T val, T &current_value)
27{
28#ifdef GPU_KERNEL_COMPILING_STAGE
29 CudaBackend::AtomicAdd(address, val, current_value);
30#else
31 OMPBackend::AtomicAdd(address, val, current_value);
32#endif
33}
34
35template <typename T>
36__host__ __device__ void atomic_max(T* address, T val)
37{
38#ifdef GPU_KERNEL_COMPILING_STAGE
39 CudaBackend::AtomicMax(address, val);
40#else
41 OMPBackend::AtomicMax(address, val);
42#endif
43}
44
45}

Connect with Ansys