Skip to content

Commit

Permalink
test: added madd_host for OS space CUDA test
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinpei Kato committed Mar 20, 2012
1 parent 46e0206 commit 6d083e0
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test/cuda/kernel/madd_host/Makefile
@@ -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
1 change: 1 addition & 0 deletions test/cuda/kernel/madd_host/madd_gpu.cu
1 change: 1 addition & 0 deletions test/cuda/kernel/madd_host/madd_host.c
36 changes: 36 additions & 0 deletions test/cuda/kernel/madd_host/main.c
@@ -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 6d083e0

Please sign in to comment.