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

memcpy taking much longer time when copying from xrt:bo to host #8435

Open
jasvinderkhurana opened this issue Sep 19, 2024 · 0 comments
Open

Comments

@jasvinderkhurana
Copy link

I am trying to copy the contents of my HLS kernel back to host, but this is taking much longer than expected. I have done the profiling and for xrt:bo to host it takes around 15ms while it takes 2.2 ms to copy memory from host to host. Below is the code snippet

    void* mem_a;
    void* mem_b;

    posix_memalign(&mem_a,4096, image_out_size_bytes);
    posix_memalign(&mem_b,4096, image_out_size_bytes);


    auto a_bo = xrt::bo(device, image_out_size_bytes, stereo_accel.group_id(0));
    auto b_bo = xrt::bo(device, image_out_size_bytes, stereo_accel.group_id(1));

    auto a_bo_map = a_bo.map();
    auto b_bo_map = b_bo.map();

    b_bo.sync(XCL_BO_SYNC_BO_FROM_DEVICE);
    memcpy(mem_a, b_bo_map, image_out_size_bytes);     // -----> Takes around 15 ms
    
    memcpy(a_bo_map, b_bo_map, image_out_size_bytes);  //----> Takes around 15 ms
    a_bo.sync(XCL_BO_SYNC_BO_TO_DEVICE);
    
    memcpy(mem_a, mem_b, image_out_size_bytes);        //-------> Takes around 2.2 ms

    clock_gettime(CLOCK_REALTIME, &end_hw);

Please let me know why is this behavior and how can I optimize it?

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