Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

gdev: update to README

cuda: added EXPORT_SYMBOL()s to some CUDA API
test: added memcpy_async for OS-space CUDA test
  • Loading branch information...
commit 3c7b746de3ee3a610259cbbb6ea9bcb7d48a6633 1 parent 9fd7f4b
Shinpei Kato authored
View
22 README
@@ -128,7 +128,16 @@ Ocelot, which can translate CUDA Drier API to Runtime API.
cd $(TOPDIR)/gdev/cuda
mkdir build
cd build
-../configure # if you want to run CUDA in OS, specify --target=kcuda
+../configure
+make
+sudo make install
+
+Gdev also supports CUDA in the operating system. You are required to
+install "kcuda" module to use this functionality.
+
+cd $(TOPDIR)/gdev/cuda
+mkdir kbuild
+../configure --target=kcuda
make
sudo make install
@@ -138,3 +147,14 @@ cd $(TOPDIR)/test/cuda/user/madd
make
./user_test 256 # a[256] x b[256] = c[256]
+8. CUDA Driver API test (OS-space programs)
+
+cd $(TOPDIR)/test/cuda/kernel/memcpy
+make
+sudo insmod ./kernel_test.ko size=10000 # copy 0x10000 size
+
+NOTE: Please be careful when doing this test as it runs a program
+in module_init(). If you run a very long program as it is, you may
+crash your system. If you want to run a very long program, you must
+provide a proper module implementation, e.g., using kernel threads.
+
View
22 cuda/kcuda/kcuda_drv.c
@@ -101,5 +101,27 @@ EXPORT_SYMBOL(cuMemFree);
EXPORT_SYMBOL(cuMemAllocHost);
EXPORT_SYMBOL(cuMemFreeHost);
EXPORT_SYMBOL(cuMemcpyDtoH);
+EXPORT_SYMBOL(cuMemcpyDtoHAsync);
EXPORT_SYMBOL(cuMemcpyHtoD);
+EXPORT_SYMBOL(cuMemcpyHtoDAsync);
EXPORT_SYMBOL(cuMemcpyDtoD);
+EXPORT_SYMBOL(cuMemHostAlloc);
+EXPORT_SYMBOL(cuMemHostGetDevicePointer);
+/* Memory mapping - Gdev extension */
+EXPORT_SYMBOL(cuMemMap);
+EXPORT_SYMBOL(cuMemUnmap);
+/* Memory mapped address - Gdev extension */
+EXPORT_SYMBOL(cuMemGetPhysAddr);
+
+/* Stream Management */
+EXPORT_SYMBOL(cuStreamCreate);
+EXPORT_SYMBOL(cuStreamDestroy);
+EXPORT_SYMBOL(cuStreamQuery);
+EXPORT_SYMBOL(cuStreamSynchronize);
+EXPORT_SYMBOL(cuStreamWaitEvent);
+
+/* Inter-Process Communication (IPC) - Gdev extension */
+EXPORT_SYMBOL(cuShmGet);
+EXPORT_SYMBOL(cuShmAt);
+EXPORT_SYMBOL(cuShmDt);
+EXPORT_SYMBOL(cuShmCtl);
View
2  test/cuda/common/memcpy.c
@@ -2,7 +2,7 @@
#ifdef __KERNEL__ /* just for measurement */
#include <linux/vmalloc.h>
#include <linux/time.h>
-#define printf printk
+#define printf printk /* note that "%f" doesn't work. */
#define malloc vmalloc
#define free vfree
#define gettimeofday(x, y) do_gettimeofday(x)
View
20 test/cuda/kernel/memcpy_async/Makefile
@@ -0,0 +1,20 @@
+TARGET = kernel_test
+$(TARGET)-y := main.o memcpy_async.o
+GDEVDIR = /usr/local/gdev
+GDEVINC = $(GDEVDIR)/include
+GDEVETC = $(GDEVDIR)/etc
+DRMINC = /lib/modules/$(shell uname -r)/source/include/drm
+CPPFLAGS += -Wno-strict-prototypes
+KERNELDIR = /lib/modules/$(shell uname -r)/build
+
+obj-m := $(TARGET).o
+
+EXTRA_CFLAGS = -I $(GDEVINC)
+KBUILD_EXTRA_SYMBOLS = $(GDEVETC)/Module.symvers.kcuda
+
+all:
+ +make -C $(KERNELDIR) M=$(PWD) modules
+
+clean:
+ +make -C $(KERNELDIR) M=$(PWD) clean
+ rm -f *~
View
35 test/cuda/kernel/memcpy_async/main.c
@@ -0,0 +1,35 @@
+#include <asm/uaccess.h>
+#include <linux/kthread.h>
+#include <linux/module.h>
+
+MODULE_LICENSE("Dual BSD/GPL");
+MODULE_DESCRIPTION("CUDA Test");
+MODULE_AUTHOR("Shinpei Kato");
+
+int cuda_test_memcpy_async(uint32_t);
+
+struct task_struct *test_thread = NULL;
+static unsigned int size = 0x10000000; /* 256MB */
+module_param(size, int, 0444);
+MODULE_PARM_DESC(size, "data size (in hex)");
+
+static void test_thread_func(void *__data)
+{
+ if (cuda_test_memcpy_async(size) < 0)
+ printk("Test failed\n");
+ else
+ printk("Test passed\n");
+}
+
+static int __init cuda_test_init(void)
+{
+ test_thread = kthread_run((void*)test_thread_func, NULL, "cuda_test");
+ return 0;
+}
+
+static void __exit cuda_test_exit(void)
+{
+}
+
+module_init(cuda_test_init);
+module_exit(cuda_test_exit);
View
1  test/cuda/kernel/memcpy_async/memcpy_async.c
Please sign in to comment.
Something went wrong with that request. Please try again.