Cannot compile example code.

I am trying to compile
pgi/linux86-64/2015/examples/OpenACC/SDK/matrixmul

when i run make I get this error,
mkdir -p …/…/lib
mkdir -p obj/x86_64/release
mkdir -p …/…/bin//release
pgcc -m64 -acc -Minfo=accel -Mcuda -I. -I…/…/include -o obj/x86_64/release/matrixMul.c.o -c matrixMul.c
PGC-F-0206-Can’t find include file stdio.h (…/…/include/timer.h: 15)
PGC/x86-64 Linux 15.10-0: compilation aborted
make: *** [obj/x86_64/release/matrixMul.c.o] Error 2

I followed this thread
https://forums.developer.nvidia.com/t/pgc-f-0206-error/132791/1
but it does not help.

Obviously I am using pgi 15.10
gcc version 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04)

UDA Driver Version: 7050
NVRM version: NVIDIA UNIX x86_64 Kernel Module 352.63 Sat Nov 7 21:25:42 PST 2015
Device Number: 0
Device Name: GeForce GT 525M
Device Revision Number: 2.1

stdio.h is in /usr/include, is it not?

Does gcc find it when you compile the file?

If you look at the verbose ‘dryrun output’

ubuntu1404% pgcc -dryrun -c x.c
Reading rcfile /home/tull/Downloads/pgi1510/linux86-64/15.10/bin/.pgccrc
Reading rcfile /home/tull/Downloads/pgi1510/linux86-64/15.10/bin/nativerc
Reading rcfile /home/tull/Downloads/pgi1510/linux86-64/15.10/bin/fnativerc
Reading rcfile /home/tull/Downloads/pgi1510/linux86-64/15.10/bin/ccrc
Reading rcfile /home/tull/Downloads/pgi1510/linux86-64/15.10/bin/x86rc
Reading rcfile /home/tull/Downloads/pgi1510/linux86-64/15.10/bin/x8664rc
Reading rcfile /home/tull/Downloads/pgi1510/linux86-64/15.10/bin/lin86rc
Reading rcfile /home/tull/Downloads/pgi1510/linux86-64/15.10/bin/lin8664rc
Reading rcfile /home/tull/Downloads/pgi1510/linux86-64/15.10/bin/iparc
Reading rcfile /home/tull/Downloads/pgi1510/linux86-64/15.10/bin/acc1rc
Reading rcfile /home/tull/Downloads/pgi1510/linux86-64/15.10/bin/acclin8664rc
Reading rcfile /home/tull/Downloads/pgi1510/linux86-64/15.10/bin/localrc
Reading rcfile /home/tull/Downloads/pgi1510/linux86-64/15.10/bin/localrc.ubuntu1404
Skipping siterc (not found)
Skipping siterc.ubuntu1404 (not found)
Skipping .mypgirc (not found)
Skipping .mypgccrc (not found)
Skipping $MYLOCALRC (not found)
Export PGI=/home/tull/Downloads/pgi1510

/home/tull/Downloads/pgi1510/linux86-64/15.10/bin/pgc x.c -opt 1 -terse 1 -inform warn -x 119 0xa10000 -x 122 0x40 -x 123 0x1000 -x 127 4 -x 127 17 -x 19 0x400000 -x 28 0x40000 -x 120 0x10000000 -x 70 0x8000 -x 122 1 -x 125 0x20000 -x 117 0x1000 -quad -x 59 4 -tp nehalem -x 120 0x1000 -astype 0 -stdinc /home/tull/Downloads/pgi1510/linux86-64/15.10/include-gcc48:/home/tull/Downloads/pgi1510/linux86-64/15.10/include:/usr/lib/gcc/x86_64-linux-gnu/4.8/include:/usr/local/include:/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed:/usr/include/x86_64-linux-gnu:/usr/include -def unix -def __unix -def unix -def linux -def __linux -def linux -def __NO_MATH_INLINES -def LP64 -def __x86_64 -def x86_64 -def LONG_MAX=9223372036854775807L -def ‘SIZE_TYPE=unsigned long int’ -def ‘PTRDIFF_TYPE=long int’ -def __THROW= -def extension= -def amd_64__amd64 -def __k8 -def k8 -def SSE -def MMX -def SSE2 -def SSE3 -def SSSE3 -def STDC_HOSTED -predicate ‘#machine(x86_64) #lint(off) #system(posix) #cpu(x86_64)’ -x 123 0x80000000 -x 123 4 -x 2 0x400 -x 119 0x20 -def __pgnu_vsn=40801 -alwaysinline /home/tull/Downloads/pgi1510/linux86-64/15.10/lib/libintrinsics.il 4 -x 120 0x200000 -x 70 0x40000000 -y 163 0xc0000000 -x 189 0x10 -y 189 0x4000000 -x 198 0x40000 -asm x.s

you can see /usr/include is part of the include paths when you compile from source.

-stdinc /home/tull/Downloads/pgi1510/linux86-64/15.10/include-gcc48:/home/tull/Downloads/pgi1510/linux86-64/15.10/include:/usr/lib/gcc/x86_64-linux-gnu/4.8/include:/usr/local/include:/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed:/usr/include/x86_64-linux-gnu:/usr/include
^^^^^^^^

Look at

pgcc -E foo.c >& foo.i

gcc -E foo.c >& foo_gcc.i

and look at the resulting preprocessed files and see if they
can find stdio.h.


dave

Thank you, for quick response.

As you mentioned, I ran the command
pgcc -dryrun matrixMul.c and got the following output

==============================================================
Reading rcfile /home/ik/documents/pgi/linux86-64/15.10/bin/.pgccrc
Reading rcfile /home/ik/documents/pgi/linux86-64/15.10/bin/nativerc
Reading rcfile /home/ik/documents/pgi/linux86-64/15.10/bin/fnativerc
Reading rcfile /home/ik/documents/pgi/linux86-64/15.10/bin/ccrc
Reading rcfile /home/ik/documents/pgi/linux86-64/15.10/bin/x86rc
Reading rcfile /home/ik/documents/pgi/linux86-64/15.10/bin/x8664rc
Reading rcfile /home/ik/documents/pgi/linux86-64/15.10/bin/lin86rc
Reading rcfile /home/ik/documents/pgi/linux86-64/15.10/bin/lin8664rc
Reading rcfile /home/ik/documents/pgi/linux86-64/15.10/bin/iparc
Reading rcfile /home/ik/documents/pgi/linux86-64/15.10/bin/acc1rc
Reading rcfile /home/ik/documents/pgi/linux86-64/15.10/bin/acclin8664rc
Reading rcfile /home/ik/documents/pgi/linux86-64/15.10/bin/localrc
Skipping localrc.Dell-XPS (not found)
Reading rcfile /home/ik/documents/pgi/linux86-64/15.10/bin/siterc
Skipping siterc.Dell-XPS (not found)
Skipping .mypgirc (not found)
Skipping .mypgccrc (not found)
Skipping $MYLOCALRC (not found)
Export PGI=/home/ik/documents/pgi

/home/ik/documents/pgi/linux86-64/15.10/bin/pgc matrixMul.c -opt 1 -terse 1 -inform warn -x 119 0xa10000 -x 122 0x40 -x 123 0x1000 -x 127 4 -x 127 17 -x 19 0x400000 -x 28 0x40000 -x 120 0x10000000 -x 70 0x8000 -x 122 1 -x 125 0x20000 -x 117 0x1000 -quad -x 59 4 -tp sandybridge -x 120 0x1000 -astype 0 -stdinc /home/ik/documents/pgi/linux86-64/15.10/include-gcc48:/home/ik/documents/pgi/linux86-64/15.10/include:/usr/lib/gcc/x86_64-linux-gnu/4.8/include:/usr/local/include:/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed:/usr/include/x86_64-linux-gnu:/usr/include -def unix -def __unix -def unix -def linux -def __linux -def linux -def __NO_MATH_INLINES -def LP64 -def __x86_64 -def x86_64 -def LONG_MAX=9223372036854775807L -def ‘SIZE_TYPE=unsigned long int’ -def ‘PTRDIFF_TYPE=long int’ -def __THROW= -def extension= -def amd_64__amd64 -def __k8 -def k8 -def SSE -def MMX -def SSE2 -def SSE3 -def SSSE3 -def STDC_HOSTED -predicate ‘#machine(x86_64) #lint(off) #system(posix) #cpu(x86_64)’ -x 123 0x80000000 -x 123 4 -x 2 0x400 -x 119 0x20 -def __pgnu_vsn=40801 -alwaysinline /home/ik/documents/pgi/linux86-64/15.10/lib/libintrinsics.il 4 -x 120 0x200000 -x 70 0x40000000 -y 163 0xc0000000 -x 189 0x10 -y 189 0x4000000 -x 198 0x40000 -asm matrixMul.s

/usr/bin/as matrixMul.s -o matrixMul.o

/usr/bin/ld /usr/lib/x86_64-linux-gnu/crt1.o /usr/lib/x86_64-linux-gnu/crti.o /home/ik/documents/pgi/linux86-64/15.10/lib/trace_init.o /usr/lib/gcc/x86_64-linux-gnu/4.8/crtbegin.o /home/ik/documents/pgi/linux86-64/15.10/lib/initmp.o --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 /home/ik/documents/pgi/linux86-64/15.10/lib/pgi.ld -L/home/ik/documents/pgi/linux86-64/15.10/lib -L/usr/lib64 -L/usr/lib/gcc/x86_64-linux-gnu/4.8 matrixMul.o -rpath /home/ik/documents/pgi/linux86-64/15.10/lib -lpgmp -lnuma -lpthread -lnspgc -lpgc -lm -lgcc -lc -lgcc /usr/lib/gcc/x86_64-linux-gnu/4.8/crtend.o /usr/lib/x86_64-linux-gnu/crtn.o

you can see that pgcc is trying to look into /usr/include for stdio.h

I also ran both the compilers with -E flags on a simple hello world program
pgcc -E helloworld.c >& phell.i
gcc -E helloworld.c >& hell.i

both the preprocessed files(phell.i and hell.i) show entries for stdio.h

I tried adding a extra flag in pgi/linux86-64/2015/examples/OpenACC/SDK/common/common.mk
INCLUDES += -I. -I$(INCDIR) -I/usr/include

but this gives me another error

=================================================================
mkdir -p …/…/lib
mkdir -p obj/x86_64/release
mkdir -p …/…/bin//release
pgcc -m64 -acc -Minfo=accel -Mcuda -I. -I…/…/include -I/usr/include -o obj/x86_64/release/matrixMul.c.o -c matrixMul.c
PGC-F-0206-Can’t find include file stddef.h (/home/ik/documents/pgi/linux86-64/15.10/include-gcc48/stddef.h: 16)
PGC/x86-64 Linux 15.10-0: compilation aborted
make: *** [obj/x86_64/release/matrixMul.c.o] Error 2

I tried locating the file stddef.h it is present in /usr/include/linux/ folder

The PGI header files either replace the Linux header file,
or the augment by using #include_next headerfile_name
in the PGI version of the header. This causes the preprocessor
to look through the subsequent include directories for the same
named header.

In either case it is important that the PGI header files get read first,
so the include directory order is very important.



Is there a stdio.h in /usr/include? Is that the file gcc finds,
or is stdio.h found in another directory? The preprocessed files should
indicate where the header file found the file.

The goal here is to use the same stdio.h that gcc uses when compiling
with pgcc.

dave

Sorry, for the delayed reply.

I am still unable to compile the sample codes. I have given up on them. So, I decided to write my own small code and try and run them. To my surprise they are running well and good. So, far I have done matrix multiplication and vector addition and they are operational.

If some one encounters this (sample code compilation) error, they will post a solution.

I just installed 64-bit 15.10 on Ubuntu 1404, and went into the examples
directory

ubuntu1404% pwd
/home/tull/Downloads/pgi1510/linux86-64/2015/examples
ubuntu1404% ls
AutoPar/ CUDA-Fortran/ CUDA-Libraries/ CUDA-x86-SDK/ F2003/ MPI/ OpenACC/ OpenMP/ README
ubuntu1404% cd OpenACC
ubuntu1404% ls
SDK/ samples/
ubuntu1404% cd SDK
ubuntu1404% ls
Makefile bin/ common/ include/ lib/ src/
ubuntu1404% cd common
ubuntu1404% make clean
find . | egrep “#” | xargs rm -f
find . | egrep “~” | xargs rm -f
rm -f obj/x86_64/release/device_helper.cpp.o obj/x86_64/release/common.c.o obj/x86_64/release/argproc.c.o
rm -f ./…/lib/libcommon_x86_64.a
rm -f ./…/bin//release/.ppm
rm -f ./…/bin//release/
.pgm
rm -f ./…/bin//release/.bin
rm -f ./…/bin//release/
.bmp
rm -f ./…/bin//release/.pdb
rm -f ./…/bin//release/
.dwf
ubuntu1404% make
mkdir -p ./…/lib
mkdir -p obj/x86_64/release
mkdir -p ./…/lib
pgc++ -m64 -acc -Minfo=accel -Mcuda -I. -I./…/include -o obj/x86_64/release/device_helper.cpp.o -c device_helper.cpp
pgcc -m64 -acc -Minfo=accel -Mcuda -I. -I./…/include -o obj/x86_64/release/common.c.o -c common.c
pgcc -m64 -acc -Minfo=accel -Mcuda -I. -I./…/include -o obj/x86_64/release/argproc.c.o -c argproc.c
ar rucv ./…/lib/libcommon_x86_64.a obj/x86_64/release/device_helper.cpp.o obj/x86_64/release/common.c.o obj/x86_64/release/argp
a - obj/x86_64/release/device_helper.cpp.o
a - obj/x86_64/release/common.c.o
a - obj/x86_64/release/argproc.c.o
ubuntu1404% cd …
ubuntu1404% ls
Makefile bin/ common/ include/ lib/ src/
ubuntu1404% cd src
ubuntu1404% ls
FDTD3d/ asyncAPI/ blackscholes/ histogram/ reduction/ simpleCUBLAS/ template/ v
MonteCarloMultiGPU/ bandwidthTest/ cppIntegration/ matrixMul/ scalarProd/ simpleMultiGPU/ transpose/
alignedTypes/ bilateralFilter/ deviceQuery/ quasirandomGenerator/ seismic_cpml/ simpleTemplates/ transposeNew/
ubuntu1404% cd matrixMul
ubuntu1404% ls
Makefile matrixMul.c matrixMul.h obj/
ubuntu1404% make clean
find . | egrep “#” | xargs rm -f
find . | egrep “~” | xargs rm -f
rm -f obj/x86_64/release/matrixMul.c.o
rm -f …/…/bin//release/matrixMul
rm -f …/…/bin//release/.ppm
rm -f …/…/bin//release/
.pgm
rm -f …/…/bin//release/.bin
rm -f …/…/bin//release/
.bmp
rm -f …/…/bin//release/.pdb
rm -f …/…/bin//release/
.dwf
ubuntu1404% make
mkdir -p …/…/lib
mkdir -p obj/x86_64/release
mkdir -p …/…/bin//release
pgcc -m64 -acc -Minfo=accel -Mcuda -I. -I…/…/include -o obj/x86_64/release/matrixMul.c.o -c matrixMul.c
matrixMulGPU:
47, Generating enter data copyin(B[:wAwB],A[:wAhA])
48, Generating enter data create(C[:hAwB])
50, Generating present(A[:wA
hA],B[:wAwB],C[:hAwB])
53, Loop is parallelizable
55, Loop is parallelizable
Accelerator kernel generated
Generating Tesla code
53, #pragma acc loop gang /* blockIdx.y /
55, #pragma acc loop gang, vector(128) /
blockIdx.x threadIdx.x /
59, Loop is parallelizable
69, Generating exit data copyout(C[:hA
wB])
70, Generating exit data delete(B[:wAwB],A[:wAhA])
pgc++ -pgf90libs -acc -Minfo=accel -Mcuda -L…/…/lib -m64 -o …/…/bin//release/matrixMul obj/x86_64/release/matrixMul.c.o 4


I did not have to change anything to make this work.