Skip to content

Commit

Permalink
Added support for 1BitSGD build flavor to build-and-test script. Also…
Browse files Browse the repository at this point in the history
… fixed a CPUONLY build error
  • Loading branch information
amitaga committed Jan 14, 2016
1 parent 18528f1 commit 0f2786c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 15 deletions.
1 change: 1 addition & 0 deletions Source/SGDLib/SimpleDistGradAggregator.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "CUDAPageLockedMemAllocator.h"
#include <future>
#include "GPUDataTransferer.h"
#include "TimerUtility.h"

namespace Microsoft { namespace MSR { namespace CNTK {

Expand Down
39 changes: 24 additions & 15 deletions Tools/build-and-test
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ CLEAN_AFTER=0
CLEAN_BEFORE=0
RANDOM_OUTPUT=0
FLAVORS="debug:release"
TARGETS="cpu:gpu"
TARGETS="cpu:gpu:1bitsgd"

# parsing command line arguments:
while [[ $# > 0 ]]
Expand All @@ -23,7 +23,7 @@ case $key in
echo " -b|--build-only - just build, do not run"
echo " -f|--flavors <flavor1:flavor2...> - which flavor to build/run (by default $FLAVORS)"
echo " -t|--targets <target1:target2...> - which target to run (by default $TARGETS)"
echo " On Linux: if 'cpu' is included, also do CPU-only builds"
echo " On Windows CPU-only builds currently are not performed"
echo " -cb|--clean-build - clean up the enlistment binaries before build"
echo " -rnd|--random-output-suffix - add random suffix to output directory"
echo " -o|--output-directory <output_dir> - specify output directory to use (by default those will be in <cntk_root>.run-<operating_system>)"
Expand Down Expand Up @@ -97,8 +97,8 @@ if [[ $OS == "Windows_NT" && $OSTYPE == "cygwin" ]]; then
exit 1
fi
elif [[ $OSTYPE == "linux-gnu" ]]; then
DEBUG_DIR=build/debug
RELEASE_DIR=build/release
DEBUG_DIR=build/$TARGET/debug
RELEASE_DIR=build/$TARGET/release
PREFIX_DIR=
# Make sure no dependencies on current directory
BIN_NAME=bin/cntk
Expand Down Expand Up @@ -185,17 +185,23 @@ if [[ $BUILD == 1 ]]; then
if [[ $CLEAN_BEFORE == 1 ]]; then
msbuild.exe /property:Configuration=$FLAVOR /t:Clean 1>&6 2>&7 || exit $?
fi
msbuild.exe /property:Configuration=$FLAVOR /m 1>&6 2>&7 || exit $?
if [[ $TARGET == "1bitsgd" ]]; then
msbuild.exe /property:Configuration=$FLAVOR /property:CNTK_ENABLE_1BitSGD=true /m 1>&6 2>&7 || exit $?
else
msbuild.exe /property:Configuration=$FLAVOR /m 1>&6 2>&7 || exit $?
fi
else
OneBitSGDOPT=no
BUILD_DIR=build/$TARGET/$FLAVOR
if [[ $TARGET == "cpu" ]]; then
CUDAOPT=no
BUILD_DIR=build/cpu/$FLAVOR
else
CUDAOPT=yes
BUILD_DIR=build/$FLAVOR
# TODO should be build/$TARGET/$FLAVOR, but need to make changes elsewhere
if [[ $TARGET == "1bitsgd" ]]; then
OneBitSGDOPT=yes
fi
fi
./configure --with-build-top=$BUILD_DIR --with-acml=$ACML_PATH --with-buildtype=$FLAVOR --cuda=$CUDAOPT
./configure --with-build-top=$BUILD_DIR --with-acml=$ACML_PATH --with-buildtype=$FLAVOR --cuda=$CUDAOPT --1bitsgd=$OneBitSGDOPT
if [[ $CLEAN_BEFORE == 1 ]]; then
make -C $BUILD_DIR -f $MAKEFILE clean 1>&6 2>&7 || exit $?
fi
Expand All @@ -218,18 +224,19 @@ if [[ $RUN == 1 ]]; then

for TARGET in "${targetArray[@]}"
do
TARGET_DEVICE=
# These sed scripts are simply toggling DeviceNumber argument in the config file
# If it is set to Auto, it will pick GPU over CPU. At -1 CPU is selected.
if [[ $TARGET == cpu ]]; then
TARGET_DEVICE=CPU
sed -i -e 's/^deviceId.*/deviceId=-1/g' $CONF_FILE || exit $?
else
TARGET_DEVICE=GPU
sed -i -e 's/^deviceId.*/deviceId=Auto/g' $CONF_FILE || exit $?
fi

for FLAVOR in "${flavorArray[@]}"
do
# TODO on Linux, for target CPU also run CPU-only tests

if [[ $FLAVOR == "debug" ]]; then
FLAVOR_DIR="$DEBUG_DIR"
else
Expand Down Expand Up @@ -261,8 +268,8 @@ if [[ $RUN == 1 ]]; then
chmod a+r $RUN_FILE.*

# Check if execution was successful
grep -q "Using ${TARGET^^}" "$OUT_FILE" || {
echo "============ ERROR: Run output (in $OUT_FILE) did not contain information about target device ($TARGET) ============"
grep -q "Using ${TARGET_DEVICE^^}" "$OUT_FILE" || {
echo "============ ERROR: Run output (in $OUT_FILE) did not contain information about target device ($TARGET_DEVICE) ============"
exit 1
}

Expand All @@ -285,8 +292,10 @@ if [[ $CLEAN_AFTER == 1 ]]; then
if [[ $OS == "Windows_NT" ]]; then
msbuild.exe /property:Configuration=$FLAVOR /t:clean 1>&6 2>&7 || exit $?
else
# TODO needs -C added; clean for all targets
make BUILDTYPE=$FLAVOR -f $MAKEFILE clean 1>&6 2>&7 || exit $?
for TARGET in "${targetArray[@]}"
do
make -C $BUILD_DIR -f $MAKEFILE clean 1>&6 2>&7 || exit $?
done
fi
done
rm -rf $OUTPUT_DIR
Expand Down

0 comments on commit 0f2786c

Please sign in to comment.