Skip to content
Snippets Groups Projects
rtdefs.cu 708 B
extern "C" {
	void *__cuda_alloc(size_t size) {
		void *ptr = NULL;
		cudaError_t res = cudaMalloc(&ptr, size);
		if (res != cudaSuccess) {
			ptr = NULL;
		}
		return ptr;
	}
	
	void __cuda_dealloc(void *ptr, size_t size) {
		(void) size;
		cudaFree(ptr);
	}

	void __cuda_zero_mem(void *ptr, size_t size) {
		cudaMemset(ptr, 0, size);
	}
	
	void __copy_cpu_to_cuda(void *dst, void *src, size_t size) {
		cudaMemcpy(dst, src, size, cudaMemcpyHostToDevice);
	}
	
	void __copy_cuda_to_cpu(void *dst, void *src, size_t size) {
		cudaMemcpy(dst, src, size, cudaMemcpyDeviceToHost);
	}
	
	void __copy_cuda_to_cuda(void *dst, void *src, size_t size) {
		cudaMemcpy(dst, src, size, cudaMemcpyDeviceToDevice);
	}
}