3

I have a problem using the nvcc compiler. I found out that host code compiled using nvcc 4.2 runs about 5 times slower than the same code compiled using g++ 4.4.6. I am using the NVIDIA SDK Makefile template to compile the code in release configuration. In both cases the -O2 optimization is used. How can this be, since the nvcc should pass the host code to the host compiler. Any ideas?

This is my makefile:

# Add source files here
EXECUTABLE  := App
verbose=1
# C/C++ source files (compiled with gcc / c++)
CCFILES     := \
    cmdl.cpp main.cpp
# Cuda source files (compiled with cudacc)
CUFILES_sm_30       := AppCuda.cu AppHost.cpp 

# Do not link with CUTIL
OMIT_CUTIL_LIB := 1

################################################################################
# Rules and targets
ROOTDIR=/home/snpsyn/NVIDIA_GPU_Computing_SDK/C/common
include $(ROOTDIR)/../common/common.mk
ECHO001
  • 31
  • 2
  • 2
    Could you perhaps tell us a bit more about your code? What are you computing? And how? – Pedro Jun 20 '12 at 09:06
  • And with what version of nvcc? – leftaroundabout Jun 20 '12 at 09:28
  • nvcc is version 4.2. I'm doing some analysis on data where the main part is calculating multi-variate probaibility distributions (histograms). The application's host code runs fine on Windows when compiled with Microsoft cl or nvcc. It also runs fine if compiled on Ubuntu using g++, but if I compile it with nvcc on Ubuntu it slows down considerably. I imagined that if I pass only the host code to the nvcc compiler (without gpu kernels) it will be passed to the host compiler (g++) and it should produce the same code as using just g++, but this is not the case. – ECHO001 Jun 20 '12 at 11:41
  • The computationally intensive part of the application is in the files AppCuda.cu and AppHost.cpp – ECHO001 Jun 20 '12 at 12:14
  • Not enough information to provide an answer. Did you profile to find out where exactly the extra time is being spent? – harrism Jun 21 '12 at 04:28

1 Answers1

1

There should be no difference in compiling c++ code with nvcc or g++ (CUDA compiler driver)

But try compiling all c++ code with g++ directly. In the example you gave, the AppHost.cpp file is being passed to nvcc and not g++.

It would help a lot if you could provide the source code and makefile.

rda
  • 86
  • 4