Changes between Initial Version and Version 1 of CudaApps


Ignore:
Timestamp:
Dec 18, 2008, 4:57:04 PM (16 years ago)
Author:
davea
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • CudaApps

    v1 v1  
     1= CUDA applications =
     2
     3== CUDA initialization ==
     4
     5Below is a function that you can use at CUDA initialization in your
     6application that will use the CUDA Driver API to setup a blocking sync
     7context. Call this function just before you call cudaSetDevice() in your
     8initialization and the thread yielding is automatically provided when you
     9launch device kernels from your host code.  There is no need to poll or use
     10sleep-loop.  Sleeping is done in the driver and your thread will resume very
     11quickly when the GPU completes the scheduled task.
     12{{{
     13bool SetCUDABlockingSync(int device) {
     14    CUdevice  hcuDevice;
     15    CUcontext hcuContext;
     16
     17    CUresult status = cuInit(0);
     18    if(status != CUDA_SUCCESS)
     19       return false;
     20
     21    status = cuDeviceGet( &hcuDevice, device);
     22    if(status != CUDA_SUCCESS)
     23       return false;
     24
     25    status = cuCtxCreate( &hcuContext, 0x4, hcuDevice );
     26    if(status != CUDA_SUCCESS)
     27       return false;
     28
     29    return true;
     30}
     31}}}
     32Don't set up a cuda context via the CUDART runtime API before the calling of the new driver API code. If there are ANY calls to CUDART runtime DLL's (other than possibly cudaGetDeviceCount() and cudaGetDeviceProperties()) prior to calling the driver API blocking sync context setup, the driver API call will not have any affect.
     33
     34
     35== Thread priority ==
     36
     37Your application should use normal thread priority on Windows.
     38To do this, initialize BOINC as follows:
     39
     40{{{
     41BOINC_OPTIONS options;
     42boinc_options_defaults(options);
     43options.normal_thread_priority = 1;
     44boinc_init_options(&options);
     45}}}