gpu_resources.hpp File Reference #include <cuda.h> #include <cuda_runtime.h> #include <opm/simulators/linalg/gpuistl/detail/gpu_safe_call.hpp> #include <type_traits>
Include dependency graph for gpu_resources.hpp:
![]()
This graph shows which files directly or indirectly include this file:
![]() Go to the source code of this file.
Macro Definition Documentation◆ OPM_CREATE_GPU_RESOURCE
Value:
class name \
{ \
public: \
using resource_type = type; \
\
name() \
{ \
OPM_GPU_SAFE_CALL(create(&resource_, ##__VA_ARGS__)); \
} \
name(const name&) = delete; \
name& operator=(const name&) = delete; \
\
~name() \
{ \
OPM_GPU_WARN_IF_ERROR(destroy(resource_)); \
} \
\
const resource_type& get() const \
{ \
return resource_; \
} \
resource_type& get() \
{ \
return resource_; \
} \
\
private: \
resource_type resource_ = nullptr; \
}
Creates an RAII-style GPU resource class. This macro automatically generates a class that:
Usage example: OPM_CREATE_GPU_RESOURCE(MyResource, ResourceType, createFunction, destroyFunction, args...);
#define OPM_CREATE_GPU_RESOURCE(name, type, create, destroy,...) Creates an RAII-style GPU resource class. Definition: gpu_resources.hpp:44 This ensures correct setup and teardown of GPU resources without clutter in user code. ◆ OPM_CREATE_GPU_RESOURCE_NO_CREATE
Value:
class name \
{ \
public: \
using resource_type = type; \
\
name() = default; \
\
~name() \
{ \
OPM_GPU_WARN_IF_ERROR(destroy(resource_)); \
} \
name(const name&) = delete; \
name& operator=(const name&) = delete; \
\
const resource_type& get() const \
{ \
return resource_; \
} \
resource_type& get() \
{ \
return resource_; \
} \
\
private: \
resource_type resource_; \
}
A helper macro for creating a GPU resource wrapper without invoking creation logic. This macro, closely related to Usage:
Use
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||