forked from shinpei0208/gdev
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: added madd_host for OS space CUDA test
- Loading branch information
Shinpei Kato
committed
Mar 20, 2012
1 parent
46e0206
commit 6d083e0
Showing
4 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../common/madd_gpu.cu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../common/madd_host.c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); |