32#ifndef eman__emdatacuda_h__
33#define eman__emdatacuda_h__ 1
35#ifdef EMAN2_USING_CUDA
37#define MEMPOOL_SIZE 10
42 bool copy_to_cuda()
const;
46 bool copy_to_cudaro()
const;
50 bool copy_from_device(
const bool rocpy =
false);
54 bool copy_rw_to_ro()
const;
58 void elementaccessed()
const;
62 void bindcudaarrayA(
const bool intp_mode)
const;
66 void unbindcudaarryA()
const;
70 void bindcudaarrayB(
const bool intp_mode)
const;
74 void unbindcudaarryB()
const;
78 void runcuda(
float * results)
const;
83 bool isrodataongpu()
const;
85 inline void roneedsanupdate()
90 inline float* getcudarwdata()
const
92 if(cudarwdata != 0) elementaccessed();
96 inline cudaArray* getcudarodata()
const
98 if(cudarodata != 0) elementaccessed();
104 bool rw_alloc()
const;
108 bool ro_alloc()
const;
112 void rw_free()
const;
116 void ro_free()
const;
120 void addtolist()
const;
124 void removefromlist()
const;
128 bool freeup_devicemem(
const int& num_bytes)
const;
130 void setdirtybit()
const;
132 static void switchoncuda();
134 static void switchoffcuda();
136 static void cuda_cleanup();
138 static bool cuda_initialize();
142 static const char* getcudalock();
146 mutable float* cudarwdata;
147 mutable cudaArray* cudarodata;
149 mutable size_t num_bytes;
152 const mutable EMData* nextlistitem;
153 const mutable EMData* prevlistitem;
155 mutable bool roneedsupdate;
156 mutable bool cudadirtybit;
158 static int cudadevicenum;
161 const static EMData* firstinlist;
162 const static EMData* lastinlist;
163 static bool nocudainit;