PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

Free OpenACC Webinar

Failed to create a shared library .so

 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Accelerator Programming
View previous topic :: View next topic  
Author Message
dima_tr



Joined: 21 Oct 2009
Posts: 3

PostPosted: Wed Oct 21, 2009 5:42 am    Post subject: Failed to create a shared library .so Reply with quote

I've been struggling with creation of .so from a simple C code containing Acceleration part. The software I work on uses a plugin approach, so I highly rely on shared library loading mechanism.

The builds were performed on Ubuntu 9.04 x64 with latest updates, using PGI 9.0.4.

====== test.c ======
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char** argv) {
float a[1000];

#pragma acc region
{
for (int i = 0; i < 1000; i++) {
a[i] = i+2;
}
}
return (EXIT_SUCCESS);
}
================

pgcc -shared -o sample.so -ta=nvidia -Minfo test.c


Compilation went fine, the block has been accelerated, kernel created successfully, but on the link time I've got an error:

tester@ubuntu:~/work/test$ pgcc -shared -ta=nvidia -Minfo -o test.so empty.c
main:
17, Generating copyout(a[0:999])
19, Loop is parallelizable
Accelerator kernel generated
19, #pragma for parallel, vector(256)
/usr/bin/ld: /opt/pgi/linux86-64/9.0-4/lib/libacc1.a(nvalloc.o): relocation R_X86_64_32S against `a local symbol' can not be used when making a shared object; recompile with -fPIC
/opt/pgi/linux86-64/9.0-4/lib/libacc1.a: could not read symbols: Bad value



There's no error when I produce an executable from the same code.

pgcc -o sample -ta=nvidia -Minfo test.c



I've tried a number of different ways: introduced -fpic (-fPIC), tried -mcmodel=small or mcmodel=medium, tried explicit linking with libacc1.a and the other static libs (libacc1.a is the only library containing the need CUDA methods). Nothing helped.

At the very moment I use a workaround: compile a static library, which is then linked inside my main executable together with libacc1.a and other necessary static libs. Not what I need, but at least this works.


1) Is it by design that it is not possible to create shared libraries with an acceleration code inside? (hopefully not)

2) What would be the way out? Can you please recompile libacc1.a with -fPIC as it is suggested (the best solution for me)? Can you alternatively produce libacc1.so, so the linker will be happy to live with it?

3) any other working solution will be greatly appreciated.


Thank you for your help and a very great product!

kind regards
Dimitri
Back to top
View user's profile
mkcolg



Joined: 30 Jun 2004
Posts: 6215
Location: The Portland Group Inc.

PostPosted: Wed Oct 21, 2009 9:27 am    Post subject: Reply with quote

Hi Dimitri,

We should have "-fpic" compiled pgacc libraries (located under the libso directory) available with the upcoming 10.0 release.

Thanks,
Mat
Back to top
View user's profile
dima_tr



Joined: 21 Oct 2009
Posts: 3

PostPosted: Thu Oct 22, 2009 12:51 am    Post subject: Reply with quote

Hi Mat,

thank you for the clarification. Looking forward the coming release!

kind regards
Dimitri
Back to top
View user's profile
dima_tr



Joined: 21 Oct 2009
Posts: 3

PostPosted: Tue Dec 08, 2009 6:17 am    Post subject: Reply with quote

Sorry to say, but I still have this error with Linux x64 PGI Workstation 10.0.
I'm on Ubuntu 9.10, x64.

Explicit linking of gcc with any of the static libraries libacc1*.a give an error with about the same complaint. These libraries are the only one containing acc_init() symbol, thus one of them must be used.


<.. compiling .o files - everything is fine.. >

pgcc -ta=nvidia -noswitcherror -shared -o dist/Linux/PGI-Linux-x86/libwhelper.so -fPIC build/Linux/PGI-Linux-x86/forces.o build/Linux/PGI-Linux-x86/shiftCells.o
/usr/bin/ld: /opt/pgi/linux86-64/10.0/lib/libacc1.a(nvalloc.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
/opt/pgi/linux86-64/10.0/lib/libacc1.a: could not read symbols: Bad value

Thank you for your help.

regards
Dimitri
Back to top
View user's profile
mkcolg



Joined: 30 Jun 2004
Posts: 6215
Location: The Portland Group Inc.

PostPosted: Tue Dec 08, 2009 4:46 pm    Post subject: Reply with quote

Hi Dimitri,

Sorry about that. Our engineer's ran into some issue that prevented the inclusion of -fpic compiled versions of these libraries with 10.0. They are working on it, though.

I'll update this post once I see that they are there. You can also send a note to trs@pgroup.com and ask to be added the notification list for TPR#16251.

- Mat
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    PGI User Forum Forum Index -> Accelerator Programming All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © phpBB Group