5

I use the command lines in Ubuntu's terminal.

And I am trying to compile the three files presented in CUDA_Compiler_Driver_NVCC.pdf

When I do use the command line given by the documentation on these 3 files, I do get the following errors:

nvcc fatal : don't know what to do with'-dc'

If I erase -dc in the command line, I do get the following error too: nvcc fatal : don't know what to do with'-arch=sm=20'

Do anyone know how I could fix this issue ?

Thanks a lot in advance for your help

Gibo

Below, you will find the command line I entered in the terminal, and the files.

Command line used: nvcc –arch=sm_20 –dc a.cu b.cu nvcc –arch=sm_20 a.o b.o

Files code (just a copy paste of the documentation): (it seems the code police changes when pasted, sorry for this small issue)

******* b.h ***********
#define N 8

extern __device__ int g[N];
extern __device__ void bar(void);

******* b.cu***********
#include "b.h"
__device__ int g[N];
__device__ void bar (void)
{
g[threadIdx.x]++;
}

******* a.cu ***********
#include <stdio.h>

#include "b.h"

__global__ void foo (void) {
__shared__ int a[N];
a[threadIdx.x] = threadIdx.x;
__syncthreads();
g[threadIdx.x] = a[blockDim.x - threadIdx.x - 1];
}

bar();

int main (void) {
unsigned int i;
int *dg, hg[N];

int sum = 0;

foo<<<1, N>>>();

if(cudaGetSymbolAddress((void**)&dg, g)){
printf("couldn't get the symbol addr\n");
return 1;
}

if(cudaMemcpy(hg, dg, N * sizeof(int), cudaMemcpyDeviceToHost)){
printf("couldn't memcpy\n");
return 1;
}

for (i = 0; i < N; i++) {
sum += hg[i];
}

if (sum == 36) {
printf("PASSED\n");
} else {
printf("FAILED (%d)\n", sum);
}

return 0;
}
jub0bs
  • 60,866
  • 25
  • 183
  • 186
Gibo
  • 61
  • 1
  • 4
  • Can you supply link to mentioned PDF? I checked with [nvcc manpage](http://rpm.pbone.net/index.php3/stat/45/idpl/12463013/numer/1/nazwa/nvcc) and it has no flags like `-dc` or `--arch`. Also, I'd assume that `--arch` specifies target hardware architecture, so I can't get it why it is given twice. – Filip Malczak Mar 29 '14 at 11:48
  • Yes Filip here it is p46-47 : http://docs.nvidia.com/cuda/pdf/CUDA_Compiler_Driver_NVCC.pdf – Gibo Mar 29 '14 at 11:51
  • Read chapter 6 (page 29 of this pdf) for explanation of `-arch` flag. Still searching for any mention of `-dc` – Filip Malczak Mar 29 '14 at 11:57
  • the -arch is used to specify the type of architecture I use. I tried them all sm_21 sm_13 etc. it seems the error does not come from this. I wonder whether it is from configuration purposes or something. I might be wrong since I am new to Ubuntu – Gibo Mar 29 '14 at 11:58
  • But you didn't specify code. I'm still at "search topics" stage, not "read those topics", but as far as I've seen, you always use `-arch` with `-code`, and its values may be the same. Also, read what other options you should use for those to be available (maybe they are used only on some special compilation phase?). – Filip Malczak Mar 29 '14 at 12:01
  • Als `-dc` is explained in 7.3, page 38. Do you really need both those options, or are you trying to start with CUDA and compile ANY program at all? – Filip Malczak Mar 29 '14 at 12:02
  • Well, after I read your answer, I wonder if these commands are useful. Because I do use a GeforceGTX620 and not one of Tesla type or something. It might effectively be related. The point is I am trying to compile the CUDA code example, and then I will compile new code – Gibo Mar 29 '14 at 12:02
  • And I am no CUDA expert, I just thought that those options look like overkill when trying to run code from PDF ;) Try without them, if you're gonna have a problem then - edit this post, I'm gonna watch it, and help you if I can. Btw: read the whole PDF, and do some notes while reading, I think it will be easier then ;) – Filip Malczak Mar 29 '14 at 12:05
  • yes I used it without and I get the following post: ./a.cu(11): Error: External calls are not supported (found non-inlined call to _Z3barv) So in a sense, it seems it is a new type of error. – Gibo Mar 29 '14 at 12:07
  • Good thing I said I'm no expert :D – Filip Malczak Mar 29 '14 at 12:11
  • But if it does not detect the content of the bar() function defined in the b.cu file, then there is something wrong with the compilation. Don't you think the -arch commands help ? here is a link of dc http://stackoverflow.com/questions/5994005/cuda-external-calls-not-supported – Gibo Mar 29 '14 at 12:17
  • With the -dc command, it might be linked to the CUDA version. I had issues seting up the 5.5 version, so I set up the 4.2, but it seems the -dc declaration was improved since the 5.0 version, I still need to check it, but it might be a clue – Gibo Mar 29 '14 at 13:00

1 Answers1

2

Make sure you are using the right version of nvcc. I had a problem like that and it was because I was using NVCC 5.5 instead of 6.0.

Also make sure the dashes have the right symbol: use - (0x2D) and not – (0xD0).

gbuzogany
  • 1,911
  • 16
  • 17
  • It did the job for me! I copied paste something from the internet and some how the - symbols got mixed! – eaponte Oct 29 '14 at 14:34