I have a class which manages memory between host and gpu and this class is designed to be run on host. It was my understanding that any host side code encounted by nvcc would be passed to the host compiler, Visual Studio cc in this case.
In the below code all I need to do is define SEGFAULT_THE_NVCC_COMPILER and compile in the boost goodness to get nvcc to segfault.
void print_dimensions( void )
{
LOG_EVENT( LOG_STATUS, "Dimensions of matrix data are\n" );
size_t index = 0;
for(
dimensions_itr_t i = this->mv_dimensions.begin();
i != this->mv_dimensions.end(); i++
)
{
index++;
#ifdef SEGFAULT_THE_NVCC_COMPILER
LOG_EVENT( LOG_STATUS,
str(
boost::format( "\tdim[%d] = %d\n" ) % index % *i
).c_str()
);
#endif
}
}
This code is copy pasted from another class which is compiled outside of a .cu file so I know for a fact it works. I know compiling boost can be a scary thing for a compiler to do, but then I read:
The front end of the compiler processes CUDA source files according to C++
syntax rules. Full C++ is supported for the host code. However, only a subset of
C++ is fully supported for the device code as described in detail in Appendix D. As
a consequence of the use of C++ syntax rules, void pointers (e.g., returned by
malloc()) cannot be assigned to non-void pointers without a typecast.
nvcc also support specific keywords and directives detailed in Appendix E.
Paying special attention to the stuff I put in bold, I quickly realize that this statement is obviously false. With the output from my compile as proof below:
– Generating temporary cmake readable file: /home/bdavis5/projects/NIH2009/branches/trunk/build/dvip4-Linux64/source/Matlab/gpu_backprojection/CMakeFiles/gpuBackprojectionPlugin_generated_gpuBackprojection.cu.o.depend.tmp
/home/bdavis5/projects/NIH2009/branches/trunk/build/Linux-2.6.32-27-server/install/include/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp(49): warning: “cc” clobber ignored
/home/bdavis5/projects/NIH2009/branches/trunk/platform/tools/cmake-2.8.3/bin/cmake -D input_file:FILEPATH=/home/bdavis5/projects/NIH2009/branches/trunk/build/dvip4-Linux64/source/Matlab/gpu_backprojection/CMakeFiles/gpuBackprojectionPlugin_generated_gpuBackprojection.cu.o.NVCC-depend -D output_file:FILEPATH=/home/bdavis5/projects/NIH2009/branches/trunk/build/dvip4-Linux64/source/Matlab/gpu_backprojection/CMakeFiles/gpuBackprojectionPlugin_generated_gpuBackprojection.cu.o.depend.tmp -P /home/bdavis5/projects/NIH2009/branches/trunk/platform/tools/cmake-2.8.3/Modules/FindCUDA/make2cmake.cmake
/home/bdavis5/projects/NIH2009/branches/trunk/build/Linux-2.6.32-27-server/install/include/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp(65): warning: “cc” clobber ignored
/home/bdavis5/projects/NIH2009/branches/trunk/build/Linux-2.6.32-27-server/install/include/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp(91): warning: “cc” clobber ignored
/home/bdavis5/projects/NIH2009/branches/trunk/build/Linux-2.6.32-27-server/install/include/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp(75): warning: variable “tmp” was set but never used
Segmentation fault
CMake Error at CMakeFiles/gpuBackprojectionPlugin_generated_gpuBackprojection.cu.o.cmake:252 (message):
A note about the clobers. These do not appear to be an issue as the code compiles and runs, but I would be interested in removing them.
if you want to test the C++ abilities of your compiler… compile boost.
eelsen
February 3, 2011, 7:03pm
2
I have a class which manages memory between host and gpu and this class is designed to be run on host. It was my understanding that any host side code encounted by nvcc would be passed to the host compiler, Visual Studio cc in this case.
In the below code all I need to do is define SEGFAULT_THE_NVCC_COMPILER and compile in the boost goodness to get nvcc to segfault.
void print_dimensions( void )
{
LOG_EVENT( LOG_STATUS, "Dimensions of matrix data are\n" );
size_t index = 0;
for(
dimensions_itr_t i = this->mv_dimensions.begin();
i != this->mv_dimensions.end(); i++
)
{
index++;
#ifdef SEGFAULT_THE_NVCC_COMPILER
LOG_EVENT( LOG_STATUS,
str(
boost::format( "\tdim[%d] = %d\n" ) % index % *i
).c_str()
);
#endif
}
}
This code is copy pasted from another class which is compiled outside of a .cu file so I know for a fact it works. I know compiling boost can be a scary thing for a compiler to do, but then I read:
Paying special attention to the stuff I put in bold, I quickly realize that this statement is obviously false. With the output from my compile as proof below:
A note about the clobers. These do not appear to be an issue as the code compiles and runs, but I would be interested in removing them.
if you want to test the C++ abilities of your compiler… compile boost.
I think it is a known issue that nvcc can’t compile all of boost.
njuffa
February 3, 2011, 7:09pm
3
I assume you have verified that the segfault occurs inside nvcc or another NVIDIA component, not the host compiler? This is not clear to me from the build log shown. Independent of the level of C++ support in the CUDA compiler, it should not segfault. If the segfault is not attributable to the host compiler or linker, it would be helpful if you could file a compiler bug, attaching a self-contained repro case, as well as information about the platform you compiled on and the exact command line used to invoke nvcc. Thank you for your help.
I assume you have verified that the segfault occurs inside nvcc or another NVIDIA component, not the host compiler? This is not clear to me from the build log shown. Independent of the level of C++ support in the CUDA compiler, it should not segfault. If the segfault is not attributable to the host compiler or linker, it would be helpful if you could file a compiler bug, attaching a self-contained repro case, as well as information about the platform you compiled on and the exact command line used to invoke nvcc . Thank you for your help.
Yep sorry for got to enable verbose=yes env variable before calling cmake to work it’s magic and above I stated VS cc which I recently switched from. I am now suing Unbuntu and my brain cells are still a version behind :-).
cc (Ubuntu 4.4.3-4ubuntu5) 4.4.3
Copyright (C) 2009 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2010 NVIDIA Corporation
Built on Wed_Nov__3_16:16:57_PDT_2010
Cuda compilation tools, release 3.2, V0.2.1221
– Generating /home/bdavis5/projects/NIH2009/branches/trunk/build/dvip4-Linux64/source/Matlab/gpu_backprojection/./gpuBackprojectionPlugin_generated_gpuBackprojection.cu.o
/usr/local/nvidia/cuda-3.2/cuda/bin/nvcc /home/bdavis5/projects/NIH2009/branches/trunk/source/Matlab/lib/dsaLib/gpu/backprojection/src/gpuBackprojection.cu -c -o /home/bdavis5/projects/NIH2009/branches/trunk/build/dvip4-Linux64/source/Matlab/gpu_backprojection/./gpuBackprojectionPlugin_generated_gpuBackprojection.cu.o -m64 -DgpuBackprojectionPlugin_EXPORTS -Xcompiler ,"-fPIC" -g -G0 -O0 -gencode=arch=compute_10,code="sm_10,compute_10" -gencode=arch=compute_13,code="sm_13,compute_13" -gencode=arch=compute_20,code="sm_20,compute_20" -DUSE_MATLAB=YES -DRECON_EXPORT=yes -DGPU_RECON=yes -DNVCC -I/usr/local/nvidia/cuda-3.2/cuda/include -I/opt/MatlabR2010a/extern/include -I/home/bdavis5/projects/NIH2009/branches/trunk/source/Matlab/lib/dsaLib/gpu/utility/src/…/include -I/home/bdavis5/projects/NIH2009/branches/trunk/source/Matlab/lib/dsaLib/mex/src/…/include -I/home/bdavis5/projects/NIH2009/branches/trunk/source/Matlab/lib/dsaLib/matrix/src/…/include -I/home/bdavis5/projects/NIH2009/branches/trunk/build/Linux-2.6.32-27-server/install/include -I/usr/local/nvidia/cuda-3.2/cuda/include -I/opt/NVIDIA_GPU_Computing_SDK/C/common/inc -I/home/bdavis5/projects/NIH2009/branches/trunk/source/Matlab/lib/dsaLib/utility/src/…/include -I/home/bdavis5/projects/NIH2009/branches/trunk/source/Matlab/lib/dsaLib/gpu/backprojection/src/. -I/home/bdavis5/projects/NIH2009/branches/trunk/source/Matlab/lib/dsaLib/gpu/backprojection/src/…/include
/home/bdavis5/projects/NIH2009/branches/trunk/build/Linux-2.6.32-27-server/install/include/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp(49): warning: “cc” clobber ignored
/home/bdavis5/projects/NIH2009/branches/trunk/build/Linux-2.6.32-27-server/install/include/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp(65): warning: “cc” clobber ignored
/home/bdavis5/projects/NIH2009/branches/trunk/build/Linux-2.6.32-27-server/install/include/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp(91): warning: “cc” clobber ignored
/home/bdavis5/projects/NIH2009/branches/trunk/build/Linux-2.6.32-27-server/install/include/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp(75): warning: variable “tmp” was set but never used
Segmentation fault
I really doubt that it has anything to do with the host compiler as this same function in another class which compiles in a .cpp file compiles just fine.
boost version is boost_1_45_0
I’ll try and come up with a simple test case make file and .cu file with cmake out of the picture. Above is the info I can obtain quickly.
the test case:
seg_fault_nvcc_compiler.cu
#include <vector>
#include <boost/format.hpp>
#include <stdio.h>
typedef size_t dimension_element_t;
typedef std::vector<dimension_element_t> dimensions_t;
typedef dimensions_t::iterator dimensions_itr_t;
#define LOG_EVENT( WARN_LEVEL, MESSAGE, ... ) printf( MESSAGE, ## __VA_ARGS__ )
#define SEGFAULT_THE_NVCC_COMPILER
void print_dimensions( void )
{
dimensions_t mv_dimensions;
mv_dimensions.push_back( 2 );
mv_dimensions.push_back( 3 );
mv_dimensions.push_back( 4 );
LOG_EVENT( LOG_STATUS, "Dimensions of matrix data are\n" );
size_t index = 0;
for(
dimensions_itr_t i = mv_dimensions.begin();
i != mv_dimensions.end(); i++
)
{
index++;
#ifdef SEGFAULT_THE_NVCC_COMPILER
LOG_EVENT( LOG_STATUS,
str(
boost::format( "\tdim[%d] = %d\n" ) % index % *i
).c_str()
);
#endif
}
}
int main( void )
{
print_dimensions();
}
Makefile
NVCC=/usr/local/nvidia/cuda-3.2/cuda/bin/nvcc
NVCC_FLAGS= -m64 -DgpuBackprojectionPlugin_EXPORTS -Xcompiler ,\"-fPIC\" -g -G0 -O0 -gencode=arch=compute_10,code=\"sm_10,compute_10\" -gencode=arch=compute_13,code=\"sm_13,compute_13\" -gencode=arch=compute_20,code=\"sm_20,compute_20\" -DUSE_MATLAB=YES -DRECON_EXPORT=yes -DGPU_RECON=yes -DNVCC
BOOST_INCLUDE_DIR_FLAG=-I/home/bdavis5/projects/NIH2009/branches/trunk/build/Linux-2.6.32-27-server/install/include
all:
$(NVCC) seg_fault_nvcc_compiler.cu -c -o seg_fault_nvcc_compiler.o $(NVCC_FLAGS) $(BOOST_INCLUDE_DIR_FLAG)
the output
bdavis5@teradrive:~/projects/NIH2009/branches/nvida_test_cases$ make
/usr/local/nvidia/cuda-3.2/cuda/bin/nvcc seg_fault_nvcc_compiler.cu -c -o seg_fault_nvcc_compiler.o -m64 -DgpuBackprojectionPlugin_EXPORTS -Xcompiler ,"-fPIC" -g -G0 -O0 -gencode=arch=compute_10,code="sm_10,compute_10" -gencode=arch=compute_13,code="sm_13,compute_13" -gencode=arch=compute_20,code="sm_20,compute_20" -DUSE_MATLAB=YES -DRECON_EXPORT=yes -DGPU_RECON=yes -DNVCC -I/home/bdavis5/projects/NIH2009/branches/trunk/build/Linux-2.6.32-27-server/install/include
/home/bdavis5/projects/NIH2009/branches/trunk/build/Linux-2.6.32-27-server/install/include/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp(49): warning: “cc” clobber ignored
/home/bdavis5/projects/NIH2009/branches/trunk/build/Linux-2.6.32-27-server/install/include/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp(65): warning: “cc” clobber ignored
/home/bdavis5/projects/NIH2009/branches/trunk/build/Linux-2.6.32-27-server/install/include/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp(91): warning: “cc” clobber ignored
/home/bdavis5/projects/NIH2009/branches/trunk/build/Linux-2.6.32-27-server/install/include/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp(75): warning: variable “tmp” was set but never used
Segmentation fault
make: *** [all] Error 139
njuffa
February 3, 2011, 9:50pm
6
Please file a bug so that our compiler team can look into this. Thanks!
That sound like a fantastic idea… how? I tried logging in as a registered developer using the links at http://developer.nvidia.com/object/gpucomputing.html and was unable to login using every user name email and password I have ever used post BBS systems. I am pretty sure I registered for this before, but I registered with the NVIDA collective again and have not received an email. I think that makes 3, 1 developer forum, 1 Nsight user, and now a third GPU Developer??? Please let me know where to enter my DNA sequence so that NVIDIA knows who I am so I can submit the bug. Or better yet just copy paste my text into the bug tool behind the 12 firewalls. I am starting to realize why the tools are still so spectacular even after version 3.2. I took the time to write the test case maybe someone there can take the time to Ctrl-C Ctrl-V the goop into the bug tracker. Crimineys
Just received my login today (Feb 7, 2011) at Noon. This bug has now been reported.
njuffa
February 8, 2011, 4:03am
9
Thank you for your help and sorry for the inconvenience.