Research Article

Optimized Data Transfers Based on the OpenCL Event Management Mechanism

Listing 1

A simple pseudocode combining OpenCL and MPI.
()  cl_command_queue cmd;
()  cl_kernel kern;
()  cl_event evt;
()
()  for(int i(0);i<N;++i){
()   // (1) computation on a device
()   clEnqueueNDRangeKernel(cmd,kern,,0,NULL,&evt);
()
()   // (2) read the result from device to host
() clEnqueueReadBuffer(cmd,,1,&evt,NULL);
() clFinish(cmd);  // the host thread is blocked
()
() // (3) exchange data with other nodes
() MPI_Sendrecv();  // blocking function call
()
() // (4) write the received data to device memory
() clEnqueueWriteBuffer(cmd,);
() }