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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T10:44:30+00:00 2026-06-02T10:44:30+00:00

Is there any example of using clEnqueueNativeKernel in OpenCL? In this way one can

  • 0

Is there any example of using clEnqueueNativeKernel in OpenCL? In this way one can write a kernel in a c or c++ language. Do other commands remain unchanged?

  • 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-02T10:44:31+00:00Added an answer on June 2, 2026 at 10:44 am

    Native C++ “kernels” are essentially just functions that you want to execute within command queue to preserve order of commands.

    AFAIK they are not supported on GPU. If you want to execute C++ functions across all devices, you should consider to use cl_event callbacks (when status == CL_COMPLETE).

    Assume you have a buffer object you want to read from device and pass to your C++ function. Also you want to pass some integer value as well
    (I use C++ OpenCL wrapper):

    // First of all, we should define a struct which describes our arguments list.
    struct Arguments
    {
        int integer;
        void* buffer_host;
    };
    
    // Define C/C++ function you want to call.
    void CFunction(void *args)
    {
        Arguments args = reinterpret_cast<Arguments*>(args);
        // Do something with args->integer and args->buffer_host.
    }
    
    // ...
    Arguments args = {.integer = 0, .buffer_host = NULL};
    
    // First, we should define Buffer objects in arguments.
    std::vector<cl::Memory> buffers_dev;
    buffers_dev.push_back(a_buffer);
    
    // Then we should define pointers to *pointer in args* which will be set
    // when OpenCL read data from buffers_dev to the host memory.
    std::vector<const void*> buffers_host;
    buffers_host.push_back(&args.buffer_host);
    
    // Finally, set integer
    args.integer = 10;
    
    queue.enqueueNativeKernel(CFunction,
                              std::make_pair(&args, siezof(Arguments)),
                              &buffers_dev,
                              &buffers_host);
    
    // At this point args were copied by OpenCL and you may reuse or delete it.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any way to write Shoes application using IDE (NetBeans for example)? I
Can we represent Conway's game of life using graphs? And is there any example
is there any example on using java method to call rhino-javascript function and return
Is there any example for a Real Time Chart using the DexExpress in ASP.Net?
Is there any way to remove variable i in the following example and still
Is there any example on using Lungo.JS? I'm trying to start developing a WebApp
hi for example i have to write this in my formula Sheet1!A1:HM232 is there
is there any way the .net 4 debugging api can somehow corrupt the state
is there any example of using work/pool (or. Producer/Consumer) scheme for MPI? As for
Is there any way to make a single View (in this case a TextView)

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.