Enable PrintBuildInfo for both Windows and Linux
This commit is contained in:
Родитель
2043cd189a
Коммит
33cf6a013f
|
@ -17,8 +17,8 @@
|
|||
#include <algorithm>
|
||||
#if defined(_WIN32)
|
||||
#include "io.h"
|
||||
#include "buildinfo.h"
|
||||
#endif
|
||||
#include "buildinfo.h"
|
||||
#include "hostname.h"
|
||||
#ifdef LEAKDETECT
|
||||
#include "vld.h" // for memory leak detection
|
||||
|
@ -1643,24 +1643,36 @@ std::string TimeDateStamp()
|
|||
return buf;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
void PrintBuiltInfo()
|
||||
{
|
||||
fprintf(stderr, "-------------------------------------------------------------------\n");
|
||||
fprintf(stderr, "Build info: \n\n");
|
||||
fprintf(stderr, "\t\tBuilt time: %s %s\n", __DATE__, __TIME__);
|
||||
fprintf(stderr, "\t\tLast modified date: %s\n", __TIMESTAMP__);
|
||||
fprintf(stderr, "\t\tBuilt by %s on %s\n", _BUILDER_, _BUILDMACHINE_);
|
||||
fprintf(stderr, "\t\tBuild Path: %s\n", _BUILDPATH_);
|
||||
#ifdef _BUILDTYPE_
|
||||
fprintf(stderr, "\t\tBuild type: %s\n", _BUILDTYPE_);
|
||||
#endif
|
||||
#ifdef _MATHLIB_
|
||||
fprintf(stderr, "\t\tMath lib: %s\n", _MATHLIB_);
|
||||
#endif
|
||||
#ifdef _CUDA_PATH_
|
||||
fprintf(stderr, "\t\tCUDA_PATH: %s\n", _CUDA_PATH_);
|
||||
#endif
|
||||
#ifdef _CUB_PATH_
|
||||
fprintf(stderr, "\t\tCUDA_PATH: %s\n", _CUB_PATH_);
|
||||
#endif
|
||||
#ifdef _GIT_EXIST
|
||||
fprintf(stderr, "\t\tBuild Branch: %s\n", _BUILDBRANCH_);
|
||||
fprintf(stderr, "\t\tBuild SHA1: %s\n", _BUILDSHA1_);
|
||||
#endif
|
||||
fprintf(stderr, "-------------------------------------------------------------------\n");
|
||||
|
||||
}
|
||||
#ifdef _BUILDER_
|
||||
fprintf(stderr, "\t\tBuilt by %s on %s\n", _BUILDER_, _BUILDMACHINE_);
|
||||
#endif
|
||||
#ifdef _BUILDPATH_
|
||||
fprintf(stderr, "\t\tBuild Path: %s\n", _BUILDPATH_);
|
||||
#endif
|
||||
fprintf(stderr, "-------------------------------------------------------------------\n");
|
||||
}
|
||||
|
||||
void PrintUsageInfo()
|
||||
{
|
||||
|
@ -1779,9 +1791,7 @@ int wmainWithBS(int argc, wchar_t* argv[]) // called from wmain which is a wra
|
|||
}
|
||||
|
||||
// echo config info to log
|
||||
#ifdef _WIN32
|
||||
PrintBuiltInfo();
|
||||
#endif
|
||||
|
||||
// execute the actions
|
||||
//std::string type = config(L"precision", "float");
|
||||
|
@ -1867,9 +1877,7 @@ int wmainOldCNTKConfig(int argc, wchar_t* argv[]) // called from wmain which i
|
|||
RedirectStdErr(logpath);
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
PrintBuiltInfo();
|
||||
#endif
|
||||
std::string timestamp = TimeDateStamp();
|
||||
|
||||
//dump config info
|
||||
|
|
19
Makefile
19
Makefile
|
@ -180,6 +180,18 @@ ORIGINDIR:='$$ORIGIN'
|
|||
|
||||
CNTKMATH:=cntkmath
|
||||
|
||||
|
||||
########################################
|
||||
# Build info
|
||||
########################################
|
||||
|
||||
BUILDINFO:= MachineLearning/CNTK/buildinfo.h
|
||||
|
||||
$(BUILDINFO): Scripts/genrate_build_info
|
||||
@echo creating $@ for $(ARCH) with build type $(BUILDTYPE)
|
||||
@Scripts/genrate_build_info
|
||||
|
||||
|
||||
########################################
|
||||
# Math library
|
||||
########################################
|
||||
|
@ -451,7 +463,7 @@ CNTK_OBJ := $(patsubst %.cu, $(OBJDIR)/%.o, $(patsubst %.cpp, $(OBJDIR)/%.o, $(C
|
|||
CNTK:=$(BINDIR)/cntk
|
||||
ALL+=$(CNTK)
|
||||
|
||||
$(CNTK): $(CNTK_OBJ) | $(CNTKMATH_LIB)
|
||||
$(CNTK): $(BUILDINFO) $(CNTK_OBJ) | $(CNTKMATH_LIB)
|
||||
@echo $(SEPARATOR)
|
||||
@mkdir -p $(dir $@)
|
||||
@echo building output for $(ARCH) with build type $(BUILDTYPE)
|
||||
|
@ -485,7 +497,10 @@ $(OBJDIR)/%.o : %.cpp Makefile
|
|||
@mkdir -p $(dir $@)
|
||||
$(CXX) -c $< -o $@ $(CPPFLAGS) $(CXXFLAGS) $(INCLUDEPATH:%=-I%) -MD -MP -MF ${@:.o=.d}
|
||||
|
||||
.PHONY: clean buildall all
|
||||
.PHONY: force clean buildall all
|
||||
|
||||
force: $(BUILDINFO)
|
||||
|
||||
|
||||
clean:
|
||||
@echo $(SEPARATOR)
|
||||
|
|
|
@ -0,0 +1,104 @@
|
|||
#!/bin/bash
|
||||
|
||||
|
||||
# description:
|
||||
# this script is used to generated buildinfo.h in MachineLearning/CNTK which will contain the following infomation to be displayed at runtime:
|
||||
# CUDA_PATH (if exists)
|
||||
# CUB_PATH (if exists)
|
||||
# GIT_COMMIT
|
||||
# GTT_BRANCH
|
||||
# BUILDTYPE (release/debug)
|
||||
# MATHLIB (MKL/ACML)
|
||||
|
||||
usage ()
|
||||
{
|
||||
echo "usage: $0 "
|
||||
echo "-------------------------------------------------------------------"
|
||||
echo "This script is used to generate buildinfo.h in MachineLearning/CNTK"
|
||||
echo "This script needs to be called from the top level directory of CNTK project"
|
||||
echo "This script assumes git can be used"
|
||||
echo "This script assumes Config.make has been made"
|
||||
echo "-------------------------------------------------------------------"
|
||||
if [ ! -z "$1" ] ; then
|
||||
echo "ERROR message: $1"
|
||||
fi
|
||||
exit 1
|
||||
}
|
||||
|
||||
Has_Git()
|
||||
{
|
||||
if hash git 2>/dev/null; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
makebuildinfo()
|
||||
{
|
||||
target=$1
|
||||
BUILDTYPE=$2
|
||||
MATHLIB=$3
|
||||
GIT_COMMIT=$4
|
||||
GIT_BRANCH=$5
|
||||
CUDA_PATH=$6
|
||||
CUB_PATH=$7
|
||||
|
||||
printf "#ifndef _BUILDINFO_H\n" > $target
|
||||
printf "#define _BUILDINFO_H\n" >> $target
|
||||
printf "#define _GIT_EXIST\n" >> $target
|
||||
printf "#define _MATHLIB_ \"%s\"\n" $MATHLIB >> $target
|
||||
printf "#define _BUILDSHA1_ \"%s\"\n" $GIT_COMMIT >> $target
|
||||
printf "#define _BUILDBRANCH_ \"%s\"\n" $GIT_BRANCH >> $target
|
||||
if [ ! -z "$CUDA_PATH" ]; then
|
||||
printf "#define _CUDA_PATH_ \"%s\"\n" $CUDA_PATH >> $target
|
||||
fi
|
||||
if [ ! -z "$CUB_PATH" ]; then
|
||||
printf "#define _CUB_PATH_ \"%s\"\n" $CUB_PATH >> $target
|
||||
fi
|
||||
printf "#define _BUILDTYPE_ \"%s\"\n" $BUILDTYPE >> $target
|
||||
printf "#endif\n" >> $target
|
||||
}
|
||||
|
||||
#//////////////////////////////////////////////////////#
|
||||
# main function #
|
||||
#//////////////////////////////////////////////////////#
|
||||
if [ $# -ne 0 ]; then
|
||||
usage
|
||||
fi
|
||||
|
||||
|
||||
# 1. check whether we have git and what is the sha-1 value
|
||||
if Has_Git; then has_git=1; else has_git=0; usage "git not exist"; fi
|
||||
GIT_COMMIT=`git rev-parse HEAD`
|
||||
GIT_BRANCH=`git rev-parse --abbrev-ref HEAD`
|
||||
|
||||
# 2. looking into Config.make
|
||||
if [ ! -e Config.make ] ; then
|
||||
usage "Config.make not exists"
|
||||
fi
|
||||
source "Config.make"
|
||||
|
||||
# 3. whether we have CUDA_PATH
|
||||
if [ -z "${CUDA_PATH+x}" ]; then
|
||||
CUDAPATH=""
|
||||
else
|
||||
CUDAPATH=$CUDA_PATH
|
||||
fi
|
||||
|
||||
# 4. whether we have CUB_PATH
|
||||
if [ -z "${CUB_PATH+x}" ]; then
|
||||
CUBPATH=""
|
||||
else
|
||||
CUBPATH=$CUB_PATH
|
||||
fi
|
||||
|
||||
# 5. make buildinfo.h
|
||||
target=MachineLearning/CNTK/buildinfo.h
|
||||
if [ ! -d MachineLearning ] ; then
|
||||
usage
|
||||
fi
|
||||
if [ -e MachineLearning/CNTK/buildinfo.h ] ; then
|
||||
rm MachineLearning/CNTK/buildinfo.h
|
||||
fi
|
||||
makebuildinfo $target $BUILDTYPE $MATHLIB $GIT_COMMIT $GIT_BRANCH $CUDAPATH $CUBPATH
|
Загрузка…
Ссылка в новой задаче