Skip to main content

Rocky Solver SDK 2025 R2

api_cuda_triangles

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

Connect with Ansys