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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:45:42+00:00 2026-05-23T20:45:42+00:00

Hello I have an algorithm similar in fashion to this (In Python): for a

  • 0

Hello I have an algorithm similar in fashion to this (In Python):

for a in xrange(10):
    for b in xrange(15):
        for c in xrange(5):
            for d in xrange(15):
                #etc

The code goes through many combinations of linear parameters. Can I and should I execute a kernel with no input data and just an id where the numerical parameters can be calculated or should I send 3 dimensions of integer data for the first 3 parameters and then calculate the rest of the parameters within each of the work items.

I am not aware of any way I can run the commands with no input data and simply have an incrementing id for all the work items so I can calculate the parameters for all combinations. Is this possible? Is it recommended?

Thank you for any help.

Note: Using C libraries for OpenCL.

  • 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-23T20:45:43+00:00Added an answer on May 23, 2026 at 8:45 pm

    It is quite hard to understand what problem you have, if you are talking about kernel arguments, you should have at least one kernel argument, kernels without kernel arguments are useless, since, OpenCL provides data-based parallelism and if you don’t have any data you don’t have any parallelism you can execute your kernel on one cpu thread…

    If you have problems with dimensions, i.e. you need 4 or more dimensions but OpenCL provides 3 than you should do something like:

    // Assuming that you have only a,b,c,d
    // and 'amount of work' = 10 * 15 * 05 * 15
    
    int index = get_global_id(0);
    int d = index % 15; index /= 15;
    int c = index % 05; index /= 05;
    int b = index % 15; index /= 15;
    int a = index % 10; index /= 10;
    
    #etc (do something with a,b,c,d)
    

    The last thing, try making your programs as flat as possible, OpenCL doesn’t like many cycles and branching logics, try to unwrap your loops by hand instead of:

    // if it is possible to render some constant into the OpenCL code,
    // than try to expand it as much as possible
    
    for (int i = 0; i < 4; i++) // The constant is 4
    {
       float x = sin(3.14 * i + ...);
       float y = cos(x + ....);
       x[i] = a * i * x + y ....;
    }
    

    write it the following way:

    float x;
    float y;
    
    x = sin(3.14 * 0 + ...);
    y = cos(x + ....);
    x[0] = a * 0 * x + y ....;
    
    
    x = sin(3.14 * 1 + ...);
    y = cos(x + ....);
    x[1] = a * 1 * x + y ....;
    
    
    x = sin(3.14 * 2 + ...);
    y = cos(x + ....);
    x[2] = a * 2 * x + y ....;
    
    
    x = sin(3.14 * 3 + ...);
    y = cos(x + ....);
    x[3] = a * 3 * x + y ....;
    

    The flatter the better! I’m talking about reasonable expansion, if you have a 1024 cycles in the loop expanding all of them is not reasonable. In this case you should expand it by the order of 2 or 4 or 8 or 16 cycles, this will lead you to having 512 or 256 or 128 or 64 loop cycles, this can get you huge performance boost…

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

Sidebar

Related Questions

Hello i have this form filling javascript: function onLine(code,nn) { document.writeform.bericht.value+=code; document.writeform.bericht.focus(); document.writeform.nickname.value+=nn; write1();
Hello i have this code var queue = new BlockingCollection<int>(); queue.Add(0); var producers =
Hello I have the following code namespace ConsoleApplication2 { class Program { static void
Hello I have been having trouble with this for a while now. I have
Hello I have this list that i am working on. When i move the
Hello I have this problem with PyQt4-dev-tools that include: * a user interface compiler
If I have the following text: Hello this is a piece of text that
Hello I have this html video tag: <video id=asdasd width=320 height=240 controls preload> <source
I have a simple C++ with Boost like this: #include <boost/algorithm/string.hpp> int main() {
Hello i have this in a batch: :passw022 title batch :: Password if exist

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.