summaryrefslogtreecommitdiff
path: root/src/CuBaseLib/.svn/text-base/cudevice.h.svn-base
diff options
context:
space:
mode:
authorJoe Zhao <ztuowen@gmail.com>2014-04-14 08:14:45 +0800
committerJoe Zhao <ztuowen@gmail.com>2014-04-14 08:14:45 +0800
commitcccccbf6cca94a3eaf813b4468453160e91c332b (patch)
tree23418cb73a10ae3b0688681a7f0ba9b06424583e /src/CuBaseLib/.svn/text-base/cudevice.h.svn-base
downloadtnet-cccccbf6cca94a3eaf813b4468453160e91c332b.tar.gz
tnet-cccccbf6cca94a3eaf813b4468453160e91c332b.tar.bz2
tnet-cccccbf6cca94a3eaf813b4468453160e91c332b.zip
First commit
Diffstat (limited to 'src/CuBaseLib/.svn/text-base/cudevice.h.svn-base')
-rw-r--r--src/CuBaseLib/.svn/text-base/cudevice.h.svn-base79
1 files changed, 79 insertions, 0 deletions
diff --git a/src/CuBaseLib/.svn/text-base/cudevice.h.svn-base b/src/CuBaseLib/.svn/text-base/cudevice.h.svn-base
new file mode 100644
index 0000000..c5eeb7b
--- /dev/null
+++ b/src/CuBaseLib/.svn/text-base/cudevice.h.svn-base
@@ -0,0 +1,79 @@
+#ifndef _CUDEVICE_H_
+#define _CUDEVICE_H_
+
+#include <map>
+#include <string>
+#include <iostream>
+
+namespace TNet {
+
+ /**
+ * Singleton object which represents CUDA device
+ * responsible for CUBLAS initilalisation
+ * and memory block registration
+ */
+ class CuDevice
+ {
+ // Singleton interface...
+ private:
+ CuDevice();
+ CuDevice(CuDevice&);
+ CuDevice& operator=(CuDevice&);
+
+ public:
+ ~CuDevice();
+ static CuDevice& Instantiate()
+ { return msDevice; }
+
+ private:
+ static CuDevice msDevice;
+
+
+ /**********************************/
+ // Instance interface
+ public:
+
+ void SelectGPU(int gpu_id);
+
+ /// Check if the CUDA device is in the system
+ bool IsPresent()
+ { return mIsPresent; }
+
+ void Verbose(bool verbose)
+ { mVerbose = verbose; }
+
+ /// Sum the IO time
+ void AccuProfile(const std::string& key,double time)
+ {
+ if(mProfileMap.find(key) == mProfileMap.end()) {
+ mProfileMap[key] = 0.0;
+ }
+ mProfileMap[key] += time;
+ }
+
+ void PrintProfile()
+ {
+ std::cout << "[cudevice profile]\n";
+ std::map<std::string, double>::iterator it;
+ for(it = mProfileMap.begin(); it != mProfileMap.end(); ++it) {
+ std::cout << it->first << "\t" << it->second << "s\n";
+ }
+ }
+
+ void ResetProfile()
+ { mProfileMap.clear(); }
+
+ std::string GetFreeMemory();
+
+
+ private:
+ std::map<std::string, double> mProfileMap;
+ bool mIsPresent;
+ bool mVerbose;
+ }; //class CuDevice
+
+
+}
+
+
+#endif