diff mbox

[3/4] Add libgomp plugin for Intel MIC

Message ID 878uaq68fn.fsf@kepler.schwinge.homeip.net
State New
Headers show

Commit Message

Thomas Schwinge July 8, 2015, 2:16 p.m. UTC
Hi!

On Tue, 21 Oct 2014 21:24:13 +0400, Ilya Verbin <iverbin@gmail.com> wrote:
> This patch contains a plugin for libgomp and appropriate changes for makefiles.
> 
> The plugin uses liboffloadmic_host.so to interact with the device (or with an
> emulator).  Also the patch contains offload_target_main executable, which is the
> corresponding target side part of a libgomp plugin, and it uses
> liboffloadmic_target.so.
> 
> The plugin builds automatically with liboffloadmic.

With recent GCC trunk sources, builds of the Intel MIC Offload Plugin
fail as follows:

    libtool: compile:  [...]/build-gcc/./gcc/xg++ [...] -I[...]/install/offload-x86_64-intelmicemul-linux-gnu/x86_64-intelmicemul-linux-gnu/liboffloadmic/plugin -I[...]/install/offload-x86_64-intelmicemul-linux-gnu/lib/gcc/x86_64-intelmicemul-linux-gnu/6.0.0/include -c [...]/source-gcc/liboffloadmic/plugin/libgomp-plugin-intelmic.cpp  -fPIC -DPIC -o .libs/libgomp_plugin_intelmic_la-libgomp-plugin-intelmic.o
    In file included from [...]/source-gcc/liboffloadmic/plugin/libgomp-plugin-intelmic.cpp:40:0:
    [...]/install/offload-x86_64-intelmicemul-linux-gnu/lib/gcc/x86_64-intelmicemul-linux-gnu/6.0.0/include/main_target_image.h:8628:1: error: narrowing conversion of '192' from 'int' to 'char' inside { } [-Wnarrowing]
     };
     ^
    [...]/install/offload-x86_64-intelmicemul-linux-gnu/lib/gcc/x86_64-intelmicemul-linux-gnu/6.0.0/include/main_target_image.h:8628:1: error: narrowing conversion of '192' from 'int' to 'char' inside { } [-Wnarrowing]
    [...]/install/offload-x86_64-intelmicemul-linux-gnu/lib/gcc/x86_64-intelmicemul-linux-gnu/6.0.0/include/main_target_image.h:8628:1: error: narrowing conversion of '164' from 'int' to 'char' inside { } [-Wnarrowing]
    [many more]

Apart from the actual compilation error, it is surprising for me to see
the GCC build reference/depend on the Intel MIC offloading compiler's
installation directory (which I built and installed earlier),
[...]/install/offload-x86_64-intelmicemul-linux-gnu/ -- is that the
correct thing to do?  Shouldn't the GCC build be self-contained?  (I have
not yet made an attempt to understand how the target and device
liboffloadmic builds work together.)

This main_target_image.h file is coming from here:

> --- /dev/null
> +++ b/liboffloadmic/plugin/Makefile.am
> @@ -0,0 +1,123 @@
> +# Plugin for offload execution on Intel MIC devices.

> +main_target_image.h: offload_target_main
> +	@echo -n "const int image_size = " > $@
> +	@stat -c '%s' $< >> $@
> +	@echo ";" >> $@
> +	@echo "struct MainTargetImage {" >> $@
> +	@echo "  int64_t size;" >> $@
> +	@echo "  char name[sizeof \"offload_target_main\"];" >> $@
> +	@echo "  char data[image_size];" >> $@
> +	@echo "};" >> $@
> +	@echo "extern \"C\" const MainTargetImage main_target_image = {" >> $@
> +	@echo "  image_size, \"offload_target_main\"," >> $@
> +	@cat $< | xxd -include >> $@
> +	@echo "};" >> $@
> +
> +offload_target_main: $(liboffload_dir)/ofldbegin.o offload_target_main.o $(liboffload_dir)/ofldend.o
> +	$(CXX) $(AM_LDFLAGS) $^ -o $@
> +
> +offload_target_main.o: offload_target_main.cpp
> +	$(CXX) $(AM_CXXFLAGS) $(AM_CPPFLAGS) -c $< -o $@

Here, I note that the xxd tool is being used, which in my distribution is
part of the Vim editor's package, which -- as far as I know -- is not
currently declared as a build dependency of GCC?

Anyway, all that aside for the moment -- OK to commit the following?



Grüße,
 Thomas

Comments

Ilya Verbin July 8, 2015, 3:13 p.m. UTC | #1
> On 8 июля 2015 г., at 17:16, Thomas Schwinge <thomas@codesourcery.com> wrote:
> 
> Hi!
> 
>> On Tue, 21 Oct 2014 21:24:13 +0400, Ilya Verbin <iverbin@gmail.com> wrote:
>> This patch contains a plugin for libgomp and appropriate changes for makefiles.
>> 
>> The plugin uses liboffloadmic_host.so to interact with the device (or with an
>> emulator).  Also the patch contains offload_target_main executable, which is the
>> corresponding target side part of a libgomp plugin, and it uses
>> liboffloadmic_target.so.
>> 
>> The plugin builds automatically with liboffloadmic.
> 
> With recent GCC trunk sources, builds of the Intel MIC Offload Plugin
> fail as follows:
> 
>    libtool: compile:  [...]/build-gcc/./gcc/xg++ [...] -I[...]/install/offload-x86_64-intelmicemul-linux-gnu/x86_64-intelmicemul-linux-gnu/liboffloadmic/plugin -I[...]/install/offload-x86_64-intelmicemul-linux-gnu/lib/gcc/x86_64-intelmicemul-linux-gnu/6.0.0/include -c [...]/source-gcc/liboffloadmic/plugin/libgomp-plugin-intelmic.cpp  -fPIC -DPIC -o .libs/libgomp_plugin_intelmic_la-libgomp-plugin-intelmic.o
>    In file included from [...]/source-gcc/liboffloadmic/plugin/libgomp-plugin-intelmic.cpp:40:0:
>    [...]/install/offload-x86_64-intelmicemul-linux-gnu/lib/gcc/x86_64-intelmicemul-linux-gnu/6.0.0/include/main_target_image.h:8628:1: error: narrowing conversion of '192' from 'int' to 'char' inside { } [-Wnarrowing]
>     };
>     ^
>    [...]/install/offload-x86_64-intelmicemul-linux-gnu/lib/gcc/x86_64-intelmicemul-linux-gnu/6.0.0/include/main_target_image.h:8628:1: error: narrowing conversion of '192' from 'int' to 'char' inside { } [-Wnarrowing]
>    [...]/install/offload-x86_64-intelmicemul-linux-gnu/lib/gcc/x86_64-intelmicemul-linux-gnu/6.0.0/include/main_target_image.h:8628:1: error: narrowing conversion of '164' from 'int' to 'char' inside { } [-Wnarrowing]
>    [many more]
> 
> Apart from the actual compilation error, it is surprising for me to see
> the GCC build reference/depend on the Intel MIC offloading compiler's
> installation directory (which I built and installed earlier),
> [...]/install/offload-x86_64-intelmicemul-linux-gnu/ -- is that the
> correct thing to do?  Shouldn't the GCC build be self-contained?  (I have
> not yet made an attempt to understand how the target and device
> liboffloadmic builds work together.)
> 
> This main_target_image.h file is coming from here:
> 
>> --- /dev/null
>> +++ b/liboffloadmic/plugin/Makefile.am
>> @@ -0,0 +1,123 @@
>> +# Plugin for offload execution on Intel MIC devices.
> 
>> +main_target_image.h: offload_target_main
>> +    @echo -n "const int image_size = " > $@
>> +    @stat -c '%s' $< >> $@
>> +    @echo ";" >> $@
>> +    @echo "struct MainTargetImage {" >> $@
>> +    @echo "  int64_t size;" >> $@
>> +    @echo "  char name[sizeof \"offload_target_main\"];" >> $@
>> +    @echo "  char data[image_size];" >> $@
>> +    @echo "};" >> $@
>> +    @echo "extern \"C\" const MainTargetImage main_target_image = {" >> $@
>> +    @echo "  image_size, \"offload_target_main\"," >> $@
>> +    @cat $< | xxd -include >> $@
>> +    @echo "};" >> $@
>> +
>> +offload_target_main: $(liboffload_dir)/ofldbegin.o offload_target_main.o $(liboffload_dir)/ofldend.o
>> +    $(CXX) $(AM_LDFLAGS) $^ -o $@
>> +
>> +offload_target_main.o: offload_target_main.cpp
>> +    $(CXX) $(AM_CXXFLAGS) $(AM_CPPFLAGS) -c $< -o $@
> 
> Here, I note that the xxd tool is being used, which in my distribution is
> part of the Vim editor's package, which -- as far as I know -- is not
> currently declared as a build dependency of GCC?
> 
> Anyway, all that aside for the moment -- OK to commit the following?
> 
> --- liboffloadmic/plugin/Makefile.am
> +++ liboffloadmic/plugin/Makefile.am
> @@ -69,7 +69,7 @@ main_target_image.h: offload_target_main
>    @echo "struct MainTargetImage {" >> $@
>    @echo "  int64_t size;" >> $@
>    @echo "  char name[sizeof \"offload_target_main\"];" >> $@
> -    @echo "  char data[image_size];" >> $@
> +    @echo "  uint8_t data[image_size];" >> $@
>    @echo "};" >> $@
>    @echo "extern \"C\" const MainTargetImage main_target_image = {" >> $@
>    @echo "  image_size, \"offload_target_main\"," >> $@
> 
> 
> Grüße,
> Thomas

Ok to me, thanks.

The plugin consists of 2 parts: offload_target_main is a target part, which is embedded into the host part (libgomp plugin itself). Target part is linked with liboffloadmic_target.so and host part is linked with liboffloadmic_host.so. Both offload_target_main and liboffloadmic_target.so are compiled by the target compiler during its build.

As for xxd, I've found its usage in some Makefile inside gcc tree, so I thought it's ok to use it.

  -- Ilya
diff mbox

Patch

--- liboffloadmic/plugin/Makefile.am
+++ liboffloadmic/plugin/Makefile.am
@@ -69,7 +69,7 @@  main_target_image.h: offload_target_main
 	@echo "struct MainTargetImage {" >> $@
 	@echo "  int64_t size;" >> $@
 	@echo "  char name[sizeof \"offload_target_main\"];" >> $@
-	@echo "  char data[image_size];" >> $@
+	@echo "  uint8_t data[image_size];" >> $@
 	@echo "};" >> $@
 	@echo "extern \"C\" const MainTargetImage main_target_image = {" >> $@
 	@echo "  image_size, \"offload_target_main\"," >> $@