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 7164883
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:08:57+00:00 2026-05-28T14:08:57+00:00

Given a float[n] inputdata to pass to the OpenCL kernel, could anyone enlighten me

  • 0

Given a float[n] inputdata to pass to the OpenCL kernel, could anyone enlighten me on the difference between the following three ways to pass this to the kernel:

A)

cl_mem input = clCreateBuffer(context, CL_MEM_USE_HOST_PTR Sizeof.cl_float * n,
        inputdata, NULL);
clSetKernelArg(kernel, i, Sizeof.cl_mem, Pointer.to(input));

B)

clSetKernelArg(kernel, i, Sizeof.cl_float * n, Pointer.to(inputdata));

C)

cl_mem input = clCreateBuffer(context, CL_MEM_options_here, Sizeof.cl_float * n,
        NULL, NULL);
clEnqueueWriteBuffer(command_queue, input, CL_TRUE, 0, Sizeof.cl_float * n, 
        inputdata, 0, NULL, NULL);
clSetKernelArg(kernel, i, Sizeof.cl_mem, Pointer.to(input));

?

Have I understood correct that the difference between A) and C) is that C) copies the entire array once at the start and then works on-GPU with it, while A) has to load its data on-the-fly? So A) is good if one needs only a small portion of an array, and C) is the way to go if you use the entire array anyway?

And what about B)? Is it more like A), more like C), or still something different?

  • 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-05-28T14:08:57+00:00Added an answer on May 28, 2026 at 2:08 pm

    Yes, you cannot pass huge amounts of parameters. There is an upper limit on the size of all parameters (typically in the 50 KiB range — you can query it with clGetDeviceInfo and CL_DEVICE_MAX_PARAMETER_SIZE). With Method a and c you can pass much larger buffers (hundreds of megabytes.) a is not helpful for OpenCL 1.1 and lower, as the buffer will be still copied usually, but with OpenCL 1.2, you can avoid one copy if your host and device is the same (i.e. you are running a CPU OpenCL runtime for instance.)

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

Sidebar

Related Questions

Given the following piece of (pseudo-C++) code: float x=100, a=0.1; unsigned int height =
Given the following code, I would expect it to return float = 32000.0001. But
Given the following html: <body> <div style=float: left; background: red>Hi</div> <div style=float: left; background:
Given NSString *test = @2.98, how do I convert this value into float so
Given this code: .yourHeaderContainer {background-color:#EEEEEE; line-height:34px; height:34px;} .yourHeaderContainer .challengeSomeone {float:right; margin-right:10px; font-size:12px; font-weight:bold; padding:0px
Given a float between 0 and 1, how to print it as a percentage?
Given the following html: <div> <div id=A1></div> <div> <div id=B1 style=float:left;></div> <div id=B2 style=float:left;></div>
I want to do an operation like this : if the given float numbers
Given this PHP code: // total is 71.24 (float) $value = $total * 100;
Given the following code : public void insertIntoQueue(float length,int xElement,int yElement,int whichElement) { Dot

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.