Skip to content

[SYCL] Configure ARM cross-compilation - #233

Merged
lukeiwanski merged 1 commit into
lukeiwanski:dev/amd_gpufrom
Rbiessy:feature/cross-compilation-amd
Apr 17, 2018
Merged

lukeiwanski merged 1 commit into
lukeiwanski:dev/amd_gpufrom
Rbiessy:feature/cross-compilation-amd

Conversation

@Rbiessy

@Rbiessy Rbiessy commented Apr 17, 2018

Copy link
Copy Markdown
Collaborator

Need more tests on AMD first.

cxx_flag: "-std=c++11"
linker_flag: "-Wl,-no-as-needed"
linker_flag: "-lstdc++"
linker_flag: "-B/usr/bin/"

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's needed.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stuff moved but everything should be there now!

@lukeiwanski

Copy link
Copy Markdown
Owner

Overall great work @Rbiessy && @DuncanMcBain !
We might want to add -no-serial-memop as the compiler is noisy about it.

Co-authored-by: John Lawson <[email protected]>
Co-authored-by: Duncan McBain <[email protected]>

Moved ACL config from configure.py to bazel.rc, matching previous TensorFlow upstream changes. Fixes ACL build. (#6)

First steps to cross compilation

Removed some things that are not needed, started adding definitions
for arm toolchains. computecpp.tpl script is next and needs to be aware
of compiling for the host.

Add correct flags to crosstool

Add temporary compiler hack

Fix broken cxx_flags in crosstool

Fixup Aarch64 toolchain components

Add BUILD.tpl entry for arm cross compiler

Target arm32 with correct directories

Further improvements to the crosscompile toolchain

Now there is a templated bash script that sets the target, gcc-toolchain
and sysroot for compute (the c-like compute++). This means that we no
longer need the version flag, as clang will basically work it out for
us. Similarly, all the builtin directories and include lines have been
removed from the CROSSTOOL as they're not needed any more!

This successfully compiles the host and device objects, but fails to link
because it is not aware that two libComputeCpp.so files are needed - one
for host, and one for device.

Change where ComputeCpp is linked

Now we don't need a host copy of libComputeCpp.so, which makes sense,
as it is only used on the target.

Remove host compiler check in configure script

Fix build config for bazel 0.9.1

Remove compute-script from SYCL config

Using compiler_flag and linker_flag means that C files can see the
target we are using, so the custom compute-script is no longer needed.
This has simplified things considerably!

Add dependency on syclrt to GRU and LSTM ops

Removed unneeded code.

Set the same build options for both local and cross-build, as much as possible.

Added host_crosstool_top to the SYCL lines of tools/bazel.rc, and tidied it up a bit.

Renamed ARM_BITCODE_TARGET to BITCODE_TARGET.

Fixed build flags from my previous changes.

Fix core kernel tests not building

The kernels didn't have a dependency on the SYCL runtime, which has now
been added (hidden behind the if_sycl function).

Only prompt user for CROSS_TOOLCHAIN if needed

Previously, the sycl_configure file would complain if the env variables
for the cross toolchain couldn't be found - now, it will only ask about
them if the environment variable "CROSS_TOOLCHAIN" is present,
indicating that the user wants to crosscompile TensorFlow + SYCL. The
names have been updated to indicate that the crosscompiling is flexible
enough to work with other GCC-like toolchains, should the need ever
arise.

Fix autodetection of crosscompilation

It now checks the environment in the correct way to see if the user
wishes to crosscompile.

Add Khronos OpenCL loader bazel configuration

ComputeCpp depends on the OpenCL library to communicate with hardware.
Previously, the OpenCL symbols were being resolved dynamically, which
worked well for the Tensorflow wheel, but doesn't for the tests. This
commit adds a minimal bazel configuration for the OpenCL ICD loader
from Khronos and the OpenCL headers, then sets up the dependencies,
such that ComputeCpp depends on the loader, which in turn depends on
the headers. This is more robust as it means that the build depends
less on how the building system is configured.

Improve OpenCL bazel configuration

OpenCL is now a cc_library, meaning that all the kernel tests are linked
against its bits statically. It also uses the exports map from the ICD
repo to indicate versions of the files within it, so should be
compatible with ICD loaders from other vendors. The headers are no
longer an inc_library, as bazel authors indicate that this is not a
useful rule, and library seems to suffice for this case. As of now, the
bazel config will build all tests and the pip package!

[SYCL] Changes SYCL data types configuration (#217)

Set the required flags to disable certain data types for SYCL in the
configure script, directly setting cxxopts in the bazelrc. This means
that these flags are provided without having to set them in the
compiler script.

Fix bad merge to fix configuration of build

Add syclrt dependency to conv_op test

Move syclrt dependency

Clean OpenCL headers

[SYCL] Add SYCL bitcode configure option

Add a configure time option to specify the SYCL target bitcode to pass
to ComputeCpp. By default this is spir64 for AMD devices, but it can be
changed to match the actual device to compiler for.

Note: There is no check to ensure that the target is supported by
ComputeCpp, nor is there a check to ensure that the traget matches the
device.
@Rbiessy

Rbiessy commented Apr 17, 2018

Copy link
Copy Markdown
Collaborator Author

Thanks! Yes I am adding it on the command line. I'm just not sure if we always want this option? I don't mind adding it if you want.

@lukeiwanski

Copy link
Copy Markdown
Owner

Adding it via command line makes sense!

@lukeiwanski
lukeiwanski merged commit 6d09da2 into lukeiwanski:dev/amd_gpu Apr 17, 2018
@Rbiessy
Rbiessy deleted the feature/cross-compilation-amd branch April 17, 2018 16:57
@DuncanMcBain

Copy link
Copy Markdown
Collaborator

I can't remember the platforms that you need to avoid it on. You might be able to suppress the remarks with something like -Rno-serial-memop without actually generating the different code.

lukeiwanski pushed a commit that referenced this pull request Apr 18, 2018
lukeiwanski pushed a commit that referenced this pull request Jul 6, 2018
Co-authored-by: John Lawson <[email protected]>
Co-authored-by: Duncan McBain <[email protected]>

Moved ACL config from configure.py to bazel.rc, matching previous TensorFlow upstream changes. Fixes ACL build. (#6)

First steps to cross compilation

Removed some things that are not needed, started adding definitions
for arm toolchains. computecpp.tpl script is next and needs to be aware
of compiling for the host.

Add correct flags to crosstool

Add temporary compiler hack

Fix broken cxx_flags in crosstool

Fixup Aarch64 toolchain components

Add BUILD.tpl entry for arm cross compiler

Target arm32 with correct directories

Further improvements to the crosscompile toolchain

Now there is a templated bash script that sets the target, gcc-toolchain
and sysroot for compute (the c-like compute++). This means that we no
longer need the version flag, as clang will basically work it out for
us. Similarly, all the builtin directories and include lines have been
removed from the CROSSTOOL as they're not needed any more!

This successfully compiles the host and device objects, but fails to link
because it is not aware that two libComputeCpp.so files are needed - one
for host, and one for device.

Change where ComputeCpp is linked

Now we don't need a host copy of libComputeCpp.so, which makes sense,
as it is only used on the target.

Remove host compiler check in configure script

Fix build config for bazel 0.9.1

Remove compute-script from SYCL config

Using compiler_flag and linker_flag means that C files can see the
target we are using, so the custom compute-script is no longer needed.
This has simplified things considerably!

Add dependency on syclrt to GRU and LSTM ops

Removed unneeded code.

Set the same build options for both local and cross-build, as much as possible.

Added host_crosstool_top to the SYCL lines of tools/bazel.rc, and tidied it up a bit.

Renamed ARM_BITCODE_TARGET to BITCODE_TARGET.

Fixed build flags from my previous changes.

Fix core kernel tests not building

The kernels didn't have a dependency on the SYCL runtime, which has now
been added (hidden behind the if_sycl function).

Only prompt user for CROSS_TOOLCHAIN if needed

Previously, the sycl_configure file would complain if the env variables
for the cross toolchain couldn't be found - now, it will only ask about
them if the environment variable "CROSS_TOOLCHAIN" is present,
indicating that the user wants to crosscompile TensorFlow + SYCL. The
names have been updated to indicate that the crosscompiling is flexible
enough to work with other GCC-like toolchains, should the need ever
arise.

Fix autodetection of crosscompilation

It now checks the environment in the correct way to see if the user
wishes to crosscompile.

Add Khronos OpenCL loader bazel configuration

ComputeCpp depends on the OpenCL library to communicate with hardware.
Previously, the OpenCL symbols were being resolved dynamically, which
worked well for the Tensorflow wheel, but doesn't for the tests. This
commit adds a minimal bazel configuration for the OpenCL ICD loader
from Khronos and the OpenCL headers, then sets up the dependencies,
such that ComputeCpp depends on the loader, which in turn depends on
the headers. This is more robust as it means that the build depends
less on how the building system is configured.

Improve OpenCL bazel configuration

OpenCL is now a cc_library, meaning that all the kernel tests are linked
against its bits statically. It also uses the exports map from the ICD
repo to indicate versions of the files within it, so should be
compatible with ICD loaders from other vendors. The headers are no
longer an inc_library, as bazel authors indicate that this is not a
useful rule, and library seems to suffice for this case. As of now, the
bazel config will build all tests and the pip package!

[SYCL] Changes SYCL data types configuration (#217)

Set the required flags to disable certain data types for SYCL in the
configure script, directly setting cxxopts in the bazelrc. This means
that these flags are provided without having to set them in the
compiler script.

Fix bad merge to fix configuration of build

Add syclrt dependency to conv_op test

Move syclrt dependency

Clean OpenCL headers

[SYCL] Add SYCL bitcode configure option

Add a configure time option to specify the SYCL target bitcode to pass
to ComputeCpp. By default this is spir64 for AMD devices, but it can be
changed to match the actual device to compiler for.

Note: There is no check to ensure that the target is supported by
ComputeCpp, nor is there a check to ensure that the traget matches the
device.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants