I am porting an existing C application to run partly on a GPU. The original code compiles without complaint when using gcc, but when using nvcc on the new version, it complains about things in some of the C files that I haven’t altered, and I can’t see why it is complaining.
The errors that I get are:
…/mpi_s/mpi.h(119): error: expected a “)”
…/mpi_s/mpi.h(121): error: expected a “)”
io_harness.h(23): error: identifier “FILE” is undefined
io_harness.h(24): error: identifier “FILE” is undefined
io_harness.h(29): error: identifier “FILE” is undefined
io_harness.h(30): error: identifier “FILE” is undefined
io_harness.h(31): error: identifier “FILE” is undefined
io_harness.h(32): error: identifier “FILE” is undefined
gpu.cu(129): error: expected a “)”
line 119 of mpi.h is:
int MPI_Type_contiguous(int count, MPI_Datatype old, MPI_Datatype * new);
line 121 of mpi.h is the second line below (a continuation of a declaration started on line 120):
int MPI_Type_vector(int count, int blocklength, int stride, MPI_Datatype old,
MPI_Datatype * new);
I can’t see what is wrong with either of those, and there are many other lines around them that are very similar which it doesn’t complain about.
stdio.h is included in io_harness.h, so I can’t understand why ‘FILE’ is undefined.
Note that I did not alter mpi.h or io_harness.h from the original which compiled with gcc.
I did create gpu.cu, and line 129 is:
cudaMemcpyToSymbol(siteforce_d, &siteforce, sizeof(double*3), 0, cudaMemcpyHostToDevice);
Again there are many almost identical lines surrounding this which it doesn’t complain about.
If I compile the original code (no CUDA) with nvcc it doesn’t complain. If I rename one of the files from .c to .cu, but make no other changes (other than creating a new rule in the Makefile for compiling .cu files, which is the same as the rule for compiling .c as I am using nvcc for both), then it gives the same complaints about the mpi.h, but it didn’t complain about io_harness.h.
I am using CUDA 2.1 beta on RHEL. Any ideas about this would be appreciated.