本文整理汇总了C++中SC_StringArray::SearchForKey方法的典型用法代码示例。如果您正苦于以下问题:C++ SC_StringArray::SearchForKey方法的具体用法?C++ SC_StringArray::SearchForKey怎么用?C++ SC_StringArray::SearchForKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SC_StringArray
的用法示例。
在下文中一共展示了SC_StringArray::SearchForKey方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MPIMasterRun
static void MPIMasterRun(const char* MPIappID, int maxMPIRank)
{
// all msgs for master ...
NodeFile::mpiDebugRun = true;
SC_StringArray machineNames;
machineNames.SetStringLen(maxNameLen);
machineNames.Alloc(maxMPIRank);
machineNames.SetString(processorName, 0);
// get slave processor name
MPI_Status status;
for (int i = 1; i < maxMPIRank; i++)
{
CheckMPI(MPI_Recv(processorName, maxNameLen, MPI_CHAR, i, mpiTag_ProcName, MPI_COMM_WORLD, &status), "Master get slave names");
int currRank = status.MPI_SOURCE;
if (currRank != i)
GenAppInternalError("Unexpected slave rank on slave processor name");
machineNames.SetString(processorName, i);
}
time_t stTime;
bool stTimeOK = false;
char timeLab[80];
const char* timeFormat = "%x %X";
if (time(&stTime) != -1)
{
#ifdef MSCVS2005
tm tmOut;
localtime_s(&tmOut, &stTime);
strftime(timeLab, 80, timeFormat, &tmOut);
#else
strftime(timeLab, 80, timeFormat, localtime(&stTime));
#endif
GenAppInfoMsg("Master start time", timeLab);
stTimeOK = true;
}
bool isOptRun = MPIOptimizationRun();
int nRuns;
if (isOptRun)
{
GenAppInfoMsg("MPI Run","Optimization only");
}
else
{
nRuns = MPIGetNCases();
char nrunstr[10];
IntToString(nRuns, nrunstr, 10);
GenAppInfoMsg("Number of runs", nrunstr);
}
int nSlaves = maxMPIRank - 1;
if (nRuns < nSlaves)
nSlaves = nRuns;
MPIMasterInit(nSlaves);
if (isOptRun)
{
MPIRunOptimizationMaster(nSlaves);
}
else
{
MPIMasterSampling(nSlaves, maxMPIRank);
}
GenAppInfoMsg(MPIappID, "master run complete");
MPIMasterCleanup(nSlaves);
if (!isOptRun)
{
using namespace std;
cout << endl << "Slave Summary" << endl;
SC_IntArray processorCount(maxMPIRank, 0);
for (int i = 0; i < nSlaves; i++)
{
cout << "Slave " << i + 1 << " processed " << indexCount[i] << " runs" << endl;
processorCount[machineNames.SearchForKey(machineNames[i + 1])] += indexCount[i];
}
cout << endl << "Machine Summary" << endl;
for (int i = 0; i < maxMPIRank; i++)
if (processorCount[i] > 0)
cout << "Machine " << machineNames[i] << " processed " << processorCount[i] << " runs" << endl;
cout << endl;
}
GenAppInfoMsg(MPIappID, "all cases completed OK");
time_t endTime;
if (stTimeOK && (time(&endTime) != -1))
{
// write start time again
GenAppInfoMsg("Master start time", timeLab);
//.........这里部分代码省略.........