本文整理汇总了C++中ArrayDesc::getDistribution方法的典型用法代码示例。如果您正苦于以下问题:C++ ArrayDesc::getDistribution方法的具体用法?C++ ArrayDesc::getDistribution怎么用?C++ ArrayDesc::getDistribution使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArrayDesc
的用法示例。
在下文中一共展示了ArrayDesc::getDistribution方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Cx
std::shared_ptr<Array> GEMMPhysical::invokeMPI(std::vector< std::shared_ptr<Array> >& inputArrays,
const GEMMOptions options, std::shared_ptr<Query>& query,
ArrayDesc& outSchema)
{
//
// Everything about the execute() method concerning the MPI execution of the arrays
// is factored into this method. This does not include the re-distribution of data
// chunks into the ScaLAPACK distribution scheme, as the supplied inputArrays
// must already be in that scheme.
//
// + intersects the array chunkGrids with the maximum process grid
// + sets up the ScaLAPACK grid accordingly and if not participating, return early
// + start and connect to an MPI slave process
// + create ScaLAPACK descriptors for the input arrays
// + convert the inputArrays into in-memory ScaLAPACK layout in shared memory
// + call a "master" routine that passes the ScaLAPACK operator name, parameters,
// and shared memory descriptors to the ScaLAPACK MPI process that will do the
// actual computation.
// + wait for successful completion
// + construct an "OpArray" that make and Array API view of the output memory.
// + return that output array.
//
enum dummy {R=0, C=1}; // row column
enum dummy2 {AA=0, BB, CC, NUM_MATRICES}; // which matrix: alpha AA * BB + beta CC -> result
LOG4CXX_DEBUG(logger, "GEMMPhysical::invokeMPI(): begin");
size_t numArray = inputArrays.size();
if (numArray != NUM_MATRICES) { // for now ... may make CC optional when beta is 0, later
LOG4CXX_ERROR(logger, "GEMMPhysical::invokeMPI(): " << numArray << " != NUM_MATRICES " << size_t(NUM_MATRICES));
throw (SYSTEM_EXCEPTION(SCIDB_SE_INTERNAL, SCIDB_LE_OPERATION_FAILED)
<< "GEMMPhysical::invokeMPI(): requires 3 input Arrays/matrices.");
}
//
// Initialize the (emulated) BLACS and get the proces grid info
//
blacs::context_t blacsContext = doBlacsInit(inputArrays, query, "GEMMPhysical");
bool isParticipatingInScaLAPACK = blacsContext.isParticipating();
if (isParticipatingInScaLAPACK) {
checkBlacsInfo(query, blacsContext, "GEMMPhysical");
}
blacs::int_t NPROW=-1, NPCOL=-1, MYPROW=-1 , MYPCOL=-1 ;
scidb_blacs_gridinfo_(blacsContext, NPROW, NPCOL, MYPROW, MYPCOL);
LOG4CXX_TRACE(logger, "GEMMPhysical::invokeMPI() NPROW="<<NPROW<<", NPCOL="<<NPCOL);
//
// launch MPISlave if we participate
// TODO: move this down into the ScaLAPACK code ... something that does
// the doBlacsInit, launchMPISlaves, and the check that they agree
//
bool isParticipatingInMPI = launchMPISlaves(query, NPROW*NPCOL);
if (isParticipatingInScaLAPACK != isParticipatingInMPI) {
LOG4CXX_DEBUG(logger, "GEMMPhysical::invokeMPI():"
<< " isParticipatingInScaLAPACK " << isParticipatingInScaLAPACK
<< " isParticipatingInMPI " << isParticipatingInMPI);
throw (SYSTEM_EXCEPTION(SCIDB_SE_INTERNAL, SCIDB_LE_OPERATION_FAILED)
<< "GEMMPhysical::invokeMPI(): internal inconsistency in MPI slave launch.");
}
if (isParticipatingInMPI) {
LOG4CXX_DEBUG(logger, "GEMMPhysical::invokeMPI(): participating in MPI");
} else {
LOG4CXX_DEBUG(logger, "GEMMPhysical::invokeMPI(): not participating in MPI");
LOG4CXX_DEBUG(logger, "GEMMPhysical::invokeMPI(): only participating in redistribute of the input");
// redistribute to psScaLAPACK
// NOTE: this must be kept in sync with the particpatingInMPI version of the redistribute, below
// NOTE: this redistribution must be kept in sync with the particpatingInMPI redistributeInputArrays, above
for(size_t mat=0; mat < numArray; mat++ ) {
std::stringstream labelStream;
labelStream << "GEMMPhysical input[" << mat << "]";
std::shared_ptr<Array> tmpRedistedInput = redistributeInputArray(inputArrays[mat],
outSchema.getDistribution(),
query, labelStream.str());
bool wasConverted = (tmpRedistedInput != inputArrays[mat]) ; // only when redistribute was actually done (sometimes optimize away)
if (wasConverted) {
SynchableArray* syncArray = safe_dynamic_cast<SynchableArray*>(tmpRedistedInput.get());
syncArray->sync();
}
// free potentially large amount of memory, e.g. when inputArrays[mat] was significantly memory-materialized
inputArrays[mat].reset();
// TODO: validate that the redistribute brought no chunks to the instance by
// getting an array iterator and make sure it returns no chunks
// (factor to ScaLAPACKPhysical.cpp)
// after validating, we don't need tmpRedistedInput anymore, either
tmpRedistedInput.reset();
}
unlaunchMPISlavesNonParticipating();
return std::shared_ptr<Array>(new MemArray(outSchema,query)); // NOTE: must not happen before redistribute is done.
}
//
// get dimension information about the input arrays
// TODO: REFACTOR, this is a pattern in DLAs
//
//.........这里部分代码省略.........