Esempio n. 1
0
int acc_stream_wait_event (void* stream, void* event){
  // debug info
  if (verbose_print){
    fprintf(stdout, "\n ... STREAM waiting for EVENT ... \n");
    fprintf(stdout, " ---> Entering: acc_stream_wait_event.\n");
  }

  // local event and queue pointers
  cl_event *clevent = (cl_event *) event;
  acc_opencl_stream_type *clstream = (acc_opencl_stream_type *) stream;

  // wait for an event on a stream
  cl_error = clEnqueueWaitForEvents((*clstream).queue,
               (cl_uint) 1, clevent);
  if (acc_opencl_error_check(cl_error, __LINE__))
    return -1;

  // debug info
  if (verbose_print){
    fprintf(stdout, " ---> Leaving: acc_stream_wait_event.\n");
  }

  // assign return value
  return 0;
}
Esempio n. 2
0
cl_int WINAPI wine_clEnqueueWaitForEvents(cl_command_queue command_queue, cl_uint num_events, cl_event * event_list)
{
    cl_int ret;
    TRACE("\n");
    ret = clEnqueueWaitForEvents(command_queue, num_events, event_list);
    return ret;
}
Esempio n. 3
0
/*!
    \overload

    Adds a barrier to the active command queue that will prevent future
    commands from being executed until after all members of \a events
    have been signalled.

    \sa marker()
*/
void QCLContext::barrier(const QCLEventList &events)
{
    if (events.isEmpty())
        return;
    cl_int error = clEnqueueWaitForEvents
        (activeQueue(), events.size(), events.eventData());
    reportError("QCLContext::barrier(QCLEventList):", error);
}
Esempio n. 4
0
void
Wait( cl_command_queue queue )
{
	cl_event wait;

	cl_int status = clEnqueueMarker( queue, &wait );
	if( status != CL_SUCCESS )
		fprintf( stderr, "Wait: clEnqueueMarker failed\n" );

	status = clEnqueueWaitForEvents( queue, 1, &wait );
	if( status != CL_SUCCESS )
		fprintf( stderr, "Wait: clEnqueueWaitForEvents failed\n" );
}
Esempio n. 5
0
QVector<float> SpectrumAnalyzerRangeData::runFFT(cl_mem samplesHistory, cl_int historyOffset, cl_int historyLength)
{
	cl_event presum_evt, algo_evt;

	CL_CHECK_ERR("clSetKernelArg", clSetKernelArg(circsum, 0, sizeof(cl_mem), &samples));
	CL_CHECK_ERR("clSetKernelArg", clSetKernelArg(circsum, 1, sizeof(cl_mem), &samplesHistory));
	CL_CHECK_ERR("clSetKernelArg", clSetKernelArg(circsum, 2, sizeof(cl_int), &historyOffset));
	CL_CHECK_ERR("clSetKernelArg", clSetKernelArg(circsum, 3, sizeof(cl_int), &historyLength));
	CL_CHECK_ERR("clSetKernelArg", clSetKernelArg(circsum, 4, sizeof(cl_int), &presumWindows));
	CL_CHECK_ERR("clEnqueueNDRangeKernel", clEnqueueNDRangeKernel(command_queue,
		circsum,
		1,
		NULL,
		&windowSize,
		&presumGroupSize,
		0,
		NULL,
		&presum_evt
	));

	clEnqueueWaitForEvents(command_queue, 1, &presum_evt);

	cl_mem output = algorithm.run(samples, &algo_evt);

	QVector<float> risultato(windowSize);

	cl_int err;
	cl_float2 *output_buffer = (cl_float2*)clEnqueueMapBuffer(command_queue,
		output,
		CL_TRUE,
		CL_MAP_READ,
		0,
		windowSize * sizeof(cl_float2),
		1,
		&algo_evt,
		NULL,
		&err);
	CL_CHECK_ERR("clEnqueueMapBuffer", err);

	for (int i = 0; i < windowSize; i++)
		risultato[i] = abs(cpx(output_buffer[i].x, output_buffer[i].y));

	CL_CHECK_ERR("clEnqueueUnmapMemObject", clEnqueueUnmapMemObject(command_queue, output, output_buffer, 0, NULL, NULL));

	CL_CHECK_ERR("clReleaseEvent", clReleaseEvent(presum_evt));
	CL_CHECK_ERR("clReleaseEvent", clReleaseEvent(algo_evt));

	return risultato;
}
Esempio n. 6
0
/*! \brief Enqueues a wait for event completion.
 *
 * Then it releases the event and sets it to 0.
 * Don't use this function when more than one wait will be issued for the event.
 * Equivalent to Cuda Stream Sync. */
void sync_ocl_event(cl_command_queue stream, cl_event *ocl_event)
{
    cl_int gmx_unused cl_error;

    /* Enqueue wait */
#ifdef CL_VERSION_1_2
    cl_error = clEnqueueBarrierWithWaitList(stream, 1, ocl_event, NULL);
#else
    cl_error = clEnqueueWaitForEvents(stream, 1, ocl_event);
#endif

    assert(CL_SUCCESS == cl_error);

    /* Release event and reset it to 0. It is ok to release it as enqueuewaitforevents performs implicit retain for events. */
    cl_error = clReleaseEvent(*ocl_event);
    assert(CL_SUCCESS == cl_error);
    *ocl_event = 0;
}
Esempio n. 7
0
END_TEST

START_TEST (test_misc_events)
{
    cl_platform_id platform = 0;
    cl_device_id device;
    cl_context ctx;
    cl_command_queue queue;
    cl_int result;
    cl_event uevent1, uevent2, marker1, marker2;

    result = clGetDeviceIDs(platform, CL_DEVICE_TYPE_DEFAULT, 1, &device, 0);
    fail_if(
        result != CL_SUCCESS,
        "unable to get the default device"
    );

    ctx = clCreateContext(0, 1, &device, 0, 0, &result);
    fail_if(
        result != CL_SUCCESS || ctx == 0,
        "unable to create a valid context"
    );

    queue = clCreateCommandQueue(ctx, device, 0, &result);
    fail_if(
        result != CL_SUCCESS || queue == 0,
        "cannot create a command queue"
    );

    /*
     * This test will build a command queue blocked by an user event. The events
     * will be in this order :
     *
     * -: UserEvent1
     * 0: WaitForEvents1 (wait=UserEvent1)
     * 1: Marker1
     * -: UserEvent2
     * 2: WaitForEvents2 (wait=UserEvent2)
     * 3: Barrier
     * 4: Marker2 (to check the barrier worked)
     *
     * When the command queue is built, we :
     *  - Check that Marker1 is Queued (WaitForEvents waits)
     *  - Set UserEvent1 to Complete
     *  - Check that Marker1 is Complete (WaitForEvents stopped to wait)
     *  - Check that Marker2 is Queued (Barrier is there)
     *  - Set UserEvent2 to Complete
     *  - Check that Marker2 is Complete (no more barrier)
     */
    uevent1 = clCreateUserEvent(ctx, &result);
    fail_if(
        result != CL_SUCCESS,
        "unable to create UserEvent1"
    );

    uevent2 = clCreateUserEvent(ctx, &result);
    fail_if(
        result != CL_SUCCESS,
        "unable to create UserEvent2"
    );

    result = clEnqueueWaitForEvents(queue, 1, &uevent1);
    fail_if(
        result != CL_SUCCESS,
        "unable to enqueue WaitForEvents(UserEvent1)"
    );

    result = clEnqueueMarker(queue, &marker1);
    fail_if(
        result != CL_SUCCESS,
        "unable to enqueue Marker1"
    );

    result = clEnqueueWaitForEvents(queue, 1, &uevent2);
    fail_if(
        result != CL_SUCCESS,
        "unable to enqueue WaitForEvents(UserEvent2)"
    );

    result = clEnqueueBarrier(queue);
    fail_if(
        result != CL_SUCCESS,
        "unable to enqueue Barrier"
    );

    result = clEnqueueMarker(queue, &marker2);
    fail_if(
        result != CL_SUCCESS,
        "unable to enqueue Marker2"
    );

    // Now the checks
    cl_int status;

    result = clGetEventInfo(marker1, CL_EVENT_COMMAND_EXECUTION_STATUS,
                            sizeof(cl_int), &status, 0);
    fail_if(
        result != CL_SUCCESS || status != CL_QUEUED,
        "Marker1 must be Queued"
    );

    result = clSetUserEventStatus(uevent1, CL_COMPLETE);
    fail_if(
        result != CL_SUCCESS,
        "unable to set UserEvent1 to Complete"
    );

    result = clGetEventInfo(marker1, CL_EVENT_COMMAND_EXECUTION_STATUS,
                            sizeof(cl_int), &status, 0);
    fail_if(
        result != CL_SUCCESS || status != CL_COMPLETE,
        "Marker1 must be Complete"
    );

    result = clGetEventInfo(marker2, CL_EVENT_COMMAND_EXECUTION_STATUS,
                            sizeof(cl_int), &status, 0);
    fail_if(
        result != CL_SUCCESS || status != CL_QUEUED,
        "Marker2 must be Queued"
    );

    result = clSetUserEventStatus(uevent2, CL_COMPLETE);
    fail_if(
        result != CL_SUCCESS,
        "unable to set UserEvent2 to Complete"
    );

    result = clGetEventInfo(marker2, CL_EVENT_COMMAND_EXECUTION_STATUS,
                            sizeof(cl_int), &status, 0);
    fail_if(
        result != CL_SUCCESS || status != CL_COMPLETE,
        "Marker2 must be Complete"
    );

    clFinish(queue);

    clReleaseEvent(uevent1);
    clReleaseEvent(uevent2);
    clReleaseEvent(marker1);
    clReleaseEvent(marker2);
    clReleaseCommandQueue(queue);
    clReleaseContext(ctx);
}