Reputation: 21
I'm new to CUDA and I'm working through compiling and testing some of the examples provided by Nvidia. I am able to compile and run the example here without any issues, so I think I generally have a functioning system.
Right now, I'm trying to compile this example code which also requires the header file util.hxx at the same site. I'm compiling with the command suggested in the comments of the code itself:
nvcc -ccbin gcc -I/usr/local/cuda/include -c diag.cpp -o diag.o
I get the following errors, most of which are just variations on the same couple of errors:
In file included from diag.cpp:12:
util.hxx: In function ‘int memcpyH2D(int, const int*, int, int, const T_ELEM*, int, int, int, int, T_ELEM**, int, int)’:
util.hxx:240:49: error: there are no arguments to ‘imax’ that depend on a template parameter, so a declaration of ‘imax’ must be available [-fpermissive]
const int A_start_col = imax( JA, IBX_A ); /* base-1 */
^~~~
util.hxx:240:49: note: (if you use ‘-fpermissive’, G++ will accept your code, but allowing the use of an undeclared name is deprecated)
util.hxx:243:42: error: there are no arguments to ‘imin’ that depend on a template parameter, so a declaration of ‘imin’ must be available [-fpermissive]
const int bdd = imin( N_hat, (IBX_A + T_A -1) );
^~~~
util.hxx:244:42: error: there are no arguments to ‘imin’ that depend on a template parameter, so a declaration of ‘imin’ must be available [-fpermissive]
const int IT_A = imin( T_A, (bdd - A_start_col + 1) );
^~~~
util.hxx:249:71: error: there are no arguments to ‘IDX2F’ that depend on a template parameter, so a declaration of ‘IDX2F’ must be available [-fpermissive]
T_ELEM *d_A = array_d_A_unpacked[JA_blk_id] + IDX2F( loc_A_start_row, loc_A_start_col, LLD_A );
^~~~~
util.hxx:250:51: error: there are no arguments to ‘IDX2F’ that depend on a template parameter, so a declaration of ‘IDX2F’ must be available [-fpermissive]
const T_ELEM *h_A = h_B + IDX2F( A_start_row - IA + 1, A_start_col - JA + 1, ldb );
^~~~~
util.hxx: In function ‘int memcpyD2H(int, const int*, int, int, int, int, int, T_ELEM**, int, int, T_ELEM*, int)’:
util.hxx:328:49: error: there are no arguments to ‘imax’ that depend on a template parameter, so a declaration of ‘imax’ must be available [-fpermissive]
const int A_start_col = imax( JA, IBX_A ); /* base-1 */
^~~~
util.hxx:330:42: error: there are no arguments to ‘imin’ that depend on a template parameter, so a declaration of ‘imin’ must be available [-fpermissive]
const int bdd = imin( N_hat, (IBX_A + T_A -1) );
^~~~
util.hxx:331:42: error: there are no arguments to ‘imin’ that depend on a template parameter, so a declaration of ‘imin’ must be available [-fpermissive]
const int IT_A = imin( T_A, (bdd - A_start_col + 1) );
^~~~
util.hxx:334:77: error: there are no arguments to ‘IDX2F’ that depend on a template parameter, so a declaration of ‘IDX2F’ must be available [-fpermissive]
const T_ELEM *d_A = array_d_A_unpacked[JA_blk_id] + IDX2F( loc_A_start_row, loc_A_start_col, LLD_A );
^~~~~
util.hxx:335:45: error: there are no arguments to ‘IDX2F’ that depend on a template parameter, so a declaration of ‘IDX2F’ must be available [-fpermissive]
T_ELEM *h_A = h_B + IDX2F( A_start_row - IA + 1, A_start_col - JA + 1, ldb );
^~~~~
util.hxx: In instantiation of ‘int memcpyH2D(int, const int*, int, int, const T_ELEM*, int, int, int, int, T_ELEM**, int, int) [with T_ELEM = double]’:
diag.cpp:53:100: required from here
util.hxx:240:53: error: ‘imax’ was not declared in this scope
const int A_start_col = imax( JA, IBX_A ); /* base-1 */
~~~~^~~~~~~~~~~~~
util.hxx:240:53: note: suggested alternative: ‘fmax’
const int A_start_col = imax( JA, IBX_A ); /* base-1 */
~~~~^~~~~~~~~~~~~
fmax
util.hxx:243:46: error: ‘imin’ was not declared in this scope
const int bdd = imin( N_hat, (IBX_A + T_A -1) );
~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
util.hxx:243:46: note: suggested alternative: ‘fmin’
const int bdd = imin( N_hat, (IBX_A + T_A -1) );
~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
fmin
util.hxx:244:46: error: ‘imin’ was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]
const int IT_A = imin( T_A, (bdd - A_start_col + 1) );
~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
util.hxx:243:46: note: ‘imin’ declared here, later in the translation unit
const int bdd = imin( N_hat, (IBX_A + T_A -1) );
~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
util.hxx:249:76: error: ‘IDX2F’ was not declared in this scope
T_ELEM *d_A = array_d_A_unpacked[JA_blk_id] + IDX2F( loc_A_start_row, loc_A_start_col, LLD_A );
~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
util.hxx:249:76: note: the macro ‘IDX2F’ had not yet been defined
diag.cpp:17: note: it was later defined here
#define IDX2F(i,j,lda) ((((j)-1)*((size_t)lda))+((i)-1))
In file included from diag.cpp:12:
util.hxx:250:56: error: ‘IDX2F’ was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]
const T_ELEM *h_A = h_B + IDX2F( A_start_row - IA + 1, A_start_col - JA + 1, ldb );
~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
util.hxx:249:76: note: ‘IDX2F’ declared here, later in the translation unit
T_ELEM *d_A = array_d_A_unpacked[JA_blk_id] + IDX2F( loc_A_start_row, loc_A_start_col, LLD_A );
~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
util.hxx: In instantiation of ‘int memcpyD2H(int, const int*, int, int, int, int, int, T_ELEM**, int, int, T_ELEM*, int) [with T_ELEM = double]’:
diag.cpp:242:17: required from here
util.hxx:328:53: error: ‘imax’ was not declared in this scope
const int A_start_col = imax( JA, IBX_A ); /* base-1 */
~~~~^~~~~~~~~~~~~
util.hxx:328:53: note: suggested alternative: ‘fmax’
const int A_start_col = imax( JA, IBX_A ); /* base-1 */
~~~~^~~~~~~~~~~~~
fmax
util.hxx:330:46: error: ‘imin’ was not declared in this scope
const int bdd = imin( N_hat, (IBX_A + T_A -1) );
~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
util.hxx:330:46: note: suggested alternative: ‘fmin’
const int bdd = imin( N_hat, (IBX_A + T_A -1) );
~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
fmin
util.hxx:331:46: error: ‘imin’ was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]
const int IT_A = imin( T_A, (bdd - A_start_col + 1) );
~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
util.hxx:330:46: note: ‘imin’ declared here, later in the translation unit
const int bdd = imin( N_hat, (IBX_A + T_A -1) );
~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
util.hxx:334:82: error: ‘IDX2F’ was not declared in this scope
const T_ELEM *d_A = array_d_A_unpacked[JA_blk_id] + IDX2F( loc_A_start_row, loc_A_start_col, LLD_A );
~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
util.hxx:334:82: note: the macro ‘IDX2F’ had not yet been defined
diag.cpp:17: note: it was later defined here
#define IDX2F(i,j,lda) ((((j)-1)*((size_t)lda))+((i)-1))
In file included from diag.cpp:12:
util.hxx:335:50: error: ‘IDX2F’ was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]
T_ELEM *h_A = h_B + IDX2F( A_start_row - IA + 1, A_start_col - JA + 1, ldb );
~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
util.hxx:334:82: note: ‘IDX2F’ declared here, later in the translation unit
const T_ELEM *d_A = array_d_A_unpacked[JA_blk_id] + IDX2F( loc_A_start_row, loc_A_start_col, LLD_A );
~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I've googled around a bit for help on the template errors, but most of the solutions are focused on fixing the code. I'm presuming, for the moment, that Nvidia's example code is fine. I'm wondering if I need to upgrade my gcc.
I'm on a Centos 8 system with the default gcc version 8.3.1 and CUDA toolkit version 11.3. According to Nvidia, this should be a fine setup.
Before I take the time to install a second gcc version in my home directory, I wonder if anyone has any advice for me?
Thanks for the help!
Upvotes: 0
Views: 203
Reputation: 21
Okay, I figured this out ... the example code was missing some directives. I added the following definitions to the top of both the main cpp file and the header:
#ifndef IDX2F
#define IDX2F(i,j,lda) ((((j)-1)*((size_t)lda))+((i)-1))
#endif /* IDX2F */
#ifndef IDX1F
#define IDX1F(i) ((i)-1)
#endif /* IDX1F */
#ifndef imin
#define imin( x, y ) ((x)<(y)) ? (x) : (y)
#endif
#ifndef imax
#define imax( x, y ) ((x)>(y)) ? (x) : (y)
#endif
Upvotes: 1