Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing issue #102: Compilation errors with clang 13 and OpenMP and MPI #103

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion Samples/0_Introduction/UnifiedMemoryStreams/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -288,13 +288,24 @@ LIBRARIES :=
# Attempt to compile a minimal OpenMP application. If a.out exists, OpenMP is properly set up.
ifneq (,$(filter $(TARGET_OS),linux android))

# Special treatment for Clang to not use standard OMP Library and fix OMP 5 bug in Clang 13
ifneq (,$(findstring "clang",$(HOST_COMPILER)))
ifneq (,$(filter $(TARGET_OS), android))
LIBRARIES += -lomp
else
LIBRARIES += -lgomp
endif

ALL_CCFLAGS += -Xcompiler -fopenmp
else
ALL_CCFLAGS += -Xcompiler -fopenmp
ALL_LDFLAGS += -Xcompiler -fopenmp
COMPILER_VERSION= $(shell $(HOST_COMPILER) --version)
ifneq (,$(findstring 13.,$(COMPILER_VERSION)))
ALL_CCFLAGS += -Xcompiler -fopenmp -Xcompiler -fopenmp-version=45
ALL_LDFLAGS += -Xcompiler -fopenmp -Xcompiler -fopenmp-version=45
endif
endif

$(shell echo "#include <omp.h>" > test.c ; echo "int main() { omp_get_num_threads(); return 0; }" >> test.c ; $(HOST_COMPILER) -fopenmp test.c)
OPENMP ?= $(shell find a.out 2>/dev/null)

Expand Down
14 changes: 13 additions & 1 deletion Samples/0_Introduction/cudaOpenMP/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -294,13 +294,25 @@ LIBRARIES :=
# Attempt to compile a minimal OpenMP application. If a.out exists, OpenMP is properly set up.
ifneq (,$(filter $(TARGET_OS),linux android))


# Special treatment for Clang to not use standard OMP Library and fix OMP 5 bug in Clang 13
ifneq (,$(findstring "clang",$(HOST_COMPILER)))
ifneq (,$(filter $(TARGET_OS), android))
LIBRARIES += -lomp
else
LIBRARIES += -lgomp
endif

ALL_CCFLAGS += -Xcompiler -fopenmp
else
ALL_CCFLAGS += -Xcompiler -fopenmp
ALL_LDFLAGS += -Xcompiler -fopenmp
COMPILER_VERSION= $(shell $(HOST_COMPILER) --version)
ifneq (,$(findstring 13.,$(COMPILER_VERSION)))
ALL_CCFLAGS += -Xcompiler -fopenmp -Xcompiler -fopenmp-version=45
ALL_LDFLAGS += -Xcompiler -fopenmp -Xcompiler -fopenmp-version=45
endif
endif

$(shell echo "#include <omp.h>" > test.c ; echo "int main() { omp_get_num_threads(); return 0; }" >> test.c ; $(HOST_COMPILER) -fopenmp test.c)
OPENMP ?= $(shell find a.out 2>/dev/null)

Expand Down
4 changes: 4 additions & 0 deletions Samples/0_Introduction/simpleMPI/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@ NVCCFLAGS := -m${TARGET_SIZE}
CCFLAGS :=
LDFLAGS :=

# Special treatment for Clang
ifneq (,$(findstring clang,$(HOST_COMPILER)))
CCFLAGS+= -fPIE
endif
# build flags
ifeq ($(TARGET_OS),darwin)
LDFLAGS += -rpath $(CUDA_PATH)/lib
Expand Down