I have spent hours trying to resolve an error that occurs when compiling example code from a book “Accelerating Matlab with GPC Computing” (Jung W Suh / Youngmin Kim). The error is from example / chapter 2.5.
When compiling the code I receive a notice saying that “fPIC” is required.
You appear to be using a Linux platform. PIC is “position independent code” as used on x64 platforms, that is, your host, not the GPU.
Try adding -Xcompiler -fPIC to the nvcc commandline, to pass the -fPIC flag to the host compiler (gcc). You may want to familiarize yourself with the details of the host tool chain.
Thank you for the note. I undestand the purpose of PIC, unfortunately tho I don’t know how to implement it when compiling in matlab / mex.
As mentioned I have used the example provided in the book “Accelerating Matlab with GPU Computing” to write the following call to compile the code in sample files, but I do not know how to implment or call the fPIC process during the mex compile.
As a novice to this I thought that adding the flag -fPIC to the command would work but it doesn’t. Mex doesn’t recognize it.
So again, would you have any suggestions for how to implement fPIC in the following compile?
then try your mex command as-is. If that doesn’t work, then it would probably be necessary (for me, anyway) to see the full actual example in its entirety). I was really just guessing here anyway.
As an aside, I wouldn’t normally recommend using objects built on an older version of the CUDA toolkit with a newer version. Rebuild those objects (excepting so or dll libraries, possibly, in certain cases).
Thank you each for these suggestions. The process is much clearer now - thanks for pointing out the compile subtleties and distinctions between host and device. The book I was using didn’t express the logic as well as each of you have.