From 0aa24623a6fb73a3fbd5dbcf97276e0d3c843c14 Mon Sep 17 00:00:00 2001 From: Joseph Rushton Wakeling Date: Thu, 21 Jun 2018 16:15:18 +0200 Subject: [PATCH 1/6] Update build scripts to always run tests for all MXNet engine types This patch updates `Build.mak` to ensure that unittests and integration tests will always be run for all of the supported engine types. As well as making it easier to run tests for all engines locally, this will make it possible to greatly simplify our CI setup. --- Build.mak | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Build.mak b/Build.mak index 80693b8..040373d 100644 --- a/Build.mak +++ b/Build.mak @@ -12,12 +12,25 @@ endif download-mnist: $C/script/download-mnist $(call exec,sh $(if $V,,-x) $^,$(MNIST_DATA_DIR),$^) +# helper function to run tests +run_test = $(call exec,MXNET_ENGINE_TYPE=$2 $1,$1,$2) + # extra build dependencies for integration tests $O/test-mxnet: override LDFLAGS += -lz $O/test-mxnet: override DFLAGS += -debug=MXNetHandleManualFree # extra runtime dependencies for integration tests $O/test-mxnet.stamp: override ITFLAGS += $(MNIST_DATA_DIR) -$O/test-mxnet.stamp: download-mnist +$O/test-mxnet.stamp: $O/test-mxnet download-mnist + $(call run_test,$<,NaiveEngine) + $(call run_test,$<,ThreadedEngine) + $(call run_test,$<,ThreadedEnginePerDevice) + $Vtouch $@ $O/%unittests: override LDFLAGS += -lz + +$O/allunittests.stamp: $O/allunittests + $(call run_test,$<,NaiveEngine) + $(call run_test,$<,ThreadedEngine) + $(call run_test,$<,ThreadedEnginePerDevice) + $Vtouch $@ From 62e2506327855db348c94658183d611cbcd41962 Mon Sep 17 00:00:00 2001 From: Joseph Rushton Wakeling Date: Thu, 21 Jun 2018 16:39:10 +0200 Subject: [PATCH 2/6] Remove MXNET_ENGINE_TYPE settings from Travis CI config Since `Build.mak` now takes care of running tests with all engines, we can greatly simplify the number and configuration of Travis CI jobs. This patch reduces the setup to cover development and production builds for D1 and D2 respectively. --- .travis.yml | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/.travis.yml b/.travis.yml index 24f4d85..a677227 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,7 +23,6 @@ env: global: # Make sure beaver is in the PATH - PATH="$(git config -f .gitmodules submodule.beaver.path)/bin:$PATH)" - - BEAVER_DOCKER_VARS="MXNET_ENGINE_TYPE" # Basic config is inherited from the global scope jobs: @@ -39,32 +38,16 @@ jobs: include: # Test matrix - <<: *test-matrix - env: DMD=dmd1 DIST=xenial F=devel MXNET_ENGINE_TYPE=NaiveEngine - - <<: *test-matrix - env: DMD=dmd1 DIST=xenial F=devel MXNET_ENGINE_TYPE=ThreadedEngine - - <<: *test-matrix - env: DMD=dmd1 DIST=xenial F=devel MXNET_ENGINE_TYPE=ThreadedEnginePerDevice + env: DMD=dmd1 DIST=xenial F=devel - <<: *test-matrix - env: DMD=dmd1 DIST=xenial F=production MXNET_ENGINE_TYPE=NaiveEngine - - <<: *test-matrix - env: DMD=dmd1 DIST=xenial F=production MXNET_ENGINE_TYPE=ThreadedEngine - - <<: *test-matrix - env: DMD=dmd1 DIST=xenial F=production MXNET_ENGINE_TYPE=ThreadedEnginePerDevice + env: DMD=dmd1 DIST=xenial F=production - <<: *test-matrix - env: DMD=dmd-transitional DIST=xenial F=production MXNET_ENGINE_TYPE=NaiveEngine - - <<: *test-matrix - env: DMD=dmd-transitional DIST=xenial F=production MXNET_ENGINE_TYPE=ThreadedEngine - - <<: *test-matrix - env: DMD=dmd-transitional DIST=xenial F=production MXNET_ENGINE_TYPE=ThreadedEnginePerDevice + env: DMD=dmd-transitional DIST=xenial F=devel - <<: *test-matrix - env: DMD=dmd-transitional DIST=xenial F=devel MXNET_ENGINE_TYPE=NaiveEngine - - <<: *test-matrix - env: DMD=dmd-transitional DIST=xenial F=devel MXNET_ENGINE_TYPE=ThreadedEngine - - <<: *test-matrix - env: DMD=dmd-transitional DIST=xenial F=devel MXNET_ENGINE_TYPE=ThreadedEnginePerDevice + env: DMD=dmd-transitional DIST=xenial F=production # Additional stages From 201fe10c613b0f527f979176aed5a5df7dfc223c Mon Sep 17 00:00:00 2001 From: Joseph Rushton Wakeling Date: Thu, 21 Jun 2018 19:17:35 +0200 Subject: [PATCH 3/6] squash! Update build scripts to always run tests for all MXNet engine types --- Build.mak | 32 ++++++++++++++++++++++---------- Config.mak | 2 ++ 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/Build.mak b/Build.mak index 040373d..8db80de 100644 --- a/Build.mak +++ b/Build.mak @@ -15,22 +15,34 @@ download-mnist: $C/script/download-mnist # helper function to run tests run_test = $(call exec,MXNET_ENGINE_TYPE=$2 $1,$1,$2) +# helper template to define targets for per-engine test runs +define run_test_with_engine +$(1).stamp: $(1)-$(2).stamp + +$(1)-$(2).stamp: $1 + $(call exec,MXNET_ENGINE_TYPE=$2 $1,$1,$2) +endef + +# helper function to generate targets for per-engine test runs +test_with_engines = $(foreach engine,$2,\ + $(eval $(call run_test_with_engine,$1,$(engine)))) + # extra build dependencies for integration tests $O/test-mxnet: override LDFLAGS += -lz $O/test-mxnet: override DFLAGS += -debug=MXNetHandleManualFree +# run integration tests with all specified engines +$(eval $(call test_with_engines,$O/test-mxnet,$(TEST_MXNET_ENGINES))) + # extra runtime dependencies for integration tests $O/test-mxnet.stamp: override ITFLAGS += $(MNIST_DATA_DIR) -$O/test-mxnet.stamp: $O/test-mxnet download-mnist - $(call run_test,$<,NaiveEngine) - $(call run_test,$<,ThreadedEngine) - $(call run_test,$<,ThreadedEnginePerDevice) - $Vtouch $@ +$O/test-mxnet.stamp: download-mnist + $Vtouch $@ # override default implementation $O/%unittests: override LDFLAGS += -lz -$O/allunittests.stamp: $O/allunittests - $(call run_test,$<,NaiveEngine) - $(call run_test,$<,ThreadedEngine) - $(call run_test,$<,ThreadedEnginePerDevice) - $Vtouch $@ +# run unittests with all specified engines +$(eval $(call test_with_engines,$O/allunittests,$(TEST_MXNET_ENGINES))) + +$O/allunittests.stamp: + $Vtouch $@ # override default implementation diff --git a/Config.mak b/Config.mak index eef5205..20dfec8 100644 --- a/Config.mak +++ b/Config.mak @@ -1,5 +1,7 @@ INTEGRATIONTEST := integrationtest +TEST_MXNET_ENGINES ?= NaiveEngine ThreadedEngine ThreadedEnginePerDevice + MXNET_ENGINE_TYPE ?= NaiveEngine export MXNET_ENGINE_TYPE From 9370ffd0a608354087013766dc7e850a1615066a Mon Sep 17 00:00:00 2001 From: Joseph Rushton Wakeling Date: Thu, 21 Jun 2018 19:19:40 +0200 Subject: [PATCH 4/6] squash! Update build scripts to always run tests for all MXNet engine types --- Build.mak | 3 --- 1 file changed, 3 deletions(-) diff --git a/Build.mak b/Build.mak index 8db80de..c3c296c 100644 --- a/Build.mak +++ b/Build.mak @@ -12,9 +12,6 @@ endif download-mnist: $C/script/download-mnist $(call exec,sh $(if $V,,-x) $^,$(MNIST_DATA_DIR),$^) -# helper function to run tests -run_test = $(call exec,MXNET_ENGINE_TYPE=$2 $1,$1,$2) - # helper template to define targets for per-engine test runs define run_test_with_engine $(1).stamp: $(1)-$(2).stamp From 38c3e08403ab83e1c1032b45ac957df9e3379972 Mon Sep 17 00:00:00 2001 From: Joseph Rushton Wakeling Date: Thu, 21 Jun 2018 19:28:53 +0200 Subject: [PATCH 5/6] squash! Update build scripts to always run tests for all MXNet engine types --- Build.mak | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Build.mak b/Build.mak index c3c296c..e7f413f 100644 --- a/Build.mak +++ b/Build.mak @@ -21,7 +21,7 @@ $(1)-$(2).stamp: $1 endef # helper function to generate targets for per-engine test runs -test_with_engines = $(foreach engine,$2,\ +test_with_engines = $(foreach engine,$(TEST_MXNET_ENGINES),\ $(eval $(call run_test_with_engine,$1,$(engine)))) # extra build dependencies for integration tests @@ -29,7 +29,7 @@ $O/test-mxnet: override LDFLAGS += -lz $O/test-mxnet: override DFLAGS += -debug=MXNetHandleManualFree # run integration tests with all specified engines -$(eval $(call test_with_engines,$O/test-mxnet,$(TEST_MXNET_ENGINES))) +$(eval $(call test_with_engines,$O/test-mxnet)) # extra runtime dependencies for integration tests $O/test-mxnet.stamp: override ITFLAGS += $(MNIST_DATA_DIR) @@ -39,7 +39,7 @@ $O/test-mxnet.stamp: download-mnist $O/%unittests: override LDFLAGS += -lz # run unittests with all specified engines -$(eval $(call test_with_engines,$O/allunittests,$(TEST_MXNET_ENGINES))) +$(eval $(call test_with_engines,$O/allunittests)) $O/allunittests.stamp: $Vtouch $@ # override default implementation From c8d44c28b89a800bf681d0b0029f8b3330363d70 Mon Sep 17 00:00:00 2001 From: Joseph Rushton Wakeling Date: Fri, 22 Jun 2018 17:01:07 +0200 Subject: [PATCH 6/6] squash! Update build scripts to always run tests for all MXNet engine types This should get the dependencies working OK. --- Build.mak | 42 +++++++++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/Build.mak b/Build.mak index e7f413f..88e6c04 100644 --- a/Build.mak +++ b/Build.mak @@ -13,33 +13,49 @@ download-mnist: $C/script/download-mnist $(call exec,sh $(if $V,,-x) $^,$(MNIST_DATA_DIR),$^) # helper template to define targets for per-engine test runs -define run_test_with_engine +# +# Params: +# $1 = path to executable that runs tests +# $2 = name of MXNet engine to use +define test_with_engine $(1).stamp: $(1)-$(2).stamp $(1)-$(2).stamp: $1 $(call exec,MXNET_ENGINE_TYPE=$2 $1,$1,$2) + $Vtouch $$@ endef # helper function to generate targets for per-engine test runs -test_with_engines = $(foreach engine,$(TEST_MXNET_ENGINES),\ - $(eval $(call run_test_with_engine,$1,$(engine)))) +# +# Params: +# $1 = path to executable that runs tests +define run_test_with_engines +$(foreach engine,$(TEST_MXNET_ENGINES),\ + $(eval $(call test_with_engine,$1,$(engine)))) + +$(1).stamp: + $Vtouch $$@ # override default implementation +endef + +define run_test_with_dependency +$(foreach engine,$(TEST_MXNET_ENGINES),\ + $(eval $(1)-$(engine).stamp: $2)) +endef # extra build dependencies for integration tests $O/test-mxnet: override LDFLAGS += -lz $O/test-mxnet: override DFLAGS += -debug=MXNetHandleManualFree -# run integration tests with all specified engines -$(eval $(call test_with_engines,$O/test-mxnet)) - # extra runtime dependencies for integration tests -$O/test-mxnet.stamp: override ITFLAGS += $(MNIST_DATA_DIR) -$O/test-mxnet.stamp: download-mnist - $Vtouch $@ # override default implementation +$(eval $(call run_test_with_dependency,$O/test-mxnet,\ + override ITFLAGS += $(MNIST_DATA_DIR))) +$(eval $(call run_test_with_dependency,$O/test-mxnet,\ + download-mnist)) + +# run integration tests with all specified engines +$(eval $(call run_test_with_engines,$O/test-mxnet)) $O/%unittests: override LDFLAGS += -lz # run unittests with all specified engines -$(eval $(call test_with_engines,$O/allunittests)) - -$O/allunittests.stamp: - $Vtouch $@ # override default implementation +$(eval $(call run_test_with_engines,$O/allunittests))