diff --git a/SConstruct b/SConstruct index 03e2feb239..f05dbe284b 100644 --- a/SConstruct +++ b/SConstruct @@ -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') @@ -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']) @@ -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) diff --git a/datadriven/SConscript b/datadriven/SConscript index 9fe90e9503..3b8138b452 100755 --- a/datadriven/SConscript +++ b/datadriven/SConscript @@ -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") diff --git a/datadriven/src/sgpp/datadriven/DatadrivenOpFactory.cpp b/datadriven/src/sgpp/datadriven/DatadrivenOpFactory.cpp index 3d7216b91f..09e7bba0f5 100644 --- a/datadriven/src/sgpp/datadriven/DatadrivenOpFactory.cpp +++ b/datadriven/src/sgpp/datadriven/DatadrivenOpFactory.cpp @@ -7,7 +7,6 @@ #include -#include #include #include @@ -36,8 +35,11 @@ #include #include +#ifdef __AVX__ +#include #include #include +#endif #include @@ -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."); diff --git a/pysgpp/pysgpp.i b/pysgpp/pysgpp.i index 4482b8df9d..4f61d1abcd 100755 --- a/pysgpp/pysgpp.i +++ b/pysgpp/pysgpp.i @@ -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}; diff --git a/site_scons/SGppConfigure.py b/site_scons/SGppConfigure.py index 41465b3632..79a955248d 100644 --- a/site_scons/SGppConfigure.py +++ b/site_scons/SGppConfigure.py @@ -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'):