Closed TommyUW closed 1 year ago
STARPU_CUDA_RAM
is a enum starpu_node_kind
, not a memory node number.
The pointer that you passed to starpu_vector_data_register
are pointers allocated in the main memory, so use STARPU_MAIN_RAM
which is the memory node number for the main memory.
StarPU will automatically transfer that to the GPU before executing the task
Hello: In this program, I am trying to perform vector addition with StarPU and CUDA. I tried to register data with STARPU_CUDA_RAM. However, there are segmentation fault appeared. My ubuntu is 20.04, with StarPU 1.4 and CUDA 12.2. However, this program is operable on other machines. What should I do to make STARPU_CUDA_RAM work? Do I need to switch the edition of CUDA? Thank you very much.
include
include
include
define N 16
/ CUDA Kernel / global void vector_addition(int d_u, int d_v, int d_w) { int i = blockDim.x blockIdx.x + threadIdx.x; d_w[i] = d_u[i] + d_v[i]; }
/ CPU Version of Kernel / void cpu_vector_addition(void buffers[], void cl_arg) { int u = (int )STARPU_VECTOR_GET_PTR(buffers[0]); int v = (int )STARPU_VECTOR_GET_PTR(buffers[1]); int w = (int )STARPU_VECTOR_GET_PTR(buffers[2]);
}
/ CUDA Version of Kernel / void cuda_vector_addition(void buffers[], void cl_arg) { int u = (int )STARPU_VECTOR_GET_PTR(buffers[0]); int v = (int )STARPU_VECTOR_GET_PTR(buffers[1]); int w = (int )STARPU_VECTOR_GET_PTR(buffers[2]); printf("cuda called?"); vector_addition<<<N/16, 16>>>(u, v, w); }
int main() { starpu_init(NULL);
} Makefile: CFLAGS := $(shell pkg-config --cflags starpu-1.4) LDFLAGS := $(shell pkg-config --libs starpu-1.4)
Specify the CUDA library directory and libraries
LDFLAGS += -L/usr/local/cuda-12.0/lib64 LDLIBS := -lstarpu-1.4 -lcudart
NVCC := nvcc # Assuming you have defined NVCC NVCCFLAGS := # Your NVCC flags here, if any
all: vector_addition_starpu
vector_addition_starpu: vector_addition_starpu.o $(NVCC) $(CFLAGS) $(LDFLAGS) vector_addition_starpu.o $(LDLIBS) -o vector_addition_starpu
vector_addition_starpu.o: vector_addition_starpu.cu $(NVCC) $(NVCCFLAGS) $(CFLAGS) -c vector_addition_starpu.cu -o vector_addition_starpu.o
clean: rm -f vector_addition_starpu *.o