Skip to main content

Rocky Solver SDK 2024 R2

api_cuda_triangles

Last update: 17.07.2025
1#pragma once
2
3#include <rocky20/api/device/api_device_triangles.hpp>
4#include <rocky20/api/device/api_cuda.hpp>
5
6namespace rocky::cuda
7{
8
9template <typename Callable>
10void dispatch_triangles_kernel(
11 IRockyModel &model,
12 Callable h_triangle_f_ptr,
13 void **udf_devices_data
14)
15{
16 if (model.get_number_of_active_triangles() <= 0)
17 return;
18
19 for (int i=0; i<model.get_number_of_devices(); i++)
20 {
21 CUDA_SET_DEVICE(model.get_device_id(i));
22
23 void *udf_device_data = udf_devices_data[i];
24 device::execute_triangles_function<CudaBackend><<<CD_NBLOCKS, CD_NTHREADS>>>(
25 model.get_device_data(i), model.get_current_time(),
26 h_triangle_f_ptr, udf_device_data
27 );
28 }
29
30 // Sync all GPUs
31 sync_devices(model);
32}
33
34} // namespace rocky::cuda
Definition rocky_api.h:60
int get_number_of_devices() const
Definition rocky_api.cpp:159
int get_number_of_active_triangles()
Definition rocky_api.cpp:144
double get_current_time() const
Definition rocky_api.cpp:129
int get_device_id(int device_index) const
Definition rocky_api.cpp:164

Connect with Ansys