Loading graph_framework/cuda_context.hpp +36 −32 Original line number Diff line number Diff line Loading @@ -16,32 +16,6 @@ #include "node.hpp" namespace gpu { //------------------------------------------------------------------------------ /// @brief Initalize cuda. //------------------------------------------------------------------------------ static void init() { cuInit(0); } //------------------------------------------------------------------------------ /// @brief Class representing a cuda gpu context. //------------------------------------------------------------------------------ template<typename T, bool SAFE_MATH=false> class cuda_context { private: /// The cuda device. CUdevice device; /// The cuda context. CUcontext context; /// The cuda code library. CUmodule module; /// Argument map. std::map<graph::leaf_node<T, SAFE_MATH> *, CUdeviceptr> kernel_arguments; /// Result buffer. CUdeviceptr result_buffer; /// Cuda stream. CUstream stream; //------------------------------------------------------------------------------ /// @brief Check results of realtime compile. /// @params[in] name Name of the operation. Loading @@ -61,7 +35,7 @@ namespace gpu { /// @params[in] result Result code of the operation. /// @params[in] name Name of the operation. //------------------------------------------------------------------------------ static void check_error(CUresult result, static check_error(CUresult result, const std::string &name) { #ifndef NDEBUG const char *error; Loading @@ -72,6 +46,36 @@ namespace gpu { #endif } //------------------------------------------------------------------------------ /// @brief Initalize cuda. //------------------------------------------------------------------------------ static CUresult cuda_init() { const CUresult result = cuInit(0); check_error(result, "cuInit"); return result; } /// Initalize Cuda. static const result = cuda_init(); //------------------------------------------------------------------------------ /// @brief Class representing a cuda gpu context. //------------------------------------------------------------------------------ template<typename T, bool SAFE_MATH=false> class cuda_context { private: /// The cuda device. CUdevice device; /// The cuda context. CUcontext context; /// The cuda code library. CUmodule module; /// Argument map. std::map<graph::leaf_node<T, SAFE_MATH> *, CUdeviceptr> kernel_arguments; /// Result buffer. CUdeviceptr result_buffer; /// Cuda stream. CUstream stream; //------------------------------------------------------------------------------ /// @brief Check results of async cuda functions. /// Loading Loading
graph_framework/cuda_context.hpp +36 −32 Original line number Diff line number Diff line Loading @@ -16,32 +16,6 @@ #include "node.hpp" namespace gpu { //------------------------------------------------------------------------------ /// @brief Initalize cuda. //------------------------------------------------------------------------------ static void init() { cuInit(0); } //------------------------------------------------------------------------------ /// @brief Class representing a cuda gpu context. //------------------------------------------------------------------------------ template<typename T, bool SAFE_MATH=false> class cuda_context { private: /// The cuda device. CUdevice device; /// The cuda context. CUcontext context; /// The cuda code library. CUmodule module; /// Argument map. std::map<graph::leaf_node<T, SAFE_MATH> *, CUdeviceptr> kernel_arguments; /// Result buffer. CUdeviceptr result_buffer; /// Cuda stream. CUstream stream; //------------------------------------------------------------------------------ /// @brief Check results of realtime compile. /// @params[in] name Name of the operation. Loading @@ -61,7 +35,7 @@ namespace gpu { /// @params[in] result Result code of the operation. /// @params[in] name Name of the operation. //------------------------------------------------------------------------------ static void check_error(CUresult result, static check_error(CUresult result, const std::string &name) { #ifndef NDEBUG const char *error; Loading @@ -72,6 +46,36 @@ namespace gpu { #endif } //------------------------------------------------------------------------------ /// @brief Initalize cuda. //------------------------------------------------------------------------------ static CUresult cuda_init() { const CUresult result = cuInit(0); check_error(result, "cuInit"); return result; } /// Initalize Cuda. static const result = cuda_init(); //------------------------------------------------------------------------------ /// @brief Class representing a cuda gpu context. //------------------------------------------------------------------------------ template<typename T, bool SAFE_MATH=false> class cuda_context { private: /// The cuda device. CUdevice device; /// The cuda context. CUcontext context; /// The cuda code library. CUmodule module; /// Argument map. std::map<graph::leaf_node<T, SAFE_MATH> *, CUdeviceptr> kernel_arguments; /// Result buffer. CUdeviceptr result_buffer; /// Cuda stream. CUstream stream; //------------------------------------------------------------------------------ /// @brief Check results of async cuda functions. /// Loading