00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef eman__emdatacuda_h__
00033 #define eman__emdatacuda_h__ 1
00034
00035 #ifdef EMAN2_USING_CUDA
00036
00037 #define MEMPOOL_SIZE 10
00038 public:
00039
00042 bool copy_to_cuda_keepcpu() const;
00043
00046 bool copy_to_cuda();
00047
00050 bool copy_to_cudaro() const;
00051
00054 bool copy_from_device(const bool rocpy = false);
00055
00058 bool copy_rw_to_ro() const;
00059
00062 void elementaccessed() const;
00063
00066 void bindcudaarrayA(const bool intp_mode) const;
00067
00070 void unbindcudaarryA() const;
00071
00074 void bindcudaarrayB(const bool intp_mode) const;
00075
00078 void unbindcudaarryB() const;
00079
00082 void runcuda(float * results) const;
00083
00087 bool isrodataongpu() const;
00088
00089 inline void roneedsanupdate()
00090 {
00091 roneedsupdate = true;
00092 }
00093
00094 inline float* getcudarwdata() const
00095 {
00096 return cudarwdata;
00097 }
00098
00099 inline cudaArray* getcudarodata() const
00100 {
00101 return cudarodata;
00102 }
00103
00106 bool rw_alloc() const;
00107
00110 bool ro_alloc() const;
00111
00114 void rw_free() const;
00115
00118 void ro_free() const;
00119
00122 void addtolist() const;
00123
00126 void removefromlist() const;
00127
00130 bool freeup_devicemem(const int& num_bytes) const;
00131
00132 static void switchoncuda();
00133
00134 static void switchoffcuda();
00135
00136 static void cuda_cleanup();
00137
00138 static bool cuda_initialize();
00139
00140 static bool usecuda;
00141
00142 static const char* getcudalock();
00143
00144 private:
00145
00146 mutable float* cudarwdata;
00147 mutable cudaArray* cudarodata;
00148
00149 mutable size_t num_bytes;
00150
00151
00152 const mutable EMData* nextlistitem;
00153 const mutable EMData* prevlistitem;
00154
00155 mutable bool roneedsupdate;
00156
00157 static int cudadevicenum;
00158 static int memused;
00159 static int fudgemem;
00160 const static EMData* firstinlist;
00161 const static EMData* lastinlist;
00162
00163 #endif // EMAN2_USING_CUDA
00164
00165 #endif //eman__emdatacuda_h__ 1
00166