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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:17:09+00:00 2026-06-14T06:17:09+00:00

OpenCL 1.1 specification says: cl_int clEnqueueBarrier(cl_command_queue command_queue) clEnqueueBarrier is a synchronization point that ensures

  • 0

OpenCL 1.1 specification says:

cl_int clEnqueueBarrier(cl_command_queue command_queue)

clEnqueueBarrier is a synchronization point that ensures that all queued commands in command_queue have finished execution before the next batch of commands can begin execution.

cl_int clFinish(cl_command_queue command_queue)

Blocks until all previously queued OpenCL commands in command_queue are issued to the associated device and have completed. clFinish does not return until all queued commands in command_queue have been processed and completed. clFinish is also a synchronization point.

Should have to do something with the in-order or out-of-order execution, but I can’t see the difference. Are they ever needed if I have in-order execution? At the moment I do something like:

...
for(...){
    clEnqueuNDRangeKernel(...);
    clFlush(command_queue);
    clFinish(command_queue);
}
...

on an Nvidia GPU. Any relevant comment is appreciated.

  • 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-14T06:17:10+00:00Added an answer on June 14, 2026 at 6:17 am

    You need to enqueue a barrier if you are writing an out-of-order queue as one method of ensure dependency. You could also use the cl_event objects to ensure correct ordering of commands on the command queue.

    If you are writing your code such that you call a clFinish after every kernel invocation, then using clEnqueueBarrier will not have any impact on your code, since you are already ensuring ordering.

    The point of using the clEnqueueBarrier would be a case such as:

    clEnqueueNDRangeKernel(queue, kernel1);
    clEnqueueBarrier(queue);
    clEnqueueNDRangeKernel(queue, kernel2);
    

    In this case, kernel2 depends on the results of kernel1. If this queue is out-of-order, then without the barrier kernel2 could execute before kernel1, causing incorrect behavior. You could achieve the same ordering with:

    clEnqueueNDRangeKernel(queue, kernel1);
    clFinish(queue);
    clEnqueueNDRangeKernel(queue, kernel2);
    

    because clFinish will wait until the queue is empty (all kernels/data transfers have finished). However, clFinish will wait until kernel1 finishes, in this case, while clEnqueueBarrier should immediately return control back to the application (allowing you to enqueue more kernels or perform other useful work.

    As a side note, I think that clFinish will implicitly call clFlush so you should not need to call it every time.

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

Sidebar

Related Questions

I know that OpenCL doesn't have support for complex numbers, and by what I've
I have been reading through the specification of openGL 1.5, and saw that any
I have some OpenCL kernels that aren't doing what they should be, and I
I am using openCL to play sounds and I have noted that the sounds
I built the opencl program using the commands: gcc -c -I ~/AMDAPP/include main.c -o
I am new to OpenCL. I have written a vector addition code in OpenCL
Is it possible to use OpenCL for PowerVR SGX530 GPU device? I have to
Hello so I have ran several openCL kernels in double precision on GPU with
As we all get to know eventually, the specification is one thing and the
In OpenCL, what is the point of the built-in functions isequal, isnotequal, isgreater, etc.?

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.