OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
GpuPluginAbi.h
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2//
3// Copyright 2026 Caleb Buahin
4//
5// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing, software
12// distributed under the License is distributed on an "AS IS" BASIS,
13// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14// See the License for the specific language governing permissions and
15// limitations under the License.
16
40
41#ifndef OPENSWMM_ENGINE_2D_GPU_PLUGIN_ABI_H
42#define OPENSWMM_ENGINE_2D_GPU_PLUGIN_ABI_H
43
44/*
45 * Export/visibility marker for the two ABI entry points.
46 *
47 * The declaration here and the definition in each plugin .cpp must agree on
48 * linkage or MSVC rejects the definition with C2375 ("redefinition; different
49 * linkage") — a plain `extern "C"` declaration followed by an
50 * `__declspec(dllexport)` definition is a mismatch. A plugin translation unit
51 * defines OPENSWMM_GPU_PLUGIN_BUILD (see the gpu CMakeLists) so it both
52 * declares and defines the symbols as dllexport. The core never link-imports
53 * these (it resolves them via dlsym/GetProcAddress), so the non-plugin case is
54 * a no-op marker.
55 */
56#if defined(_WIN32)
57#if defined(OPENSWMM_GPU_PLUGIN_BUILD)
58#define OPENSWMM_GPU_ABI __declspec(dllexport)
59#else
60#define OPENSWMM_GPU_ABI
61#endif
62#elif defined(__GNUC__)
63#define OPENSWMM_GPU_ABI __attribute__((visibility("default")))
64#else
65#define OPENSWMM_GPU_ABI
66#endif
67
68#ifdef __cplusplus
69extern "C" {
70#endif
71
78/* v5: reject v3/v4 C++ vtables predating completedSourceTime and the current
79 * state layouts. A matching build contract and plugin-owned destruction are
80 * mandatory. Never accept an older version through a thread-count fallback. */
81/* v6: SurfaceTransportState adds the canonical RK2 age-generation ledger;
82 * SurfaceStateData offsets therefore change. Rebuild every surface plugin.
83 * The independent C-only groundwater raw-recharge ABI remains v1. */
84/* v7: SurfaceStateData adds accepted runtime-forcing rainfall receipts.
85 * Rebuild surface plugins; independent raw groundwater recharge remains v1. */
86/* v8: SurfaceStateData adds gross applied boundary-water transfer arrays.
87 * Rebuild surface plugins; independent raw groundwater recharge remains v1. */
88/* v9: SolverOptions2D adds the physical-time momentum smoothing reference
89 * interval. Rebuild surface plugins to match the changed option layout. */
90#define OPENSWMM_GPU_ABI_VERSION 9
91
100
115
133
151
183
196
197#ifdef __cplusplus
198} /* extern "C" */
199#endif
200
201#endif /* OPENSWMM_ENGINE_2D_GPU_PLUGIN_ABI_H */
OPENSWMM_GPU_ABI int openswmm_gpu_host_threads(void)
(v4, optional) Host thread count the plugin's Kokkos runtime is initialised with; 0 when not yet init...
Definition GpuPluginOmp.cpp:114
OPENSWMM_GPU_ABI int openswmm_gpu_probe(OpenSwmmGpuProbe *out)
Query the plugin for a usable GPU device.
Definition GpuPluginCuda.cpp:73
OPENSWMM_GPU_ABI void openswmm_destroy_gpu_explicit_solver(void *solver)
Destroy on the execution owner through the allocating plugin.
Definition GpuPluginSupport.hpp:53
OPENSWMM_GPU_ABI const char * openswmm_gpu_last_error(void)
Last construction error on this controlling thread; plugin-owned text.
Definition GpuPluginSupport.hpp:50
OPENSWMM_GPU_ABI const char * openswmm_gpu_build_contract(void)
v5 compatibility check, called BEFORE probe or factory.
Definition GpuPluginSupport.hpp:47
OpenSwmmGpuVendor
Definition GpuPluginAbi.h:93
@ OPENSWMM_GPU_VENDOR_OPENMP
Definition GpuPluginAbi.h:98
@ OPENSWMM_GPU_VENDOR_HIP
Definition GpuPluginAbi.h:96
@ OPENSWMM_GPU_VENDOR_CUDA
Definition GpuPluginAbi.h:95
@ OPENSWMM_GPU_VENDOR_SYCL
Definition GpuPluginAbi.h:97
@ OPENSWMM_GPU_VENDOR_NONE
Definition GpuPluginAbi.h:94
OPENSWMM_GPU_ABI void * openswmm_make_gpu_explicit_solver(const OpenSwmmGpuProbe *probe)
Construct the Kokkos explicit LTS marcher surface solver.
Definition GpuPluginCuda.cpp:99
#define OPENSWMM_GPU_ABI
Definition GpuPluginAbi.h:65
Definition GpuPluginAbi.h:102
unsigned long long device_mem_bytes
Definition GpuPluginAbi.h:107
int device_count
Definition GpuPluginAbi.h:104
char device_name[128]
Definition GpuPluginAbi.h:106
int requested_threads
Definition GpuPluginAbi.h:113
int abi_version
Definition GpuPluginAbi.h:103
int vendor
Definition GpuPluginAbi.h:105