Community
cancel
Showing results for 
Search instead for 
Did you mean: 
245 Views

Compiling R packages with dpcpp

Hi,

 

I am currently using Ubuntu 19.10 with the latest version of oneapi installed on it via APT. I can compile my code with it and it works. However, when I want to use -shared option to compile them and create a shared library to include in the R package, I get the following error:

/usr/bin/ld: /tmp/X.o: relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: nonrepresentable section on output
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
 

And that is with all my individual files being compiled with the -fPIC option already. Any ideas I'm missing?

Tags (1)
0 Kudos
14 Replies
AbhishekD_Intel
Moderator
245 Views

Hi,

We got your problem and we are working on it.

Just confirm for us that are you using OneAPI DPC++ Compiler 2021.1-beta05?

-Abhishek

AbhishekD_Intel
Moderator
245 Views

Hi,

If you are using DPCPP from the OneAPI-beta05 toolkit then there is one flag that you skipped while generating a shared library.

First, generate your .o file with dpcpp, Second when you are generating shared library from the .o file use following command:

dpcpp -shared -fPIC -o lib<filename>.so <filename>.o

It will successfully generate lib<filename>.so for you, then you can include it into your R packages.

I hope your problem gets resolved.

-Abhishek

 

245 Views

Thanks a lot, Abhishek! That solved the linking problem. However, now I get another error at a later stage:

  /opt/intel/inteloneapi/mkl/2021.1-beta05/lib/intel64/libmkl_sequential.so: undefined symbol: mkl_graph_mxv_plus_times_fp32_def_i32_i64_i64
 

And the same error holds even if I use TBB instead of Sequential

 

AbhishekD_Intel
Moderator
245 Views

Hi,

Will you please elaborate on the error you are getting, which means you are getting it at compile time or at a time of executing the executable.

It would be great if you show me your compilation steps so that we can easily trace your error.

 

Warm Regards,

Abhishek

245 Views

Here is the output, after compiling all individual  source files:

 

dpcpp -shared -L/opt/microsoft/ropen/3.5.3/lib64/R/lib -fPIC -L/opt/intel/inteloneapi/mkl/2021.1-beta05/lib/intel64 -lmkl_sycl -lmkl_intel_ilp64 -lmkl_core -lmkl_sequential -lsycl -lOpenCL -lpthread -lm -ldl -o ACTIONet.so ACTIONet.o RcppExports.o ACTIONet/misc/my_utils.o ACTIONet/enrichment/enrichment.o ACTIONet/enrichment/pseudobulk.o ACTIONet/enrichment/normalization.o ACTIONet/archetype_unification/unification.o ACTIONet/network_construction/build_network.o ACTIONet/visualization/colorspace.o ACTIONet/visualization/gradient.o ACTIONet/visualization/optimize.o ACTIONet/visualization/layout.o ACTIONet/visualization/sampler.o ACTIONet/decomposition/reduced_kernels.o ACTIONet/decomposition/SVD.o ACTIONet/decomposition/archetype_pruning.o ACTIONet/decomposition/AA.o ACTIONet/decomposition/ACTION.o -L/opt/microsoft/ropen/3.5.3/lib64/R/lib -lR
installing to /home/shahin/R/x86_64-pc-linux-gnu-library/3.5/ACTIONet/libs
** R
** data
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
Error: package or namespace load failed for ‘ACTIONet’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/home/shahin/R/x86_64-pc-linux-gnu-library/3.5/ACTIONet/libs/ACTIONet.so':
  /opt/intel/inteloneapi/mkl/2021.1-beta05/lib/intel64/libmkl_sequential.so: undefined symbol: mkl_graph_mxv_plus_times_fp32_def_i32_i64_i64
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/home/shahin/R/x86_64-pc-linux-gnu-library/3.5/ACTIONet’
* restoring previous ‘/home/shahin/R/x86_64-pc-linux-gnu-library/3.5/ACTIONet’

AbhishekD_Intel
Moderator
245 Views

Hi,

We have also encountered such errors in some of our installations, so in your case, I will suggest you to please check the ACTIONet is correctly installed, sometimes there is also case that the installed package cannot find right repo. So if it is installed properly you can also try specifying the path of you installed libraries to the LD_LIBRARY_PATH again try running those commands.

It should resolve your issue. If you still have the error you can reach us out.

-Abhishek

245 Views

The library I am developing itself is called ACTIONet. " /opt/intel/inteloneapi/mkl/2021.1-beta05/lib/intel64/libmkl_sequential.so: undefined symbol: mkl_graph_mxv_plus_times_fp32_def_i32_i64_i64" to me sound like that the threading library in mkl is using this function and that is defined in another library that is not suggested to be linked by intel link advisor, which is "-L${MKLROOT}/lib/intel64 -lmkl_sycl -lmkl_intel_ilp64 -lmkl_core -lmkl_sequential -lsycl -lOpenCL -lpthread -lm -ldl"

AbhishekD_Intel
Moderator
245 Views

Ok, Is it possible for you to share the source code where you are getting errors so that we can try reproducing it from our end and then we will get back to you.

 

-Abhishek

245 Views

Here is the compressed file with all the code. You can run "R CMD INSTALL ." in the main root folder to compile it. Compile settings are set in src/Makevars

245 Views

Just a quick update: Upon further tracing the issue, it looks like the issue is raised due to a conflict with the mkl_core library already included in MRAN (the version of R I am using to compile the code).

245 Views

Final update: It looks like "mkl_graph_mxv_plus_times_fp32_def_i32_i64_i64" is a new function implementation in mkl_core provided by the oneAPI that has not been in previous versions of MKL. MRAN by default has an older version of MKL that uses while compiling the package. By using static linking instead of dynamic I was able to explicitly incorporate the right library inside and have it compiled.

AbhishekD_Intel
Moderator
245 Views

Hi,

Will you please post your this issue on Intel® oneAPI Math Kernel Library & Intel® Math Kernel Library forum, they will be the best one to guide you on it.

I tried solving this problem, but I may not be the one who will give the exact solution to it, They will definitely solve your problem regarding the conflicts you are facing in mkl_core.

We hope your issue will get resolved as soon as possible.

 

Stay Healthy Stay Safe!

Warm Regards,

Abhishek

AbhishekD_Intel
Moderator
245 Views

Hi,

We hope your issue is resolved.

Will you please confirm if your issue related to this Forum is resolved?

 

Warm Regards,

Abhishek

AbhishekD_Intel
Moderator
245 Views

Hi,

We are closing this thread as your issue is been resolved.

 

Thank You

Reply