GPU accelerator with hybrid C/C++ code

Dear all,
I’d like to post a general problem related to the usage of GPU accelerator capabiliy of the PGI compiler. In particular I’m wondering if it is possible to compile a GPU-accelerated executable from hybrid C/C++ algorithm.
To be more specific, I wrote a C++ program that contains a loop that I’d like to parallelize on GPU. However, I noticed that the pgCC (and the other c++ compilers) does not accept the -ta flag. Thus, I decided to implement a C routine containing the part that needs parallelization, add the accelerator pragma, compile this file with “pgcc -ta=host,nvidia” and then link the resulting object with all the other ones. However, when I try to link all the objects (with pgCC) I get the errors that are reported at the end of this post. Am I doing somenthing wrong or is it impossible to produce a C/C++ mixed code parallelized for GPU?
Thank you in advance for all the kind answers,

Mirco Zerbetto

  • func.o: In function function.pgi.uni.gpu': /local/home/polimeno/zerbetto/software/jemdi_beta_03/./func.c:23: undefined reference to __pgi_cu_init’
    /local/home/polimeno/zerbetto/software/jemdi_beta_03/./func.c:23: undefined reference to __pgi_cu_module3' /local/home/polimeno/zerbetto/software/jemdi_beta_03/./func.c:23: undefined reference to __pgi_cu_module_function3’
    /local/home/polimeno/zerbetto/software/jemdi_beta_03/./func.c:23: undefined reference to __pgi_cu_module_function3' /local/home/polimeno/zerbetto/software/jemdi_beta_03/./func.c:23: undefined reference to __pgi_cu_alloc_a’
    /local/home/polimeno/zerbetto/software/jemdi_beta_03/./func.c:23: undefined reference to __pgi_cu_uploadx_a' /local/home/polimeno/zerbetto/software/jemdi_beta_03/./func.c:23: undefined reference to __pgi_cu_datadone_a’
    /local/home/polimeno/zerbetto/software/jemdi_beta_03/./func.c:27: undefined reference to __pgi_cu_alloc_t' /local/home/polimeno/zerbetto/software/jemdi_beta_03/./func.c:27: undefined reference to __pgi_cu_uploadc_a’
    /local/home/polimeno/zerbetto/software/jemdi_beta_03/./func.c:27: undefined reference to __pgi_cu_launch_a' /local/home/polimeno/zerbetto/software/jemdi_beta_03/./func.c:27: undefined reference to __pgi_cu_launch_a’
    /local/home/polimeno/zerbetto/software/jemdi_beta_03/./func.c:27: undefined reference to __pgi_cu_downloadc_a' /local/home/polimeno/zerbetto/software/jemdi_beta_03/./func.c:36: undefined reference to __pgi_cu_free_a’
    /local/home/polimeno/zerbetto/software/jemdi_beta_03/./func.c:36: undefined reference to __pgi_cu_free_a' /local/home/polimeno/zerbetto/software/jemdi_beta_03/./func.c:36: undefined reference to __pgi_cu_close’
    func.o: In function function.test': /local/home/polimeno/zerbetto/software/jemdi_beta_03/./func.c:40: undefined reference to __pgi_unified_version_selector8’

Hi Mirco Zerbetto,

I wrote a C++ program that contains a loop that I’d like to parallelize on GPU. However, I noticed that the pgCC (and the other c++ compilers) does not accept the -ta flag

Correct. C++ support for the PGI Accelerator Model and OpenACC is currently expected in 13.x release due late 2012 or early 2013.

Am I doing somenthing wrong or is it impossible to produce a C/C++ mixed code parallelized for GPU?

This error indicates that you are missing the Accelerator libraries. Which compiler are you using to link and what options are you using?

Assuming you are using pgCC to link, you can either add the libraries “-lacc1 -ldl” to your link options or instead link using pgcc with “-ta=host,nvidia” plus the “-pgcpplibs” flags. This will link in both the C++ and Accelerator libraries.

Hope this helps,
Mat

Dear Mat,

thank you so much for your kind help. I was able to compile the code using both your suggestions.

Best regards,

Mirco