Skip to content

Commit bd5f6a9

Browse files
authored
Export GpuDevice Globals (AMReX-Codes#2918)
* Export GpuDevice Globals Implement symbol export via `AMREX_EXPORT` for the global variables in `Src/Base/AMReX_GpuDevice.H`. Follow-up to AMReX-Codes#1847 AMReX-Codes#1847 Fix AMReX-Codes#2917 * Fix: Export `AMReX::m_instance`
1 parent 4f63929 commit bd5f6a9

File tree

2 files changed

+18
-17
lines changed

2 files changed

+18
-17
lines changed

Src/Base/AMReX.H

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ namespace amrex
271271

272272
private:
273273

274-
static std::vector<std::unique_ptr<AMReX> > m_instance;
274+
static AMREX_EXPORT std::vector<std::unique_ptr<AMReX> > m_instance;
275275

276276
Geometry* m_geom = nullptr;
277277
};

Src/Base/AMReX_GpuDevice.H

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <AMReX_Config.H>
44

55
#include <AMReX.H>
6+
#include <AMReX_Extension.H>
67
#include <AMReX_Utility.H>
78
#include <AMReX_GpuTypes.H>
89
#include <AMReX_GpuError.H>
@@ -148,9 +149,9 @@ public:
148149
// definition: https://github.com/llvm/llvm-project/blob/62ec4ac90738a5f2d209ed28c822223e58aaaeb7/clang/lib/Basic/Targets/AMDGPU.cpp#L400
149150
// overview wavefront size: https://github.com/llvm/llvm-project/blob/efc063b621ea0c4d1e452bcade62f7fc7e1cc937/clang/test/Driver/amdgpu-macros.cl#L70-L115
150151
// gfx10XX has 32 threads per wavefront else 64
151-
static constexpr int warp_size = __AMDGCN_WAVEFRONT_SIZE;
152+
static AMREX_EXPORT constexpr int warp_size = __AMDGCN_WAVEFRONT_SIZE;
152153
# else
153-
static constexpr int warp_size = AMREX_HIP_OR_CUDA_OR_DPCPP(64,32,16);
154+
static AMREX_EXPORT constexpr int warp_size = AMREX_HIP_OR_CUDA_OR_DPCPP(64,32,16);
154155
# endif
155156

156157
static unsigned int maxBlocksPerLaunch () noexcept { return max_blocks_per_launch; }
@@ -166,28 +167,28 @@ private:
166167

167168
static void initialize_gpu ();
168169

169-
static int device_id;
170-
static int num_devices_used;
171-
static int verbose;
172-
static int max_gpu_streams;
170+
static AMREX_EXPORT int device_id;
171+
static AMREX_EXPORT int num_devices_used;
172+
static AMREX_EXPORT int verbose;
173+
static AMREX_EXPORT int max_gpu_streams;
173174

174175
#ifdef AMREX_USE_GPU
175-
static dim3 numThreadsMin;
176-
static dim3 numBlocksOverride, numThreadsOverride;
176+
static AMREX_EXPORT dim3 numThreadsMin;
177+
static AMREX_EXPORT dim3 numBlocksOverride, numThreadsOverride;
177178

178179
// We build gpu_default_stream and gpu_stream_pool.
179180
// The non-owning gpu_stream is used to store the current stream that will be used.
180181
// gpu_stream is a vector so that it's thread safe to write to it.
181-
static gpuStream_t gpu_default_stream;
182-
static Vector<gpuStream_t> gpu_stream_pool; // The size of this is max_gpu_stream
183-
static Vector<gpuStream_t> gpu_stream; // The size of this is omp_max_threads
184-
static gpuDeviceProp_t device_prop;
185-
static int memory_pools_supported;
186-
static unsigned int max_blocks_per_launch;
182+
static AMREX_EXPORT gpuStream_t gpu_default_stream;
183+
static AMREX_EXPORT Vector<gpuStream_t> gpu_stream_pool; // The size of this is max_gpu_stream
184+
static AMREX_EXPORT Vector<gpuStream_t> gpu_stream; // The size of this is omp_max_threads
185+
static AMREX_EXPORT gpuDeviceProp_t device_prop;
186+
static AMREX_EXPORT int memory_pools_supported;
187+
static AMREX_EXPORT unsigned int max_blocks_per_launch;
187188

188189
#ifdef AMREX_USE_DPCPP
189-
static std::unique_ptr<sycl::context> sycl_context;
190-
static std::unique_ptr<sycl::device> sycl_device;
190+
static AMREX_EXPORT std::unique_ptr<sycl::context> sycl_context;
191+
static AMREX_EXPORT std::unique_ptr<sycl::device> sycl_device;
191192
#endif
192193
#endif
193194
};

0 commit comments

Comments
 (0)