Skip to content

Commit

Permalink
- fix for parallel builds
Browse files Browse the repository at this point in the history
- SSE3 fallback option added

git-svn-id: https://ipvs.informatik.uni-stuttgart.de/SGpp/repos/branches/SGppCodingDays@4028 4eea3252-f0fb-4393-894d-40516dce545b
  • Loading branch information
David Pfander committed Jan 27, 2015
1 parent 568d9ae commit e250933
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 16 deletions.
8 changes: 6 additions & 2 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ vars.Add(BoolVariable('OPT', "Sets optimization on and off", False))
vars.Add(BoolVariable('NO_UNIT_TESTS', 'Omit UnitTests if set to True', False))
vars.Add(BoolVariable('SG_PYTHON', 'Build with python Support', True))
vars.Add(BoolVariable('SG_JAVA', 'Build with java Support', False))
vars.Add(BoolVariable('SSE3_FALLBACK', 'Tries to build as much as possible with SSE3 instead of AVX (intrinsics based functions won\'t work)', False))
vars.Add('OUTPUT_PATH', 'Path where built libraries are installed. Needs a trailing slash!', '')
vars.Add(BoolVariable('VERBOSE', 'Set output verbosity', False))
vars.Add('CMD_LOGFILE', 'Specifies a file to capture the build log', 'build.log')
Expand Down Expand Up @@ -117,6 +118,9 @@ Export('env')

libalglib, alglibstatic = env.SConscript('tools/SConscriptAlglib', variant_dir='tmp/build_alglib', duplicate=0)
alglibinst = env.Install(env['OUTPUT_PATH'] + 'lib/alglib', [libalglib, alglibstatic])
# make base depend on alglib

env.Depends("#/" + BUILD_DIR.path + "/libsgppbase.so", alglibinst)

env.Append(CPPPATH=['#/tools'])

Expand Down Expand Up @@ -152,8 +156,8 @@ if not env['NO_UNIT_TESTS'] and env['SG_PYTHON']:
pysgppTestTargets = []
dependency = None
for moduleFolder in moduleFolders:
if moduleFolder == "parallel" or moduleFolder == "finance" or moduleFolder == "pde" or moduleFolder == "solver":
# these modules don't currently have tests
if moduleFolder == "parallel":
# # these modules don't currently have tests
continue
moduleTest = env.Test('#/' + moduleFolder + '/tests/test_' + moduleFolder + '.py')
env.Requires(moduleTest, pysgppInstall)
Expand Down
27 changes: 20 additions & 7 deletions datadriven/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,29 @@ Import('moduleName')

dependencies = ["base", "solver"]

srcs = []
avxFolders = ['./src/sgpp/datadriven/operation/OperationMultipleEvalSubspace/', './src/sgpp/datadriven/operation/OperationMultiEvalStreaming']

avx_env = env.Clone()
avxCPPFLAGS = filter(lambda flag: flag != '-msse3', avx_env['CPPFLAGS'])
avx_env['CPPFLAGS'] = avxCPPFLAGS
#avx_env.Remove(CPPFLAGS = '-msse3')
avx_env.Append(CPPFLAGS = '-mavx')

def isAVXFolder(folder):
for avxFolder in avxFolders:
if folder.startswith(avxFolder):
return True
return False

objs = []
for currentFolder, subdirNames, fileNames in os.walk("."):
if currentFolder.startswith("./src"):
for fileName in fnmatch.filter(fileNames, '*.cpp'):
srcs.append(os.path.join(currentFolder, fileName))

objs = []
for sourceFile in srcs:
objs.append(env.SharedObject(sourceFile))

sourceFile = os.path.join(currentFolder, fileName)
if isAVXFolder(currentFolder):
objs.append(avx_env.SharedObject(sourceFile))
else:
objs.append(env.SharedObject(sourceFile))

lib = env.SharedLibrary(target ="sgpp" + moduleName, source = objs, LIBPATH = [BUILD_DIR, '#/lib/alglib'], LIBS=['sgppbase', 'sgppsolver', 'libalglib'])
env.Depends(lib, "#/" + BUILD_DIR.path + "/libsgppbase.so")
Expand Down
16 changes: 15 additions & 1 deletion datadriven/src/sgpp/datadriven/DatadrivenOpFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

#include <cstring>

#include <sgpp/datadriven/operation/OperationMultiEvalStreaming/OperationMultiEvalStreaming.hpp>
#include <sgpp/base/exception/factory_exception.hpp>

#include <sgpp/base/grid/type/PolyGrid.hpp>
Expand Down Expand Up @@ -36,8 +35,11 @@
#include <sgpp/datadriven/operation/hash/OperationInverseRosenblattTransformationLinear.hpp>
#include <sgpp/datadriven/operation/hash/OperationRegularizationDiagonalLinearBoundary.hpp>

#ifdef __AVX__
#include <sgpp/datadriven/operation/OperationMultiEvalStreaming/OperationMultiEvalStreaming.hpp>
#include <sgpp/datadriven/operation/OperationMultipleEvalSubspace/combined/OperationMultipleEvalSubspaceCombined.hpp>
#include <sgpp/datadriven/operation/OperationMultipleEvalSubspace/simple/OperationMultipleEvalSubspaceSimple.hpp>
#endif

#include <sgpp/base/operation/BaseOpFactory.hpp>

Expand Down Expand Up @@ -162,16 +164,28 @@ base::OperationMultipleEval *createOperationMultipleEval(base::Grid &grid, base:
if (configuration.subType != SGPP::datadriven::OperationMultipleEvalSubType::DEFAULT) {
throw base::factory_exception("OperationMultiEval is not implemented for this implementation subtype.");
}
#ifdef __AVX__
return new datadriven::OperationMultiEvalStreaming(grid, dataset);
#else
throw base::factory_exception("Error creating function: library wasn't compiled with AVX");
#endif
break;
case datadriven::OperationMultipleEvalType::SUBSPACELINEAR:
switch (configuration.subType) {
case SGPP::datadriven::OperationMultipleEvalSubType::DEFAULT:
case SGPP::datadriven::OperationMultipleEvalSubType::COMBINED:
#ifdef __AVX__
return new datadriven::OperationMultipleEvalSubspaceCombined(grid, dataset);
#else
throw base::factory_exception("Error creating function: library wasn't compiled with AVX");
#endif
break;
case SGPP::datadriven::OperationMultipleEvalSubType::SIMPLE:
#ifdef __AVX__
return new datadriven::OperationMultipleEvalSubspaceSimple(grid, dataset);
#else
throw base::factory_exception("Error creating function: library wasn't compiled with AVX");
#endif
break;
default:
throw base::factory_exception("OperationMultiEval is not implemented for this implementation subtype.");
Expand Down
2 changes: 1 addition & 1 deletion pysgpp/pysgpp.i
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
%init %{
import_array();
%}
//%apply (double** ARGOUTVIEW_ARRAY1, int *DIM1) {(double** vec, int* n)}
%apply (double** ARGOUTVIEW_ARRAY1, int *DIM1) {(double** vec, int* n)}
%apply (double* IN_ARRAY1, int DIM1) {(double* input, int size)}
//%apply int INPUT {SGPP::base::HashGenerator::level_t level};

Expand Down
13 changes: 8 additions & 5 deletions site_scons/SGppConfigure.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,14 @@ def doConfigure(env, moduleFolders):
Exit(1)
config.env.AppendUnique(CPPFLAGS = "-std=c++11")

# check avx support
if not config.CheckFlag("-mavx"):
sys.stderr.write("Error: compiler doesn't seem to support AVX. Abort!\n")
Exit(1)
config.env.AppendUnique(CPPFLAGS = "-mavx")
if not env['SSE3_FALLBACK']:
# check avx support
if not config.CheckFlag("-mavx"):
sys.stderr.write("Error: compiler doesn't seem to support AVX. Abort! Fallin\n")
Exit(1)
config.env.AppendUnique(CPPFLAGS = "-mavx")
else:
config.env.AppendUnique(CPPFLAGS = "-msse3")

# check whether swig installed
if not config.CheckExec('doxygen'):
Expand Down

0 comments on commit e250933

Please sign in to comment.