Page 2 of 2 FirstFirst 12
Results 11 to 15 of 15

Thread: Is this undefined behavior?

  1. #11
    Junior Member
    Join Date
    Sep 2012
    Posts
    17
    Also I've been using this function to sync for many queues without problem:

    Code :
    	__declspec(dllexport)
    		void waitN(OpenClCommandQueue ** hCommandQueueArray, OpenClCommandQueue * hCommandQueueToSync, const int n)
    	{
    		std::vector<cl::Event> evtVect;
    		for (int i = 0; i < n; i++)
    		{
    			evtVect.push_back(cl::Event());
    			hCommandQueueArray[i]->commandQueue.enqueueMarkerWithWaitList(NULL, &evtVect[i]);
    			hCommandQueueArray[i]->commandQueue.flush();
    		}
    		hCommandQueueToSync->commandQueue.enqueueMarkerWithWaitList(&evtVect, NULL);
    		hCommandQueueToSync->commandQueue.finish();
    	}

    does the last marker with wait list make memory consistency for all queues after the single finish() command? (so that next batch of kernels can see true buffer values and host can read the latest bits?)

    Should I convert these to an enqueue barrier with wait list version? There are not any commands enqueued after markers so they are last but is it enough with just waiting for markers?

    It is not very explicitly documented that which one is enough to satisfy queue level, multiple queue level, multiple device level(if same context ofcourse) memory consistency. I'm sure kernels finish before these but what about buffer states? When do the latest bits get ready if its a single queue, if its a multiple queue or a multiple device context?
    Last edited by Tugrul; 06-13-2017 at 10:13 AM.

  2. #12
    Senior Member
    Join Date
    Apr 2015
    Posts
    275
    EnqueueMarker is deprecated, I believe.
    after the single finish() command?
    Finish itself if a synchronization point.

    Basically, if some command involves waiting on events, it is automatically a synchronization point for every device in the context. At queue level with an in-order queue you don't need to worry at all: every subsequent command sees the results of a previous command with the excection of non-blocking mapping and reading/writing.

  3. #13
    Junior Member
    Join Date
    Sep 2012
    Posts
    17
    Then a synchronization point synchronizes for all queues and for everything? (I mean, that "moment" of state of all buffers, and all kernels,)

    If I dont use events, other queues may have still not complete and their buffer usage may be garbage but still the moment of "finish" they still synched, am I right?
    Last edited by Tugrul; 06-13-2017 at 11:23 AM.

  4. #14
    Senior Member
    Join Date
    Apr 2015
    Posts
    275
    No, you can only count on memory objects associated with those synch points (i.e. buffers used by a kernel launched) to be in valid state after a wait. For every queue and device in the context, though. If you don't use events, you have to use clFinish at some point which will ensure that every memory object touched by any command on that queue is synched.

    Example:
    Code :
    RunKernel(buffer_a)
    RunKernel(buffer_b, event_t)
    clWaitForEvents(event_t)
    //At this point buffer_b is in valid state, but it might turn out that the first kernel is still running

  5. #15
    Junior Member
    Join Date
    Sep 2012
    Posts
    17
    Quote Originally Posted by Salabar View Post
    No, you can only count on memory objects associated with those synch points (i.e. buffers used by a kernel launched) to be in valid state after a wait. For every queue and device in the context, though. If you don't use events, you have to use clFinish at some point which will ensure that every memory object touched by any command on that queue is synched.

    Example:
    Code :
    RunKernel(buffer_a)
    RunKernel(buffer_b, event_t)
    clWaitForEvents(event_t)
    //At this point buffer_b is in valid state, but it might turn out that the first kernel is still running
    Thank you very much. I use in-order type for all queues so its ok to sync on single queue, provided that before that sync point, events ensure other queues are done computing, if I understand correctly.

Page 2 of 2 FirstFirst 12

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean