SG++-Doxygen-Documentation
sgpp::datadriven::PartitioningTool Class Reference

The methods in this class calculate size and offset of a segment for a partition of a domain. More...

#include <PartitioningTool.hpp>

Public Member Functions

 PartitioningTool ()
 

Static Public Member Functions

static void calcAlmostBlockedDistribution (size_t totalSize, size_t numChunksPerProc, int *sizes, int *offsets, size_t blocksize)
 
static void calcDistribution (size_t totalSize, size_t numChunks, int *sizes, int *offsets, size_t blocksize=1)
 calcDistribution calculates a distribution of a domain of size totalSize into numCunks chunks and fills the two arrays sizes and offsets with the respective offsets and sizes (both arrays have to be already allocated and must be of size numChunks). More...
 
static void getOpenMPPartitionSegment (size_t totalSize, size_t *size, size_t *offset, size_t blocksize=1)
 getOpenMPLoopPartitionSegment uses the number of OpenMP Threads and the threads id for segmentCount and segmentNumber More...
 
static void getOpenMPPartitionSegment (size_t start, size_t end, size_t *segmentStart, size_t *segmentEnd, size_t blocksize=1)
 
static void getPartitionSegment (size_t totalSize, size_t segmentCount, size_t segmentNumber, size_t *size, size_t *offset, size_t blocksize=1)
 
static void getPartitionSegment (size_t start, size_t end, size_t segmentCount, size_t segmentNumber, size_t *segmentStart, size_t *segmentEnd, size_t blocksize=1)
 

Detailed Description

The methods in this class calculate size and offset of a segment for a partition of a domain.

The domain can be either specified by its size (totalSize) or by start (including) and end (excluding) indexes. Then, the number of resulting segments (segmentCount) and the number of the desired segment (segmentNumber) have to be passed. The results are stored into size and offset. The last (and optional) parameter blocksize specifies how the segments should be aligned to blocks. The complete size must be evenly divisible by the blocksize.

Segments are distributed as equally as possible (the difference between the minimum and maximum number of items is at most blocksize). When just dividing (integer division) and leaving the rest to the last segment, this segment could have twice as much to do as all the others (example: totalSize=127, segmentCount = 16, blockSize = 1)

Parameters
totalSizesize of domain that's to be partitioned
startstart of domain that's to be partitioned, including
endend of domain that's to be partitioned, excluding
segmentCountnumber of segments to partition the domain into
segmentNumberspecifies the number of the fragment for which to calculate size and offset
sizeoutput variable to put resulting size into
offsetoutput variable to put resulting offset into

Constructor & Destructor Documentation

◆ PartitioningTool()

sgpp::datadriven::PartitioningTool::PartitioningTool ( )

Member Function Documentation

◆ calcAlmostBlockedDistribution()

static void sgpp::datadriven::PartitioningTool::calcAlmostBlockedDistribution ( size_t  totalSize,
size_t  numChunksPerProc,
int *  sizes,
int *  offsets,
size_t  blocksize 
)
static

◆ calcDistribution()

void sgpp::datadriven::PartitioningTool::calcDistribution ( size_t  totalSize,
size_t  numChunks,
int *  sizes,
int *  offsets,
size_t  blocksize = 1 
)
static

calcDistribution calculates a distribution of a domain of size totalSize into numCunks chunks and fills the two arrays sizes and offsets with the respective offsets and sizes (both arrays have to be already allocated and must be of size numChunks).

When blocksize greater than 1, then the resulting sizes are a multiple of this blocksize.

Example:

|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .| calcDistribution(50, 3, sizes, offsets, 5) -> |. . . . .-. . . . .-. . . . .-. . . . .|. . . . .-. . . . .-. . . . .|. . . . .-. . . . .-. . . . .|

sizes: [20,15,15] offsets: [0,20,35]

Parameters
totalSizesize of domain to distribute
numChunks
sizesoutput array to store resulting distribution sizes (array size must be numChunks)
offsetsoutput array to store resulting distribution offsets (array size must be numChunks)
blocksizeresulting sizes are a multiple of this blocksize.

References getPartitionSegment().

◆ getOpenMPPartitionSegment() [1/2]

void sgpp::datadriven::PartitioningTool::getOpenMPPartitionSegment ( size_t  totalSize,
size_t *  size,
size_t *  offset,
size_t  blocksize = 1 
)
static

getOpenMPLoopPartitionSegment uses the number of OpenMP Threads and the threads id for segmentCount and segmentNumber

Call this function inside a parallel openmp region. Can also be called if only one Thread is active or even if OpenMP is disabled, then the result is one single partition.

Referenced by sgpp::datadriven::AbstractOperationMultipleEvalSubspace::mult(), and sgpp::datadriven::AbstractOperationMultipleEvalSubspace::multTranspose().

◆ getOpenMPPartitionSegment() [2/2]

void sgpp::datadriven::PartitioningTool::getOpenMPPartitionSegment ( size_t  start,
size_t  end,
size_t *  segmentStart,
size_t *  segmentEnd,
size_t  blocksize = 1 
)
static

References getPartitionSegment().

◆ getPartitionSegment() [1/2]

void sgpp::datadriven::PartitioningTool::getPartitionSegment ( size_t  totalSize,
size_t  segmentCount,
size_t  segmentNumber,
size_t *  size,
size_t *  offset,
size_t  blocksize = 1 
)
static

◆ getPartitionSegment() [2/2]

void sgpp::datadriven::PartitioningTool::getPartitionSegment ( size_t  start,
size_t  end,
size_t  segmentCount,
size_t  segmentNumber,
size_t *  segmentStart,
size_t *  segmentEnd,
size_t  blocksize = 1 
)
static

References python.leja::start.


The documentation for this class was generated from the following files: