Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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? #297

Open
robert987-dev opened this issue Oct 8, 2024 · 0 comments

Comments

@robert987-dev
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant