Permalink
Browse files

test: added madd_host for OS space CUDA test

  • Loading branch information...
1 parent 93553f2 commit b93b022299eb616795b5fa7acd2bec59e34135fd Shinpei Kato committed Mar 20, 2012
@@ -0,0 +1,23 @@
+TARGET = kernel_test
+$(TARGET)-y := main.o madd_host.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
+NVCC = nvcc -arch sm_20 -cubin
+
+obj-m := $(TARGET).o
+
+EXTRA_CFLAGS = -I $(GDEVINC)
+KBUILD_EXTRA_SYMBOLS = $(GDEVETC)/Module.symvers.kcuda
+
+all:
+ @echo '#define DIRPATH "$(PWD)"' > dirpath.h
+ $(NVCC) -o madd_gpu.cubin madd_gpu.cu
+ +make -C $(KERNELDIR) M=$(PWD) modules
+
+clean:
+ +make -C $(KERNELDIR) M=$(PWD) clean
+ rm -f *~ *.cubin dirpath.h
@@ -0,0 +1,36 @@
+#include <asm/uaccess.h>
+#include <linux/kthread.h>
+#include <linux/module.h>
+#include "dirpath.h"
+
+MODULE_LICENSE("Dual BSD/GPL");
+MODULE_DESCRIPTION("CUDA Test");
+MODULE_AUTHOR("Shinpei Kato");
+
+int cuda_test_madd_host(unsigned int n, char *path);
+
+struct task_struct *test_thread = NULL;
+static int n = 256;
+module_param(n, int, 0444);
+MODULE_PARM_DESC(size, "matrix size");
+
+static void test_thread_func(void *__data)
+{
+ if (cuda_test_madd_host(n, DIRPATH) < 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);

0 comments on commit b93b022

Please sign in to comment.