Skip to content

Commit

Permalink
datadriven/tests/test_... unfixable broken, merge of SGppAutoTune oth…
Browse files Browse the repository at this point in the history
…erwise complete

git-svn-id: https://ipvs.informatik.uni-stuttgart.de/SGpp/repos/trunk@5287 4eea3252-f0fb-4393-894d-40516dce545b
  • Loading branch information
Sekuraz committed Nov 30, 2015
1 parent d0e2912 commit 5d267f8
Show file tree
Hide file tree
Showing 145 changed files with 5,888 additions and 9,691 deletions.
10 changes: 8 additions & 2 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ vars.Add('LINKFLAGS', 'Set additional Linker-flags, they are linker-depended (mu
vars.Add('CPPPATH', 'Set paths where to look for additional headers', '')
vars.Add('LIBPATH', 'Set paths where to look for additional libs', '')
# define the target
vars.Add('MARCH', 'Sets the architecture if compiling with gcc, this is a pass-through option: just specify the gcc options!', None)
vars.Add('TARGETCPU', "Sets the processor you are compiling for. 'default' means using gcc with standard configuration. Also available are: 'ICC', here Intel Compiler in version 11 or higher must be used", 'default')
vars.Add('ARCH', 'Sets the architecture if compiling with gcc, this is a pass-through option: just specify the gcc options!', 'avx')
vars.Add('COMPILER', "Sets the processor you are compiling for. 'gnu' means using gcc with standard configuration. Also available are: 'intel', here Intel Compiler in version 11 or higher must be used", 'gnu')
vars.Add(BoolVariable('OPT', "Sets optimization on and off", False))
# for compiling on LRZ without errors: omit unit tests
vars.Add(BoolVariable('NO_UNIT_TESTS', 'Omit UnitTests if set to True', False))
Expand All @@ -70,11 +70,17 @@ for moduleName in moduleNames:
vars.Add(BoolVariable(moduleName, 'Build the module ' + moduleName, True))

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')
vars.Add(BoolVariable('USE_OCL', 'Sets OpenCL enabled state (Only actually enabled if also the OpenCL environment variables are set)', False))
vars.Add('OCL_INCLUDE_PATH', 'Specifies the location of the OpenCL header files (parent directory of "CL/").')
vars.Add('OCL_LIBRARY_PATH', 'Specifies the location of the OpenCL library.')
vars.Add('BOOST_INCLUDE_PATH', 'Specifies the location of the boost header files.', '/usr/include')
vars.Add('BOOST_LIBRARY_PATH', 'Specifies the location of the boost library.', '/usr/lib64')
vars.Add(BoolVariable('COMPILE_BOOST_TESTS', 'Compile the test cases written using Boost Test.', True))
vars.Add(BoolVariable('COMPILE_BOOST_PERFORMANCE_TESTS', 'Compile the performance tests written using Boost Test.', True))
vars.Add(BoolVariable('RUN_BOOST_TESTS', 'Run the test cases written using Boost Test (only if COMPILE_BOOST_TESTS is true).', True))
vars.Add(BoolVariable('USE_DOUBLE_PRECISION', 'If disabled, SG++ will compile using single precision (floats).', True))

Expand Down
30 changes: 11 additions & 19 deletions base/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,11 @@ Import('exampleTargetList')
moduleDependencies = []
Export('moduleDependencies')

additionalDependencies = []
if env['USE_OCL']:
moduleDependencies += ['OpenCL']

# srcs = []
# 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))
additionalDependencies += ['OpenCL']

moduleDependencies = additionalDependencies + moduleDependencies

objs = []
for currentFolder, subdirNames, fileNames in os.walk("src", topdown=True):
Expand Down Expand Up @@ -90,13 +83,13 @@ else:

libInstall = env.Install(BUILD_DIR, lib)

for fileName in os.listdir("examples"):
if fnmatch.fnmatch(fileName, "*.cpp"):
example = env.Program(source=os.path.join("examples", fileName),
LIBPATH=BUILD_DIR,
LIBS=[libname] + moduleDependencies)
env.Requires(example, libInstall)
exampleTargetList.append(example)
if env["ARCH"] != "MIC":
for fileName in os.listdir("examples"):
if fnmatch.fnmatch(fileName, "*.cpp"):
example = env.Program(source=os.path.join("examples", fileName),
LIBS=[libname] + moduleDependencies)
env.Requires(example, libInstall)
exampleTargetList.append(example)

# build unit tests
if env['COMPILE_BOOST_TESTS']:
Expand Down Expand Up @@ -125,4 +118,3 @@ if env['COMPILE_BOOST_TESTS']:

libraryTargetList.append(lib)
installTargetList.append(libInstall)

1 change: 0 additions & 1 deletion base/doc/doxygen/development.doxy
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ If you modify existing code, do not forget
to make sure that no new errors are introduced. If you write new
functionalities, do @em always add unit tests for each functionality!


<!-- ############################################################# -->
@section development__doxygen Doxygen

Expand Down
2 changes: 1 addition & 1 deletion base/src/sgpp/base/application/ScreenOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,4 @@ namespace SGPP {
}

}
}
}
11 changes: 11 additions & 0 deletions base/src/sgpp/base/datatypes/DataMatrix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,17 @@ namespace SGPP {
return data[row * ncols + col];
}

/**
* Returns the i-th element.
* For the 5th element in the third row, i would be 2*getNcols()+4.
*
* @param i position of the element
* @return data[i]
*/
inline float_t& operator[](size_t i) {
return data[i];
};

/**
* Returns the value of the element at position [row,col]
*
Expand Down
133 changes: 62 additions & 71 deletions base/src/sgpp/base/opencl/LinearLoadBalancer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,75 +9,68 @@

#include <sgpp/globaldef.hpp>

#include <sgpp/base/tools/ConfigurationParameters.hpp>
#include <sgpp/base/opencl/OCLOperationConfiguration.hpp>

namespace SGPP {
namespace base {

class LinearLoadBalancer {
private:
size_t deviceCount;
base::ConfigurationParameters& parameters;
double* weights;
double* partition;
public:
LinearLoadBalancer(OCLManager& manager,
base::ConfigurationParameters& parameters) :
deviceCount(manager.num_devices), parameters(parameters) {
this->weights = new double[manager.num_devices];
this->partition = new double[manager.num_devices];

for (size_t i = 0; i < manager.num_devices; i++) {
namespace base {

class LinearLoadBalancer {
private:
size_t deviceCount;
std::shared_ptr<base::OCLOperationConfiguration> parameters;
double* weights;
double* partition;
public:
LinearLoadBalancer(std::shared_ptr<OCLManager> manager, std::shared_ptr<base::OCLOperationConfiguration> parameters) :
deviceCount(manager->num_devices), parameters(parameters) {
this->weights = new double[manager->num_devices];
this->partition = new double[manager->num_devices];

for (size_t i = 0; i < manager->num_devices; i++) {
//initialize with same timing to enforce equal problem sizes in the beginning
this->partition[i] = 1.0 / static_cast<double>(manager.num_devices);
}
this->partition[i] = 1.0 / static_cast<double>(manager->num_devices);
}
}

~LinearLoadBalancer() {
delete[] this->weights;
delete[] this->partition;
}
~LinearLoadBalancer() {
delete[] this->weights;
delete[] this->partition;
}

void getPartitionSegments(size_t start, size_t end, size_t blockSize,
size_t* segmentStart, size_t* segmentEnd) {
bool setVerboseLoadBalancing = parameters.getAsBoolean(
"LINEAR_LOAD_BALANCING_VERBOSE");
size_t totalSize = end - start;
void getPartitionSegments(size_t start, size_t end, size_t blockSize, size_t* segmentStart, size_t* segmentEnd) {
bool setVerboseLoadBalancing = (*parameters)["LOAD_BALANCING_VERBOSE"].getBool();
size_t totalSize = end - start;

// check for valid input
if (blockSize == 0) {
throw SGPP::base::operation_exception(
"blockSize must not be zero!");
}
// check for valid input
if (blockSize == 0) {
throw SGPP::base::operation_exception("blockSize must not be zero!");
}

if (totalSize % blockSize != 0) {
if (totalSize % blockSize != 0) {
throw SGPP::base::operation_exception(
"totalSize must be divisible by blockSize without remainder, but it is not!");
}
"totalSize must be divisible by blockSize without remainder, but it is not!");
}

size_t currentStartIndex = start;
size_t currentStartIndex = start;

for (size_t i = 0; i < this->deviceCount; i++) {
size_t partitionElements =
static_cast<size_t>(static_cast<double>(totalSize)
* partition[i]);
for (size_t i = 0; i < this->deviceCount; i++) {
size_t partitionElements = static_cast<size_t>(static_cast<double>(totalSize) * partition[i]);

if (currentStartIndex != end && partitionElements == 0) {
partitionElements = 1;
partitionElements = 1;
}

//last device has to ensure that all data is in one partition
if (currentStartIndex + partitionElements > end
|| i == this->deviceCount - 1) {
partitionElements = end - currentStartIndex;
if (currentStartIndex + partitionElements > end || i == this->deviceCount - 1) {
partitionElements = end - currentStartIndex;
}

//employ padding
size_t remainder = partitionElements % blockSize;
size_t padding = 0;

if (remainder != 0) {
padding = blockSize - remainder;
padding = blockSize - remainder;
}

partitionElements += padding;
Expand All @@ -86,53 +79,51 @@ namespace SGPP {
segmentEnd[i] = currentStartIndex + partitionElements;

if (setVerboseLoadBalancing) {
std::cout << "device: " << i << " from: " << segmentStart[i]
<< " to: " << segmentEnd[i] << std::endl;
std::cout << "device: " << i << " from: " << segmentStart[i] << " to: " << segmentEnd[i] << std::endl;
}

currentStartIndex += partitionElements;
}
}
}

void update(double* timings) {
bool setVerboseLoadBalancing = parameters.getAsBoolean(
"LINEAR_LOAD_BALANCING_VERBOSE");
//TODO: consider inactive device due to nothing to do?
void update(double* timings) {
bool setVerboseLoadBalancing = (*parameters)["LOAD_BALANCING_VERBOSE"].getBool();

//recalculate weights
for (size_t i = 0; i < this->deviceCount; i++) {
//recalculate weights
for (size_t i = 0; i < this->deviceCount; i++) {
weights[i] = timings[i] / partition[i];
}
}

//calculate the optimal duration
double t = 0.0;
//calculate the optimal duration
double t = 0.0;

for (size_t i = 0; i < this->deviceCount; i++) {
for (size_t i = 0; i < this->deviceCount; i++) {
t += 1.0 / weights[i];
}
}

t = 1.0 / t;
t = 1.0 / t;

if (setVerboseLoadBalancing) {
if (setVerboseLoadBalancing) {
std::cout << "t: " << t << std::endl;
}
}

//calculate optimal partition
for (size_t i = 0; i < this->deviceCount; i++) {
//calculate optimal partition
for (size_t i = 0; i < this->deviceCount; i++) {
if (t == 0.0) {
partition[i] = 1.0 / static_cast<double>(this->deviceCount);
partition[i] = 1.0 / static_cast<double>(this->deviceCount);
} else {
partition[i] = t / weights[i];
partition[i] = t / weights[i];
}

if (setVerboseLoadBalancing) {
std::cout << "device: " << i << " partition size: "
<< partition[i] << std::endl;
std::cout << "device: " << i << " partition size: " << partition[i] << std::endl;
}
}
}
}

};
};

}
}
}

Loading

0 comments on commit 5d267f8

Please sign in to comment.