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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T01:18:36+00:00 2026-06-06T01:18:36+00:00

In my OpenCL program, I am going to end up with 60+ global memory

  • 0

In my OpenCL program, I am going to end up with 60+ global memory buffers that each kernel is going to need to be able to access. What’s the recommended way to for letting each kernel know the location of each of these buffers?

The buffers themselves are stable throughout the life of the application — that is, we will allocate the buffers at application start, call multiple kernels, then only deallocate the buffers at application end. Their contents, however, may change as the kernels read/write from them.

In CUDA, the way I did this was to create 60+ program scope global variables in my CUDA code. I would then, on the host, write the address of the device buffers I allocated into these global variables. Then kernels would simply use these global variables to find the buffer it needed to work with.

What would be the best way to do this in OpenCL? It seems that CL’s global variables are a bit different than CUDA’s, but I can’t find a clear answer on if my CUDA method will work, and if so, how to go about transferring the buffer pointers into global variables. If that wont work, what’s the best way otherwise?

  • 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-06T01:18:37+00:00Added an answer on June 6, 2026 at 1:18 am

    60 global variables sure is a lot! Are you sure there isn’t a way to refactor your algorithm a bit to use smaller data chunks? Remember, each kernel should be a minimum work unit, not something colossal!

    However, there is one possible solution. Assuming your 60 arrays are of known size, you could store them all into one big buffer, and then use offsets to access various parts of that large array. Here’s a very simple example with three arrays:

    A is 100 elements
    B is 200 elements
    C is 100 elements
    
    big_array = A[0:100] B[0:200] C[0:100]
    offsets = [0, 100, 300]
    

    Then, you only need to pass big_array and offsets to your kernel, and you can access each array. For example:

    A[50] = big_array[offsets[0] + 50]
    B[20] = big_array[offsets[1] + 20]
    C[0] = big_array[offsets[2] + 0]
    

    I’m not sure how this would affect caching on your particular device, but my initial guess is “not well.” This kind of array access is a little nasty, as well. I’m not sure if it would be valid, but you could start each of your kernels with some code that extracts each offset and adds it to a copy of the original pointer.

    On the host side, in order to keep your arrays more accessible, you can use clCreateSubBuffer: http://www.khronos.org/registry/cl/sdk/1.2/docs/man/xhtml/clCreateSubBuffer.html which would also allow you to pass references to specific arrays without the offsets array.

    I don’t think this solution will be any better than passing the 60 kernel arguments, but depending on your OpenCL implementation’s clSetKernelArgs, it might be faster. It will certainly reduce the length of your argument list.

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

Sidebar

Related Questions

So I have a rather large openGL program going, and checking for normal memory
I am trying to setup a program that uses Java and OpenCL. I am
I try to implement memory mapped technics in my OpenCL program, but it's doesn't
i'm programming a simple OpenGL program on a multi-core computer that has a GPU.
I have written a simple OpenGL program in C++ that displays a line joining
I am trying to add some shaders to my old OpenGL program that draws
I wrote a simply OpenCL program based off the SDK and it compiles and
I am writing a OpenCL program in which multiple kernels are being called on
I hear that GL_QUADS are going to be removed in the OpenGL versions >
About atomic access of __local variables: I know it's slow to do global operations

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.