summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Simianer <p@simianer.de>2015-12-09 11:24:07 +0100
committerPatrick Simianer <p@simianer.de>2015-12-09 11:24:07 +0100
commit869e1c86d80dee01b39d447e741f9498d917a418 (patch)
treed2880d6451da9106dbe00bed4bec8995a19c2bb5
parent44cf8e0348e0023b3cf3b612c43273c7b35f5f5c (diff)
cuda
-rw-r--r--cuda/Makefile6
-rw-r--r--cuda/memcpy.cu17
-rw-r--r--cuda/meminfo.cu14
3 files changed, 37 insertions, 0 deletions
diff --git a/cuda/Makefile b/cuda/Makefile
new file mode 100644
index 0000000..17b5b6b
--- /dev/null
+++ b/cuda/Makefile
@@ -0,0 +1,6 @@
+memcpy: memcpy.cu
+ nvcc memcpy.cu
+
+meminfo: meminfo.cu
+ nvcc meminfo.cu
+
diff --git a/cuda/memcpy.cu b/cuda/memcpy.cu
new file mode 100644
index 0000000..e2d5781
--- /dev/null
+++ b/cuda/memcpy.cu
@@ -0,0 +1,17 @@
+#include <iostream>
+
+using namespace std;
+
+int main(void)
+{
+ void* ptr = NULL;
+ float* f = new float[1];
+ cudaMalloc(&ptr, sizeof(float)*1);
+ int r = cudaMemcpy(ptr, f, sizeof(float) * 1, cudaMemcpyHostToDevice);
+ cout << r << endl;
+ cout << cudaSuccess << endl;
+ cout << cudaErrorInvalidValue << endl;
+ cout << cudaErrorInvalidDevicePointer << endl;
+ cout << cudaErrorInvalidMemcpyDirection << endl;
+}
+
diff --git a/cuda/meminfo.cu b/cuda/meminfo.cu
new file mode 100644
index 0000000..aebe709
--- /dev/null
+++ b/cuda/meminfo.cu
@@ -0,0 +1,14 @@
+#include <iostream>
+
+using namespace std;
+
+int
+main(void)
+{
+ size_t free_bytes;
+ size_t total_bytes;
+ cudaSetDevice(0);
+ cudaMemGetInfo( &free_bytes, &total_bytes );
+ cerr << "[cnn] Memory Free (MB): " << free_bytes/1024/1024 << "/" << total_bytes/1024/1024 << endl << endl;
+}
+