[Openmp-dev] Using clang-offload-bundler to bundle application/executable

Doerfert, Johannes via Openmp-dev openmp-dev at lists.llvm.org
Sun Nov 3 22:26:15 PST 2019


Hi Lukas,

I did not really follow the recent changes so I cannot really help.

 @Sergey @Alexey @Jon @Hal, could any of you comment on this use case/problem please?

Thanks,
  Johannes

________________________________________
From: Openmp-dev <openmp-dev-bounces at lists.llvm.org> on behalf of Lukas Sommer via Openmp-dev <openmp-dev at lists.llvm.org>
Sent: Monday, October 28, 2019 07:42
To: openmp-dev at lists.llvm.org
Subject: [Openmp-dev] Using clang-offload-bundler to bundle     application/executable

Hello,

I'm trying to use the clang-offload-bundler to merge the results of the
compilation for device and host for an application using OpenMP target
pragmas.

My goal is to run a custom pass on the device code and then bundle an
application from the modified device code and the host code. For testing
purposes, I use a very simple vector addition with target offloading
pragmas and the "offloading" to x86_64 (LLVM/Clang release 9.0).

I use clang to generate LLVM IR from the application code. Then I use
the clang-offload-bundler to unbundle the LLVM IR for device and host. I
run opt and llc separately on the LLVM IR for host and device.

To this end, on my application code (code.c), I run the following steps:

> clang -fopenmp -fopenmp-targets=x86_64-unknown-linux-gnu -S -emit-llvm
> -O3 -o bundled.ll code.c
> clang-offload-bundler --inputs=bundled.ll
> --outputs=host.in.ll,device.in.ll
> --targets=host-x86_64-unknown-linux-gnu,openmp-x86_64-unknown-linux-gnu
> --type=ll --unbundle
> opt -o host.opt.ll -O3 host.in.ll
> llc -o host.o -filetype=obj host.opt.ll
> opt -o device.opt.ll -O3 device.in.ll (custom pass should be added
> here later on)
> llc -o device.o -filetype=obj device.opt.ll

Afterwards, I tried to bundle the object files for host & device:

> clang-offload-bundler --inputs=host.o,device.o --outputs=app.o
> --targets=host-x86_64-unknown-linux-gnu,openmp-x86_64-unknown-linux-gnu
> --type=o
This command completes without any warning or error.

I tried to invoke gcc on the output to generate the executable from the
object file (app.o):

> gcc app.o -lomp -lomptarget
However, I get the following error:

> /usr/bin/ld:
> app.o:(.rodata..omp_offloading.device_images[.omp_offloading.descriptor_reg.x86_64-unknown-linux-gnu]+0x10):
> undefined reference to `.omp_offloading.entries_begin'
> /usr/bin/ld:
> app.o:(.rodata..omp_offloading.device_images[.omp_offloading.descriptor_reg.x86_64-unknown-linux-gnu]+0x18):
> undefined reference to `.omp_offloading.entries_end'
> /usr/bin/ld:
> app.o:(.rodata..omp_offloading.descriptor[.omp_offloading.descriptor_reg.x86_64-unknown-linux-gnu]+0x10):
> undefined reference to `.omp_offloading.entries_begin'
> /usr/bin/ld:
> app.o:(.rodata..omp_offloading.descriptor[.omp_offloading.descriptor_reg.x86_64-unknown-linux-gnu]+0x18):
> undefined reference to `.omp_offloading.entries_end'
Do I need to run any additional steps before going through gcc or pass
additional flags? Is there another way of accomplishing the desired
behavior?

Thanks a lot in advance,

Best regards

Lukas

--
Lukas Sommer, M.Sc.
TU Darmstadt
Embedded Systems and Applications Group (ESA)
Hochschulstr. 10, 64289 Darmstadt, Germany
Phone: +49 6151 1622429
www.esa.informatik.tu-darmstadt.de


_______________________________________________
Openmp-dev mailing list
Openmp-dev at lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/openmp-dev


More information about the Openmp-dev mailing list