dma_ip_drivers icon indicating copy to clipboard operation
dma_ip_drivers copied to clipboard

For the XDMA driver, how to write non-contiguous memory blocks on the HOST side into an SG list (multiple table entries), and then write them to the FPGA through the XDMA driver?

Open robert987-dev opened this issue 1 year ago • 1 comments

For the XDMA driver, how to write non-contiguous memory blocks on the HOST side into an SG list (multiple table entries), and then write them to the FPGA through the XDMA driver?

For example, I allocate non-contiguous memory blocks on the host side:

// Total data size
size_t total_size = STREAM_SIZE * SEQUENCE_NUMBER * BATCH_SIZE * sizeof(float);
size_t num_blocks = total_size / BLOCK_SIZE; // Total number of blocks
printf("num_blocks: %d \n", num_blocks);

// Allocate an array to store block pointers
hostDataBlocks = (float**)malloc(num_blocks * sizeof(float*));
if (!hostDataBlocks) {
    perror("malloc");
    return -1;
}

// Allocate non-contiguous memory blocks
for (size_t i = 0; i < num_blocks; ++i) {
    cudaStatus = cudaHostAlloc((void**)&hostDataBlocks[i], BLOCK_SIZE, cudaHostAllocDefault);
    if (cudaStatus != cudaSuccess) {
        std::cerr << "cudaHostAlloc failed: " << cudaGetErrorString(cudaStatus) << std::endl;
        return -1;
    }
}

How to use the XDMA driver to write hostDataBlocks into the DMA using SG mode?

robert987-dev avatar Oct 08 '24 10:10 robert987-dev

@robert987-dev this is impossible to do with this driver. you can only transfer virtually contiguous memory. You have to either transfer block-by-block. or extend driver functionality (perhaps with additional ioctl function) if you really want to do it with a single transfer request

Prandr avatar Apr 10 '25 17:04 Prandr