19 #ifndef SINGA_CORE_COMMON_H_ 20 #define SINGA_CORE_COMMON_H_ 23 #include "singa/singa_config.h" 26 #include "singa/utils/logging.h" 29 #include <cuda_runtime.h> 30 #include <cublas_v2.h> 39 #include "singa/utils/opencl_utils.h" 62 Block(
void* ptr,
size_t size,
size_t offset = 0)
63 : data_(ptr), size_(size), offset_(offset) {
69 void* mutable_data() {
71 return static_cast<char*
>(data_) + offset_;
73 const void* data()
const {
74 CHECK(initialized_) <<
"Must initialize data before reading it";
75 return static_cast<char*
>(data_) + offset_;
77 size_t size()
const {
return size_; }
78 size_t offset()
const {
return offset_; }
85 int ref_count()
const {
return ref_count_.load(); }
87 bool initialized()
const {
93 void* data_ =
nullptr;
96 bool initialized_ =
false;
99 std::atomic<int> ref_count_;
103 std::mt19937 random_generator;
105 cublasHandle_t cublas_handle;
107 curandGenerator_t curand_generator;
109 cudnnHandle_t cudnn_handle;
119 mkldnn::engine *engine;
125 #endif // SINGA_CORE_COMMON_H_ To implemente functions using cuda libraries.
Definition: common.h:54
To implement function using opencl libraries.
Definition: common.h:56
To implemente functions using cpp libraries.
Definition: common.h:52
Block represent a chunk of memory (on device or host).
Definition: common.h:60
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements...
Definition: common.h:48