title: Repeated calling of enqueueNDRangeKernel in OpenCL
body: <p>What other OpenCL functions should be called when enqueueNDRangeKernel is called repeatedly?</p>
  
  <p>I have not been able to find a tutorial that shows the use of enqueueNDRangeKernel in this fashion and my coding attempts have unfortunately resulted in an unhandled exception error. A similar question has been asked before but the responses don't seem to apply to my situation.</p>
  
  <p>I currently have a loop in which I call the OpenCL functions in the following sequence: </p>
  
  <ol>
  <li>setArg</li>
  <li>enqueueNDRangeKernel</li>
  <li>enqueueMapBuffer</li>
  <li>enqueueUnmapMemObject</li>
  </ol>
  
  <p>I am calling setArg because the input to the kernel changes before each call to enqueueNDRangeKernel. I am calling enqueueMapBuffer and enqueueUnmapMemObject since the output from the kernel is used in the host code. The kernel runs ok the first time (the output is correct) but during the second pass through the loop I get an unhandled exception error when calling enqueueMapBuffer.</p>
  
  <p>I am using the following set-up:</p>
  
  <ol>
  <li>Intel OpenCL SDK with CL_DEVICE_TYPE_CPU (on an Intel i7 CPU)</li>
  <li>Visual Studio 2010 IDE on Windows 7</li>
  <li>Host Code is written in C++ with the OpenCL C++ bindings.</li>
  </ol>
  
  <p>Thanks.</p>