Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8520889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T06:39:28+00:00 2026-06-11T06:39:28+00:00

I am a beginner with OpenCL and I have difficulties to understand something. I

  • 0

I am a beginner with OpenCL and I have difficulties to understand something.
I want to improve the transfers of an image between host and device.
I made a scheme to better understand me.

Top: what I have now | Bottom: what I want
HtD (Host to Device) and DtH ( Device to Host) are memory transfers.
K1 and K2 are kernels.

I thought about using mapping memory, but the first transfer (Host to Device) is done with the clSetKernelArg() command, no ?
Or do I have to cut my input image into sub-image and use mapping to get the output image ?

Thanks.

Edit: More information

K1 process mem input image.
K2 process output image from K1.

So, I want to transfer MemInput into several pieces for K1.
And I want to read and save on the host the MemOuput processed by K2.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T06:39:31+00:00Added an answer on June 11, 2026 at 6:39 am

    As you may have already seen, you do a transfer from host to device by using clEnqueueWriteBuffer and similar.

    All the commands having the keyword ‘enqueue’ in them have a special property: The commands are not executed directly, but when you tigger them using clFinish, clFlush, clEnqueueWaitForEvents, using clEnqueueWriteBuffer in blocking mode and some more.

    This means that all action happens at once and you have to synchronise it using the event objects. As everything (may) happen at once, you could do something like this (Each point happens at the same time):

    1. Transfer Data A
    2. Process Data A & Transfer Data B
    3. Process Data B & Transfer Data C & Retrive Data A’
    4. Process Data C & Retrieve Data B’
    5. Retrieve Data C’

    Remember: Enqueueing Tasks without Event-Objects may result in a simultaneous execution of all enqueued elements!

    To make sure that Process Data B doesn’t happen before Transfer B, you have to retrieve an event object from clEnqueueWriteBuffer and supply it as an object to wait for to f.i. clEnqueueNDRangeKernel

    cl_event evt;
    clEnqueueWriteBuffer(... , bufferB , ... , ... , ... , bufferBdata , NULL , NULL , &evt);
    clEnqueueNDRangeKernel(... , kernelB , ... , ... , ... , ... , 1 , &evt, NULL);
    

    Instead of supplying NULL, each command can of course wait on certain objects AND generate a new event object. The parameter next to last is an array, so you can event wait for several events!


    EDIT: To summarise the comments below
    Transferring data – What command acts where?

           CPU                        GPU
                                BufA       BufB
    array[] = {...}
    clCreateBuffer()  ----->  [     ]              //Create (empty) Buffer in GPU memory *
    clCreateBuffer()  ----->  [     ]    [     ]   //Create (empty) Buffer in GPU memory *
    clWriteBuffer()   -arr->  [array]    [     ]   //Copy from CPU to GPU
    clCopyBuffer()            [array] -> [array]   //Copy from GPU to GPU
    clReadBuffer()    <-arr-  [array]    [array]   //Copy from GPU to CPU
    

    * You may initialise the buffer directly by providing data using the host_ptr parameter.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Beginner in Android development. My code crashes. I have made a simple Java method
Python beginner here, I have a list of lists and want to refer to
I am a beginner. I want to use pyopengl in linux but I have
I'm a total beginner with OpenCL and I'm trying to make the following kernel
Beginner iOS dev here. I have a problem in my array. Im making an
Beginner level question Scenario: Have simple string cocantation tool, that I might expand later
Beginner question: I have a dictionary where the values are lists of (a variable
I'm a beginner in game development and game programming. I have experience in computer
Beginner programmer here....hope it makes sense :) I have created a console app that
Beginner here, I have a simple question. In Android what would be the best

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.