I want to transfer data directly from AMD GPU to DDR memory on FPGA board.
I am trying to create a buffer object by mapping the FPGA's DDR memory with mmap using Linux UIO and setting the CL_MEM_USE_HOST_PTR flag in clcreatebuffer for the buffer I get, but CL_MEM_OBJECT_ ALLOCATION_FAILURE is returned.
I have confirmed that I can read/write to the memory of the FPGA board by the address obtained by mmap. (I also confirmed that the read/write result from the FPGA serial port is correct.)
So I think that mmap is working correctly.
How can I solve this problem?
Here is a part of source code.
fd = open("/dev/uio0", O_RDWR);
if (fd < 0) {
exit(1);
}
buff = mmap(NULL, mem_alloc_size, (PROT_READ|PROT_WRITE), (MAP_SHARED|MAP_LOCKED), fd, 0);
if (buff == MAP_FAILED) {
exit(1);
}
mem_obj_host = clCreateBuffer(context, (CL_MEM_WRITE_ONLY|CL_MEM_USE_HOST_PTR), mem_alloc_size, buff, &ret);
if(ret != CL_SUCCESS) {
printf("ret:%d \n", ret); // return -4 (CL_MEM_OBJECT_ ALLOCATION_FAILURE)
exit(1);
}