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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:10:10+00:00 2026-06-13T13:10:10+00:00

I’m having trouble passing a vector type (uint8) parameter to an OpenCL kernel function

  • 0

I’m having trouble passing a vector type (uint8) parameter to an OpenCL kernel function from the host code in C.

In the host I’ve got the data in an array:

cl_uint dataArr[8] = { 1, 2, 3, 4, 5, 6, 7, 8 };

(My real data is more than just [1, 8]; this is just for ease of explanation.)

I then transfer the data over to a buffer to be passed to the kernel:

cl_mem kernelInputData = clCreateBuffer(context,
    CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR, sizeof(cl_uint)*8, dataArr, NULL);

Next, I pass this buffer into the kernel:

clSetKernelArg(kernel, 0, sizeof(cl_mem), &kernelInputData);

And the kernel function’s signature looks something like this:

kernel void kernelFunction(constant uint8 *vectorPtr)

However, the kernel doesn’t seem to be obtaining the correct input data from the pointer to kernelInputData. When I pass values back from within the kernel, I see that vectorPtr points to something with this structure: ( 1, 2, 3, 4, 5, ?, ?, ? ) where the question marks are usually 4293848814 but sometimes 0. Either way, not what they’re supposed to be.

What am I doing wrong?


EDIT:

I’ve switched from using an array to cl_uint8 on the host side. I now have:

cl_uint8 dataVector = { 1, 2, 3, 4, 5, 6, 7, 8 };

And I pass this vector to the kernel like so:

clSetKernelArg(kernel, 0, sizeof(cl_uint8), &dataVector);

And the kernel function’s signature looks something like this:

kernel void kernelFunction(constant uint8 *vectorPtr)

However, running this code gives me a CL_INVALID_ARG_SIZE error on clSetKernelArg(). This error goes away if I switch the ARG_SIZE paramater to sizeof(cl_uint8 *) but then I get an EXC_BAD_ACCESS error in __dynamic_cast within clSetKernelArg().

My device is:

Apple Macbook Pro (mid-2009)
OSX 10.8 Mountain Lion
NVIDIA GeForce 9400M
OpenCL 1.0
CLH 1.0

  • 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-13T13:10:12+00:00Added an answer on June 13, 2026 at 1:10 pm

    You are defining an array of cl_uint of size 8.
    The creation of the cl_mem and the setting of kernel argument are right.
    But your kernel argument isn’t correct: you try to read an array of cl_uint8 instead of cl_uint.

    If you want to use a vector data type, you must declare: cl_uint8 dataArr of size 1.
    Or if you want to use an array of size 8: kernel void kernelFunction(constant uint *vectorPtr, uint size):

    Edit:

    The kernel parameter for cl_uint8 dataVector is not a pointer.
    So, the correct code is:

    cl_uint8 dataVector = { 1, 2, 3, 4, 5, 6, 7, 8 };
    clSetKernelArg(kernel, 0, sizeof(cl_uint8), &dataVector);
    

    and

    kernel void kernelFunction(constant uint8 vectorPtr)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I have a view passing on information from a database: def serve_article(request, id): served_article
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

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.