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

Rocm/Cuda unit test improvement #95

Merged
merged 1 commit into from
Apr 19, 2023
Merged
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
26 changes: 26 additions & 0 deletions SCRAM/GMake/Makefile.alpaka
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,29 @@ $$(eval $$(call AddRocmRules,$1,$2))
endif
endif
endef

ifeq ($(strip $(UNITTESTING)),yes)
$(foreach b,$(ALPAKA_SELECTED_BACKENDS),\
$(eval $(call ShellCMDs,alpakaIsEnabled$(ALPAKA_BACKEND_SUFFIX_$b)))\
$(eval AlpakaTest_$b:=\
$(if $(strip $(filter alpakaIsEnabled$(ALPAKA_BACKEND_SUFFIX_$b),$(CMD_alpakaIsEnabled$(ALPAKA_BACKEND_SUFFIX_$b)))),\
true,\
$(CMD_alpakaIsEnabled$(ALPAKA_BACKEND_SUFFIX_$b))))\
$(eval SKIP_ALPAKA_TESTS_$b:=$(shell $(AlpakaTest_$b) >/dev/null 2>&1 || $(CMD_echo) yes)))

define AlpakaTestsFlag
ifeq ($(strip $(filter alpaka-$2,$($(1)_LOC_USE))-$(SKIP_ALPAKA_TESTS_$2)),alpaka-$2-yes)
$(1)_NO_TESTRUN := yes
$(1)_TEST_SKIP_MSG:=Failed to run alpakaIsEnabled$(ALPAKA_BACKEND_SUFFIX_$2)
else
ifeq ($(strip $(filter $2,$($(1)_LOC_USE))-$(SKIP_ALPAKA_TESTS_$2)),$2-yes)
$(1)_NO_TESTRUN := yes
$(1)_TEST_SKIP_MSG:=Failed to run alpakaIsEnabled$(ALPAKA_BACKEND_SUFFIX_$2)
endif
endif
endef

define AlpakaTestsFlags
$(foreach x,$(ALPAKA_SELECTED_BACKENDS),$(if $(strip $(UNITTEST_TYPES)),$(eval $(call UserTestsSelection,$1,$x)),$(eval $(call AlpakaTestsFlag,$1,$x))))
endef
endif
15 changes: 14 additions & 1 deletion SCRAM/GMake/Makefile.rules
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ COMMON_WORKINGDIR := $(SCRAM_TMP)/common
WORKINGDIR := $(SCRAM_INTwork)
UNITTEST_DIRNAME:=unit_tests
UNITTEST_DIR := $(LOCALTOP)/$(UNITTEST_DIRNAME)
UNITTEST_TYPES:=
ifneq ($(strip $(USER_UNIT_TESTS)),)
UNITTEST_TYPES:=$(strip $(USER_UNIT_TESTS) $(foreach b,$(ALPAKA_SELECTED_BACKENDS),$(if $(strip $(filter $b,$(USER_UNIT_TESTS))),alpaka-$b)))
endif
PRECOMPILE_FLAGS_EXTENSION := cxxflags
PRECOMPILE_EXTENSION := gch
YACC := bison
Expand Down Expand Up @@ -303,6 +307,13 @@ GetCompilerType=$(if $(strip $1),$1,$(if $(strip $($2_COMPILER)),$($2_COMPILER),
GetCompiler=$(if $(strip $2),$2,$(if $(strip $($1_LOC_FLAGS_COMPILER)),$($1_LOC_FLAGS_COMPILER),$(SCRAM_COMPILER)))
GetVectorFlag=$(strip $(if $($1_LOC_FLAGS_COMPILER),$($($1_LOC_FLAGS_COMPILER)-cxxcompiler_EX_FLAGS_$3_TARGETS_$2),$($(SCRAM_COMPILER)-cxxcompiler_EX_FLAGS_$3_TARGETS_$2)))

define UserTestsSelection
ifeq ($(strip $(filter $(UNITTEST_TYPES),$($(1)_LOC_USE))),)
$(1)_NO_TESTRUN := yes
$(1)_TEST_SKIP_MSG:=Not a $(UNITTEST_TYPES) type test
endif
endef

define SetCompilerTargetsFlag
$(eval $(1)_SCRAM_TARGETS:=)
$(foreach v,$(SCRAM_TARGETS),\
Expand Down Expand Up @@ -805,7 +816,7 @@ endef
# Tesings test executable
define run_test
@if [ "X$($(1)_NO_TESTRUN)" == "Xyes" ] ; then \
$(CMD_printf) "Skip %5s ... $($(1)_PROD_PACKAGE)/$1\n" "0s"; \
$(CMD_printf) "Skip %5s ... $($(1)_PROD_PACKAGE)/$1 ($($(1)_TEST_SKIP_MSG))\n" "0s"; \
else \
$(if $(strip $(SCRAM_BUILDVERBOSE)),$(CMD_echo) "Package "$(patsubst $(SCRAM_SOURCEDIR)/%/test,%,$(4))": Running test $(1)" &&)\
[ -d $($(1)_objdir) ] || $(CMD_mkdir) -p $($(1)_objdir) &&\
Expand Down Expand Up @@ -1124,6 +1135,8 @@ ifeq ($(strip $(4)),test)
.PHONY: runtests_$(1) unittests_$(1)
ifeq ($(strip $(filter $(1),$(SKIP_UNITTESTS))),$(1))
$(1)_NO_TESTRUN := yes
$(1)_TEST_SKIP_MSG:=Explicitly skipped via SKIP_UNITTESTS
$(call AlpakaTestsFlags,$1)
endif
runtests_$(6) += unittests_$(1)
unittests_$(6) += unittests_$(1)
Expand Down
4 changes: 4 additions & 0 deletions SCRAM/Plugins/BuildRules.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,10 @@ def updateEnvVarMK(self):
sname = store['name'].upper().replace("/", "_")
ref.write("SCRAMSTORENAME_%s:=%s\n" % (sname, storename))
ref.write("ALL_PRODUCT_STORES+=$(SCRAMSTORENAME_%s)\n" % sname)
ref.write("ALPAKA_SELECTED_BACKENDS:=%s\n" % self.cache['SELECTED_ALPAKA_BACKENDS'])
for bend in self.cache['SELECTED_ALPAKA_BACKENDS'].split(' '):
if not bend: continue
ref.write("ALPAKA_BACKEND_SUFFIX_%s:=%s\n" % (bend,self.cache["SUPPORTED_ALPAKA_BACKENDS"][bend]))
ref.close()
return

Expand Down