Calling helper_timer.h from CUDA causes errors

Hi,

I’m trying to compile some c++ and cuda code. One of my .cpp files calles “helper_time.h”, however, I keep getting the following errors:

/usr/local/cuda-10.2/samples/common/inc/exception.h:92:15: error: expected initializer before ‘<’ token
 void Exception<Std_Exception>::throw_it(const char *file, const int line
/usr/local/cuda-10.2/samples/common/inc/exception.h:118:1: error: reference to ‘Exception’ is ambiguous
 Exception<Std_Exception>::Exception() : Std_Exception("Unknown Exception.\n") {}

Any ideas what could be causing this?

Hi,

It seems that you are meeting a similar issue as following:

“ambiguous symbol error” while building a C++/Tcl program using boost library - Stack Overflow

Could you try the suggestion to see if it also works for your use case?
If not, would you mind to share a complete source for us reproducing?

Thanks.

Hi @AastaLLL,

I was able to solve the issue, it was an error in my CMakeLists file, however I am now gettin out of bounds errors:

========= Invalid __global__ read of size 1
=========     at 0x00000090 in d_getAvrgErr(float*, uchar4*, int)
=========     by thread (15,13,0) in block (5,0,0)
=========     Address 0x0004049e is out of bounds
=========     Saved host backtrace up to driver entry point at kernel launch time
=========     Host Frame:/usr/lib/aarch64-linux-gnu/tegra/libcuda.so.1 (cuLaunchKernel + 0x218) [0x1f3970

Here’s the function causing the error:

__global__ void d_getAvrgErr(float* d_avrg, uchar4* d_ptr, int W) {
    int i = (blockIdx.x<<BLOCK_DIM_2D_RADIX) + threadIdx.x,
        j = (blockIdx.y<<BLOCK_DIM_2D_RADIX) + threadIdx.y,
        index = j*W + i;
    d_ptr += index;
    atomicAdd(d_avrg,abs(d_ptr->z-(int)d_ptr->y));
}

How could I prevent an out of bounds error? Btw I’m trying to compile on both a Xavier NX and a TX2 NX

Hi,

Address 0x0004049e is out of bounds

This indicates the thread index is larger than the array size.
And causes some illegal memory access.

You can add a simple check to avoid this.
For example, if the buffer size of d_ptr is d_size.

__global__ void d_getAvrgErr(float* d_avrg, uchar4* d_ptr, int W, int d_size) {
    int i = (blockIdx.x<<BLOCK_DIM_2D_RADIX) + threadIdx.x,
        j = (blockIdx.y<<BLOCK_DIM_2D_RADIX) + threadIdx.y,
        index = j*W + I;

    if ( index < d_size )
    {
        d_ptr += index;
        atomicAdd(d_avrg,abs(d_ptr->z-(int)d_ptr->y));
    }
}

Thanks.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.