REPLACING CUTIL* IN CUDA 5.0+

cutil*.h was extensively used for most of the old cuda projects. But post CUDA 4.2 there is no cutil* to be used. Recently, I was trying to compile a CUDA + OpenGL project which extensively uses all the cutil* functions, so I had to go about changing all the deprecated macros and function calls. Well, there can be another option, which is to have CUDA 4.1 in your machine and use it to build your project, but I decided to take the longer and cleaner route, which is to update the entire code.

The replacement for cutil*.h are the new helper_*.h . Here is what nVidia has to say about the entire affair.

Prior to CUDA 5.0, CUDA Sample projects referenced a utility library with header and source files called cutil. This has been removed with the CUDA Samples in CUDA 5.0, and replaced with header files found in CUDA Samples\v5.0\C\common\inc

helper_cuda.h, helper_cuda_gl.h, helper_cuda_drvapi.h, helper_functions.h,helper_image.h, helper_math.h, helper_string.h,and helper_timer.h

These files provide utility functions for CUDA device initialization, CUDA error checking, string parsing, image file loading and saving, and timing functions. The CUDA Samples projects no longer have references and dependencies to cutil, and will now use these helper functions going forward.

 

So here is what i did.

  1. Replace

    #include <cutil.h>
    #include <cutil_inline.h>
    #include <cutil_gl_inline.h>
    #include <cutil_inline_runtime.h>

    with

    #include <helper_cuda.h>
    #include <helper_cuda_gl.h>
    #include <helper_functions.h>
    #include <helper_timer.h>
  2. Replace

    cutilSafeCall( )

    with

    checkCudaErrors( )

     

  3. Change the timer structure from

    unsigned int timer=0;
    cutCreateTimer(&timer);
    cutResetTimer(&timer);
    cutStartTimer(&timer);
    ...ur code...
    cutStopTimer(&timer);
    float time = cutGetTimerValue(&timer);
    cutDeleteTimer(&timer);

    to

    StopwatchInterface *timer=NULL;
    sdkCreateTimer(&timer);
    sdkResetTimer(&timer);
    sdkStartTimer(&timer);
    ...ur code...
    sdkStopTimer(&timer);
    float time = sdkGetTimerValue(&timer);
    cutDeleteTimer(&timer);
  4. The helper_*.h come bundled along with the CUDA sample programs. So you will have to include the “../common/inc” directory into your project.


你可能感兴趣的:(REPLACING CUTIL* IN CUDA 5.0+)