Skip to contentSkip to conversation

Add OpenMP support for custom external toolchains

PATCH New Ed Blake 2 participants 4 messages Mar 28, 2019

lore
Share & tools
lore

Ed Blake

author
#0 lore raw

cover Add OpenMP support for custom external toolchains

This patchset adds OpenMP support for custom external toolchains. The first patch adds a new 'BR2_TOOLCHAIN_EXTERNAL_OPENMP' option for custom external toolchains to enable OpenMP support, and the second patch adds a check that the toolchain has OpenMP support.

Ed Blake (2):
toolchain-external: introduce BR2_TOOLCHAIN_EXTERNAL_OPENMP
toolchain-external: add a check for OpenMP support

 toolchain/helpers.mk                           | 18 ++++++++++++++++++
 .../pkg-toolchain-external.mk                  |  3 +++
 .../Config.in.options                          |  8 ++++++++
 3 files changed, 29 insertions(+)
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH 1/2 toolchain-external: introduce BR2_TOOLCHAIN_EXTERNAL_OPENMP

Add a new option for custom external toolchains to enable OpenMP support.

---
 .../toolchain-external-custom/Config.in.options           | 8 ++++++++
 1 file changed, 8 insertions(+)
toolchain/toolchain-external/toolchain-external-custom/Config.in.options +8 -0
index 08a79ee4d9..74e445d625 100644
@@ -421,6 +421,14 @@ config BR2_TOOLCHAIN_EXTERNAL_FORTRAN
 	  support. If you don't know, leave the default value,
 	  Buildroot will tell you if it's correct or not.
 
+config BR2_TOOLCHAIN_EXTERNAL_OPENMP
+	bool "Toolchain has OpenMP support?"
+	select BR2_TOOLCHAIN_HAS_OPENMP
+	help
+	  Select this option if your external toolchain has OpenMP
+	  support. If you don't know, leave the default value,
+	  Buildroot will tell you if it's correct or not.
+
 config BR2_TOOLCHAIN_EXTRA_EXTERNAL_LIBS
 	string "Extra toolchain libraries to be copied to target"
 	help
Signature · 1 line
2.17.1
author
#2 lore raw

PATCH 2/2 toolchain-external: add a check for OpenMP support

In reply to Ed Blake
---
 toolchain/helpers.mk                           | 18 ++++++++++++++++++
 .../pkg-toolchain-external.mk                  |  3 +++
 2 files changed, 21 insertions(+)
toolchain/helpers.mk +18 -0
index e5520c00c3..03355f56dd 100644
@@ -359,6 +359,24 @@ check_fortran = \
 	fi ; \
 	rm -f $${__o}* \
 
+#
+#
+# Check that the external toolchain supports OpenMP
+#
+# $1: cross-gcc path
+#
+check_openmp = \
+	__CROSS_CC=$(strip $1) ; \
+	__o=$(BUILD_DIR)/.br-toolchain-test-openmp.tmp ; \
+	printf '\#include <omp.h>\nint main(void) { return omp_get_thread_num(); }' | \
+	$${__CROSS_CC} -fopenmp -x c -o $${__o} - ; \
+	if test $$? -ne 0 ; then \
+		rm -f $${__o}* ; \
+		echo "OpenMP support is selected but is not available in external toolchain"; \
+		exit 1 ; \
+	fi ; \
+	rm -f $${__o}* \
+
 #
 # Check that the cross-compiler given in the configuration exists
 #
toolchain/toolchain-external/pkg-toolchain-external.mk +3 -0
index 747837fdc6..baf719ad1f 100644
@@ -545,6 +545,9 @@ define $(2)_CONFIGURE_CMDS
 	if test "$$(BR2_TOOLCHAIN_HAS_FORTRAN)" = "y" ; then \
 		$$(call check_fortran,$$(TOOLCHAIN_EXTERNAL_FC)) ; \
 	fi ; \
+	if test "$$(BR2_TOOLCHAIN_HAS_OPENMP)" = "y" ; then \
+		$$(call check_openmp,$$(TOOLCHAIN_EXTERNAL_CC)) ; \
+	fi ; \
 	if test "$$(BR2_TOOLCHAIN_EXTERNAL_UCLIBC)" = "y" ; then \
 		$$(call check_uclibc,$$$${SYSROOT_DIR}) ; \
 	elif test "$$(BR2_TOOLCHAIN_EXTERNAL_MUSL)" = "y" ; then \
Signature · 1 line
2.17.1
#3 lore raw

cover Add OpenMP support for custom external toolchains

In reply to Ed Blake
Quoted 3 lines · On Thu, 28 Mar 2019 18:48:14 +0000 Ed Blake <[email protected]> wrote:

Ed Blake (2):
toolchain-external: introduce BR2_TOOLCHAIN_EXTERNAL_OPENMP
toolchain-external: add a check for OpenMP support

Thanks, applied!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com