Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
clvisc::OpenclBackend Class Reference

#include <JETSCAPE/blob/main/external_packages/clvisc_wrapper/include/opencl_backend.h>

+ Collaboration diagram for clvisc::OpenclBackend:

Public Member Functions

 OpenclBackend (std::string device_type, int device_id)
 
cl::Program BuildProgram (std::string fname, const std::string &option)
 
cl::Kernel CreateKernel (const cl::Program &prg, std::string func_name)
 
cl::Context Context ()
 
cl::CommandQueue Queue ()
 
void DeviceInfo ()
 
cl_int DeviceType ()
 
float ExcutionTime (cl::Event &event)
 
cl::Buffer CreateBuffer (size_t bytes_of_buffer)
 
cl::Image2D CreateImage2DByCopyVector (std::vector< cl_float4 > &source_vector, size_t width, size_t height, bool read_only)
 
template<typename ValueType >
cl::Buffer CreateBufferByCopyVector (std::vector< ValueType > &source_vector, bool read_only)
 
void enqueue_run (const cl::Kernel &kernel_, const cl::NDRange &global_size, const cl::NDRange &local_size)
 
template<typename ValueType >
void enqueue_copy (const std::vector< ValueType > &src_vector, cl::Buffer &dst_buffer)
 
template<typename ValueType >
void enqueue_copy (const cl::Buffer &src_buffer, std::vector< ValueType > &dst_vector)
 
void enqueue_copy (const cl::Buffer &src_buffer, cl::Buffer &dst_buffer, size_t size)
 

Public Attributes

cl::Context context_
 
cl::CommandQueue queue_
 
std::map< std::string,
cl::Program
programs
 
std::map< std::string, cl::Kernelkernel_funcs
 
std::map< std::string, cl::Bufferbuffers
 

Private Member Functions

cl::Context CreateContext_ (const cl_int &device_type)
 

Private Attributes

cl_int device_type_
 
std::vector< cl::Devicedevices_
 
cl_int device_id_
 
cl::Device device_
 

Detailed Description

Definition at line 66 of file opencl_backend.h.

View newest version in sPHENIX GitHub at line 66 of file opencl_backend.h

Constructor & Destructor Documentation

clvisc::OpenclBackend::OpenclBackend ( std::string  device_type,
int  device_id 
)

Definition at line 67 of file opencl_backend.cc.

View newest version in sPHENIX GitHub at line 67 of file opencl_backend.cc

References context_, CreateContext_(), device_, device_id_, device_type_, DeviceInfo(), devices_, cl::Context::getInfo(), and queue_.

+ Here is the call graph for this function:

Member Function Documentation

cl::Program clvisc::OpenclBackend::BuildProgram ( std::string  fname,
const std::string &  option 
)

helper functions: Build each program in programs vector with given options

Note
The compiling error of the kernel *.cl can be print out

Definition at line 131 of file opencl_backend.cc.

View newest version in sPHENIX GitHub at line 131 of file opencl_backend.cc

References context_, device_, devices_, check_license::err(), and tgeo-response2json::prog.

Referenced by clvisc::BulkInfo::BulkInfo(), clvisc::CLIdeal::CLIdeal(), and clvisc::CLVisc::CLVisc().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

cl::Context clvisc::OpenclBackend::Context ( )
inline

return gpu context

Definition at line 89 of file opencl_backend.h.

View newest version in sPHENIX GitHub at line 89 of file opencl_backend.h

References context_.

cl::Buffer clvisc::OpenclBackend::CreateBuffer ( size_t  bytes_of_buffer)

create a buffer on GPU, e.g., for one cl_real array of N elements, the bytes_of_buffer = N * sizeof(cl_real)

Definition at line 154 of file opencl_backend.cc.

View newest version in sPHENIX GitHub at line 154 of file opencl_backend.cc

References context_.

Referenced by clvisc::BulkInfo::BulkInfo(), clvisc::CLVisc::initialize_gpu_buffer_(), and clvisc::CLIdeal::initialize_gpu_buffer_().

+ Here is the caller graph for this function:

template<typename ValueType >
template cl::Buffer clvisc::OpenclBackend::CreateBufferByCopyVector ( std::vector< ValueType > &  source_vector,
bool  read_only 
)

create a buffer on GPU, with the same size and content as source_vector Notice: the cl.hpp does not support creating buffers from (const void *); so one can not use const std::vector<ValueType> & source_vector here

Definition at line 159 of file opencl_backend.cc.

View newest version in sPHENIX GitHub at line 159 of file opencl_backend.cc

References context_.

Referenced by clvisc::CLVisc::initialize_gpu_buffer_(), and clvisc::CLIdeal::initialize_gpu_buffer_().

+ Here is the caller graph for this function:

cl::Context clvisc::OpenclBackend::CreateContext_ ( const cl_int &  device_type)
private

helper functions: create context from the device type with one platform which support it

Returns
one context in the type of cl::Context

Definition at line 103 of file opencl_backend.cc.

View newest version in sPHENIX GitHub at line 103 of file opencl_backend.cc

References cl::Platform::get(), i, and j.

Referenced by OpenclBackend().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

cl::Image2D clvisc::OpenclBackend::CreateImage2DByCopyVector ( std::vector< cl_float4 > &  source_vector,
size_t  width,
size_t  height,
bool  read_only 
)

create a image2d_t buffer on GPU by copying host point

Definition at line 171 of file opencl_backend.cc.

View newest version in sPHENIX GitHub at line 171 of file opencl_backend.cc

References context_.

Referenced by clvisc::CLIdeal::read_eos_table_().

+ Here is the caller graph for this function:

cl::Kernel clvisc::OpenclBackend::CreateKernel ( const cl::Program prg,
std::string  func_name 
)
inline

Definition at line 84 of file opencl_backend.h.

View newest version in sPHENIX GitHub at line 84 of file opencl_backend.h

void clvisc::OpenclBackend::DeviceInfo ( )

printout the available devices

Definition at line 254 of file opencl_backend.cc.

View newest version in sPHENIX GitHub at line 254 of file opencl_backend.cc

References devices_.

Referenced by OpenclBackend().

+ Here is the caller graph for this function:

cl_int clvisc::OpenclBackend::DeviceType ( )

printout the device type, CL_DEVICE_TYPE_CPU or CL_DEVICE_TYPE_GPU

Definition at line 278 of file opencl_backend.cc.

View newest version in sPHENIX GitHub at line 278 of file opencl_backend.cc

References device_type_.

Referenced by clvisc::CLIdeal::CLIdeal(), and clvisc::CLIdeal::max_energy_density().

+ Here is the caller graph for this function:

template<typename ValueType >
void clvisc::OpenclBackend::enqueue_copy ( const std::vector< ValueType > &  src_vector,
cl::Buffer dst_buffer 
)

Definition at line 204 of file opencl_backend.cc.

View newest version in sPHENIX GitHub at line 204 of file opencl_backend.cc

References cl::CommandQueue::enqueueWriteBuffer(), event, and queue_.

Referenced by clvisc::BulkInfo::add_data(), clvisc::CLVisc::evolve(), and clvisc::CLIdeal::max_energy_density().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<typename ValueType >
void clvisc::OpenclBackend::enqueue_copy ( const cl::Buffer src_buffer,
std::vector< ValueType > &  dst_vector 
)

Definition at line 221 of file opencl_backend.cc.

View newest version in sPHENIX GitHub at line 221 of file opencl_backend.cc

References cl::CommandQueue::enqueueReadBuffer(), event, and queue_.

+ Here is the call graph for this function:

void clvisc::OpenclBackend::enqueue_copy ( const cl::Buffer src_buffer,
cl::Buffer dst_buffer,
size_t  size 
)

Definition at line 237 of file opencl_backend.cc.

View newest version in sPHENIX GitHub at line 237 of file opencl_backend.cc

References cl::CommandQueue::enqueueCopyBuffer(), event, and queue_.

+ Here is the call graph for this function:

void clvisc::OpenclBackend::enqueue_run ( const cl::Kernel kernel_,
const cl::NDRange global_size,
const cl::NDRange local_size 
)

Definition at line 187 of file opencl_backend.cc.

View newest version in sPHENIX GitHub at line 187 of file opencl_backend.cc

References cl::CommandQueue::enqueueNDRangeKernel(), event, cl::NullRange, and queue_.

Referenced by clvisc::BulkInfo::add_data(), clvisc::CLIdeal::half_step_(), clvisc::CLVisc::half_step_israel_stewart_(), clvisc::CLVisc::half_step_visc_(), clvisc::CLVisc::israel_stewart_initialize_(), clvisc::CLIdeal::max_energy_density(), and clvisc::CLVisc::update_udiff_().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

float clvisc::OpenclBackend::ExcutionTime ( cl::Event event)

utility to compute the excution time of one event

get the kernel excution time in units of seconds

Definition at line 94 of file opencl_backend.cc.

View newest version in sPHENIX GitHub at line 94 of file opencl_backend.cc

cl::CommandQueue clvisc::OpenclBackend::Queue ( )
inline

return command queue

Definition at line 92 of file opencl_backend.h.

View newest version in sPHENIX GitHub at line 92 of file opencl_backend.h

References queue_.

Member Data Documentation

std::map<std::string, cl::Buffer> clvisc::OpenclBackend::buffers

Definition at line 77 of file opencl_backend.h.

View newest version in sPHENIX GitHub at line 77 of file opencl_backend.h

cl::Context clvisc::OpenclBackend::context_

Definition at line 72 of file opencl_backend.h.

View newest version in sPHENIX GitHub at line 72 of file opencl_backend.h

Referenced by BuildProgram(), Context(), CreateBuffer(), CreateBufferByCopyVector(), CreateImage2DByCopyVector(), and OpenclBackend().

cl::Device clvisc::OpenclBackend::device_
private

Definition at line 134 of file opencl_backend.h.

View newest version in sPHENIX GitHub at line 134 of file opencl_backend.h

Referenced by BuildProgram(), and OpenclBackend().

cl_int clvisc::OpenclBackend::device_id_
private

Definition at line 133 of file opencl_backend.h.

View newest version in sPHENIX GitHub at line 133 of file opencl_backend.h

Referenced by OpenclBackend().

cl_int clvisc::OpenclBackend::device_type_
private

Definition at line 131 of file opencl_backend.h.

View newest version in sPHENIX GitHub at line 131 of file opencl_backend.h

Referenced by DeviceType(), and OpenclBackend().

std::vector<cl::Device> clvisc::OpenclBackend::devices_
private

Definition at line 132 of file opencl_backend.h.

View newest version in sPHENIX GitHub at line 132 of file opencl_backend.h

Referenced by BuildProgram(), DeviceInfo(), and OpenclBackend().

std::map<std::string, cl::Kernel> clvisc::OpenclBackend::kernel_funcs

Definition at line 76 of file opencl_backend.h.

View newest version in sPHENIX GitHub at line 76 of file opencl_backend.h

std::map<std::string, cl::Program> clvisc::OpenclBackend::programs

Definition at line 75 of file opencl_backend.h.

View newest version in sPHENIX GitHub at line 75 of file opencl_backend.h

cl::CommandQueue clvisc::OpenclBackend::queue_

Definition at line 73 of file opencl_backend.h.

View newest version in sPHENIX GitHub at line 73 of file opencl_backend.h

Referenced by enqueue_copy(), enqueue_run(), OpenclBackend(), and Queue().


The documentation for this class was generated from the following files: