This minimal example:
int main()
{
struct surfaceReference* surfaceReferencePointer;
cudaGetSurfaceReference(&surfaceReferencePointer, "surfaceReference");
}
Fails when it is compiled like this:
nvcc -g -arch=sm_20 -o foo.out foo.cu
Showing the following error message:
foo.cu(4): warning: argument of type "surfaceReference **" is incompatible with parameter of type "const surfaceReference **"
foo.cu(4): warning: argument of type "surfaceReference **" is incompatible with parameter of type "const surfaceReference **"
foo.cu: In function ‘int main()’:
foo.cu:4: error: invalid conversion from ‘surfaceReference**’ to ‘const surfaceReference**’
foo.cu:4: error: initializing argument 1 of ‘cudaError_t cudaGetSurfaceReference(const surfaceReference**, const char*)’
I cannot understand what I am doing wrong. I am compiling on a Linux Ubuntu 64-bit machine, using CUDA 3.2.
The struct surfaceReference* pointer should be defined as const:
int main()
{
const struct surfaceReference* surfaceReferencePointer;
cudaGetSurfaceReference(&surfaceReferencePointer, "surfaceReference");
}
Kudos to codymanix, who provided the right answer in the comments.
Related
Minimum repro:
kernel.cu:
#include <stdio.h>
__constant__ int N_GPU;
void wrapper_fn(int *ptr)
{
cudaMemcpyToSymbol(N_GPU, ptr, sizeof(int), cudaMemcpyDeviceToDevice);
}
__global__ void printKernel() {
printf("N = %d; \n", N_GPU);
}
driver.cu:
#include "cuda_runtime.h"
#include <stdio.h>
void wrapper_fn(int*);
__global__ void printKernel();
int main()
{
int N = 10;
int* d_N_ptr;
cudaMalloc(&d_N_ptr, sizeof(int));
cudaMemcpy(d_N_ptr, &N, sizeof(int), cudaMemcpyDefault);
wrapper_fn(d_N_ptr);
printKernel <<<1, 1 >>>();
cudaPeekAtLastError();
cudaDeviceSynchronize();
return 0;
}
Both on cuda-11.4 and cuda-11.2, running nvcc kernel.cu driver.cu compiles. The expected output (i.e N = 10;) is only seen in 11.2 and not 11.4.
Upon running cuda-gdb on 11.4, I get the following:
...
[New Thread 0x7fffee240700 (LWP 54339)]
warning: Cuda API error detected: cudaMalloc returned (0xde)
warning: Cuda API error detected: cudaMemcpy returned (0xde)
warning: Cuda API error detected: cudaMemcpyToSymbol returned (0xde)
warning: Cuda API error detected: cudaLaunchKernel returned (0xde)
warning: Cuda API error detected: cudaPeekAtLastError returned (0xde)
warning: Cuda API error detected: cudaDeviceSynchronize returned (0xde)
[Thread 0x7fffee240700 (LWP 54339) exited]
...
Any particular nvcc flags I'm missing that's important in the 11.4? or particular API changes I'm missing? Thanks in advance!
So the answer has to do with my driver version. The error code as seen from the cuda-gdb output (0xde = 222) is due to the fact that the compiled PTX is too new for the driver installed (my driver was 460.35), and the "CUDA Enhanced Compatibility" was used to run on my older driver, that didn't support the necessary PTX JIT.
TLDR; compiling to the exact architecture-specific SASS solved for cuda 11.4.
I did this by adding the the -arch compute_70 flag to my nvcc compilation command.
Environment: CentOS+mysql-5.6.14
This is what I tried:
cd /usr/local/src/
tar zvfx ahiguti-HandlerSocket-Plugin-for-MySQL-1.0.6-71-g159ea6d.tar.gz
cd ahiguti-HandlerSocket-Plugin-for-MySQL-159ea6d/
./autogen.sh
./configure --with-mysql-source=/usr/local/src/mysql-5.1.47 --with-mysql-bindir=/usr/local/app/mysql/bin/ --with-mysql-plugindir=/usr/local/app/mysql/lib/mysql/plugin/ --prefix=/usr/local/app/mysql
make
but when i do 'make', I encounter the following errors:
In file included from database.cpp:16:
mysql_incl.hpp:12:1: warning: "HAVE_CONFIG_H" redefined
<command line>:1:1: warning: this is the location of the previous definition
database.cpp: In member function 'virtual void dena::dbcontext::init_thread(const void*, volatile int&)':
database.cpp:294: error: 'LOCK_thread_count' was not declared in this scope
database.cpp:296: error: 'threads' was not declared in this scope
database.cpp:297: error: 'thread_count' was not declared in this scope
database.cpp:310: error: 'create' is not a member of 'MDL_request'
database.cpp: In member function 'virtual void dena::dbcontext::term_thread()':
database.cpp:337: error: 'LOCK_thread_count' was not declared in this scope
database.cpp:340: error: 'thread_count' was not declared in this scope
database.cpp: In member function 'void dena::dbcontext::cmd_find_internal(dena::dbcallback_i&, const dena::prep_stmt&, ha_rkey_function, const dena::cmd_exec_args&)':
database.cpp:649: error: 'struct st_key' has no member named 'key_parts'
/data/install/mysql-5.6.14/sql/handler.h:2228: error: 'virtual int handler::index_read_map(uchar*, const uchar*, key_part_map, ha_rkey_function)' is protected
database.cpp:689: error: within this context
/data/install/mysql-5.6.14/sql/handler.h:2247: error: 'virtual int handler::index_prev(uchar*)' is protected
database.cpp:694: error: within this context
/data/install/mysql-5.6.14/sql/handler.h:2244: error: 'virtual int handler::index_next(uchar*)' is protected
database.cpp:698: error: within this context
/data/install/mysql-5.6.14/sql/handler.h:2256: error: 'virtual int handler::index_next_same(uchar*, const uchar*, uint)' is protected
database.cpp:701: error: within this context
database.cpp: In member function 'virtual void dena::dbcontext::cmd_open_index(dena::dbcallback_i&, size_t, const char*, const char*, const char*, const char*)':
database.cpp:770: error: cannot convert 'MEM_ROOT*' to 'Open_table_context*' for argument '3' to 'bool open_table(THD*, TABLE_LIST*, Open_table_context*)'
make[2]: *** [handlersocket_la-database.lo] error 1
make[1]: Leaving directory `/usr/local/src/HandlerSocket-Plugin-for-MySQL-1.0.6'
make: *** [all] error 2
You should use version 1.1 of https://github.com/DeNA/HandlerSocket-Plugin-for-MySQL
I build ITK with gdcm official release for windows. But its not having some of file that I'm using in further coding. So I have to use git version of gdcm cause its having those which I needed but following error encountered when I am trying to build ITK with ITK_USE_SYSTEM_GDCM and using gdcm git version to build gdcm bin.
>------ Build started: Project: ITKIOGDCM, Configuration: Debug Win32 ------
80>Compiling...
80>itkGDCMImageIO.cxx
80>..\..\..\..\..\src\Modules\IO\GDCM\src\itkGDCMImageIO.cxx(41) : fatal error C1083: Cannot open include file: 'gdcmImageHelper.h': No such file or directory
80>itkGDCMSeriesFileNames.cxx
80>D:\ITK\src\Modules\IO\GDCM\include\itkGDCMSeriesFileNames.h(154) : error C2664: 'void gdcm::SerieHelper::AddRestriction(const gdcm::TagKey &)' : cannot convert parameter 1 from 'const std::string' to 'const gdcm::TagKey &'
80> Reason: cannot convert from 'const std::string' to 'const gdcm::TagKey'
80> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
80>..\..\..\..\..\src\Modules\IO\GDCM\src\itkGDCMSeriesFileNames.cxx(29) : error C2248: 'gdcm::SerieHelper::SerieHelper' : cannot access protected member declared in class 'gdcm::SerieHelper'
80> D:\GDCM\gdcm\src\gdcmSerieHelper.h(198) : see declaration of 'gdcm::SerieHelper::SerieHelper'
80> D:\GDCM\gdcm\src\gdcmSerieHelper.h(64) : see declaration of 'gdcm::SerieHelper'
80>..\..\..\..\..\src\Modules\IO\GDCM\src\itkGDCMSeriesFileNames.cxx(160) : error C2027: use of undefined type 'gdcm::File'
80> D:\GDCM\gdcm\src\gdcmSerieHelper.h(34) : see declaration of 'gdcm::File'
80>..\..\..\..\..\src\Modules\IO\GDCM\src\itkGDCMSeriesFileNames.cxx(160) : error C2227: left of '->IsReadable' must point to class/struct/union/generic type
80>..\..\..\..\..\src\Modules\IO\GDCM\src\itkGDCMSeriesFileNames.cxx(163) : error C2027: use of undefined type 'gdcm::File'
80> D:\GDCM\gdcm\src\gdcmSerieHelper.h(34) : see declaration of 'gdcm::File'
80>..\..\..\..\..\src\Modules\IO\GDCM\src\itkGDCMSeriesFileNames.cxx(163) : error C2227: left of '->GetFileName' must point to class/struct/union/generic type
80>..\..\..\..\..\src\Modules\IO\GDCM\src\itkGDCMSeriesFileNames.cxx(166) : error C2027: use of undefined type 'gdcm::File'
80> D:\GDCM\gdcm\src\gdcmSerieHelper.h(34) : see declaration of 'gdcm::File'
80>..\..\..\..\..\src\Modules\IO\GDCM\src\itkGDCMSeriesFileNames.cxx(166) : error C2227: left of '->GetFileName' must point to class/struct/union/generic type
80>itkGDCMImageIOFactory.cxx
80>Generating Code...
80>Build log was saved at "file://d:\ITK\binGDCM\Modules\IO\GDCM\src\ITKIOGDCM.dir\Debug\BuildLog.htm"
80>ITKIOGDCM - 9 error(s), 0 warning(s)
Please help.
You are mixing the very old and deprecated GDCM 1.x with GDCM 2.x. They are actually API incompatible.
I am trying to compile MySQL++ 3.1.0 with the command:
mingw32-make -f Makefile.mingw
After a set of files gets compiled (e.g. beemutex.cpp, cmdline.cpp, connection.cpp, ...), I get these errors:
g++ -c -o mysqlpp_sql_buffer.o -g -mthreads -DUNICODE -D_UNICODE -DMYSQLPP_NO_DLL -DHAVE_MYSQL_SSL_SET -I"C:\Program Files\MySQL\MySQL Server 5.5\include" -MT
mysqlpp_sql_buffer.o -MFmysqlpp_sql_buffer.o.d -MD -MP lib/sql_buffer.cpp
In file included from lib/sql_buffer.h:31:0,
from lib/sql_buffer.cpp:26:
lib/refcounted.h:258:2: error: 'size_t' does not name a type
lib/refcounted.h: In constructor 'mysqlpp::RefCountedPointer<T, Destroyer>::RefCountedPointer()':
lib/refcounted.h:89:2: error: class 'mysqlpp::RefCountedPointer<T, Destroyer>' does not have any field named 'refs_'
lib/refcounted.h: In constructor 'mysqlpp::RefCountedPointer<T, Destroyer>::RefCountedPointer(T*)':
lib/refcounted.h:100:2: error: class 'mysqlpp::RefCountedPointer<T, Destroyer>' does not have any field named 'refs_'
lib/refcounted.h:104:4: error: 'refs_' was not declared in this scope
lib/refcounted.h:104:16: error: expected type-specifier before 'size_t'
lib/refcounted.h:104:16: error: expected ';' before 'size_t'
lib/refcounted.h: In constructor 'mysqlpp::RefCountedPointer<T, Destroyer>::RefCountedPointer(const ThisType&)':
lib/refcounted.h:112:2: error: class 'mysqlpp::RefCountedPointer<T, Destroyer>' does not have any field named 'refs_'
lib/refcounted.h:115:8: error: 'refs_' was not declared in this scope
lib/refcounted.h: In destructor 'mysqlpp::RefCountedPointer<T, Destroyer>::~RefCountedPointer()':
lib/refcounted.h:125:7: error: 'refs_' was not declared in this scope
lib/refcounted.h: In member function 'void mysqlpp::RefCountedPointer<T, Destroyer>::swap(mysqlpp::RefCountedPointer<T, Destroyer>::ThisType&)':
lib/refcounted.h:246:13: error: 'refs_' was not declared in this scope
mingw32-make: *** [mysqlpp_sql_buffer.o] Error 1
Something could be wrong in my configuration, but I can't find what. It seems strange that it cannot find, e.g., size_t.
Thank you!
Platform:
Windows 7
MinGW 2011.09 / GCC 4.6.1
MySQL 5.5
mysql++ 3.1.0
Changing size_t() with std::size_t() in refcounted.h solved the problem. It now compiles.
I still have linking problems, but they should be different issues.
I have a GTX 570 (Fermi architecture) which is of compute Capability 2.0. I have Cuda version 4.0 on my computer
and I am using Ubuntu 10.10
With Cuda 4.0 it is possible to use printf() inside kernels. Here is an example code from page 125 of the Cuda 4.0 programming guide
#if defined(__CUDA_ARCH__) && (__CUDA_ARCH__ < 200)
#define printf(f, ...) ((void)(f, __VA_ARGS__),0)
#endif
__global__ void helloCUDA(float f)
{
printf(“Hello thread %d, f=%f\n”, threadIdx.x, f);
}
void main()
{
helloCUDA<<<1, 5>>>(1.2345f);
cudaDeviceReset();
}
I am getting the following compilation error.
gaurish108 MyPractice: nvcc printf_inkernel.cu -o printf_inkernel
printf_inkernel.cu(10): error: unrecognized token
printf_inkernel.cu(10): error: expected an expression
printf_inkernel.cu(10): error: unrecognized token
printf_inkernel.cu(10): error: unrecognized token
printf_inkernel.cu(10): error: unrecognized token
printf_inkernel.cu(10): error: unrecognized token
printf_inkernel.cu(10): error: unrecognized token
printf_inkernel.cu(10): error: unrecognized token
printf_inkernel.cu(15): warning: return type of function "main" must be "int"
8 errors detected in the compilation of "/tmp/tmpxft_000014cd_00000000-4_printf_inkernel.cpp1.ii".
Why is it not recognizing printf? I tried adding the flag -arch=sm_20 , but I get the same error.
It looks like you've got a weird quote character at either end of printf's formatter string.
If you copy and paste this program, it ought to compile and run without error:
#include <stdio.h>
__global__ void helloCUDA(float f)
{
printf("Hello thread %d, f=%f\n", threadIdx.x, f);
}
int main()
{
helloCUDA<<<1, 5>>>(1.2345f);
cudaDeviceReset();
return 0;
}
And the output:
$ nvcc -arch=sm_20 test.cu -run
Hello thread 0, f=1.234500
Hello thread 1, f=1.234500
Hello thread 2, f=1.234500
Hello thread 3, f=1.234500
Hello thread 4, f=1.234500
I don't understand the need for the weird macro which begins the program. I'd get rid of it.