Skip to content

Commit

Permalink
Refs #5340 row with EMPTY_INT() for no chunking
Browse files Browse the repository at this point in the history
  • Loading branch information
VickieLynch committed May 17, 2012
1 parent 3db7df8 commit eccf6b0
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 21 deletions.
26 changes: 20 additions & 6 deletions Code/Mantid/Framework/DataHandling/src/DetermineChunking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,17 @@ namespace DataHandling
double filesize = 0;
string runinfo = this->getPropertyValue(RUNINFO_PARAM);
std::string ext = this->extension(runinfo);

Mantid::API::ITableWorkspace_sptr strategy = Mantid::API::WorkspaceFactory::Instance().createTable("TableWorkspace");
strategy->addColumn("int","ChunkNumber");
strategy->addColumn("int","TotalChunks");
this->setProperty("OutputWorkspace", strategy);
if (maxChunk == 0 || maxChunk == EMPTY_DBL())
{
Mantid::API::TableRow row = strategy->appendRow();
row << EMPTY_INT() << EMPTY_INT();
return;
}
//PreNexus
if( ext.compare("xml") == 0)
{
vector<string> eventFilenames;
Expand All @@ -155,7 +165,8 @@ namespace DataHandling
filesize += static_cast<double>(eventfile->getNumElements()) * 48.0 / (1024.0*1024.0*1024.0);
}
}
else
//Event Nexus
else if( runinfo.compare(runinfo.size()-10,10,"_event.nxs") == 0)
{
// top level file information
::NeXus::File file(runinfo);
Expand Down Expand Up @@ -213,20 +224,23 @@ namespace DataHandling
// Factor fo 2 for compression
filesize = static_cast<double>(total_events) * 48.0 / (1024.0*1024.0*1024.0);
}
//Histo Nexus
else
{
Mantid::API::TableRow row = strategy->appendRow();
row << EMPTY_INT() << EMPTY_INT();
return;
}

int numChunks = static_cast<int>(filesize/maxChunk);
numChunks ++; //So maxChunkSize is not exceeded
if (numChunks < 0) numChunks = 1;
Mantid::API::ITableWorkspace_sptr strategy = Mantid::API::WorkspaceFactory::Instance().createTable("TableWorkspace");
strategy->addColumn("int","ChunkNumber");
strategy->addColumn("int","TotalChunks");

for (int i = 1; i <= numChunks; i++)
{
Mantid::API::TableRow row = strategy->appendRow();
row << i << numChunks;
}
this->setProperty("OutputWorkspace", strategy);
}
/// set the name of the top level NXentry m_top_entry_name
std::string DetermineChunking::setTopEntryName(std::string m_filename)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,21 +290,18 @@ def _getStrategy(self, runnumber, extension):
strategy = []
if HAVE_MPI:
comm = mpi.world
if self._chunks > 0 and not "histo" in extension and comm.size > 1:
Chunks = DetermineChunking(Filename=wksp+extension,MaxChunkSize=self._chunks,OutputWorkspace='Chunks').workspace()
for row in Chunks:
if (int(row["ChunkNumber"])-1)%comm.size == comm.rank:
strategy.append(row)
elif comm.size > 1:
strategy.append({'ChunkNumber':comm.rank+1,'TotalChunks':comm.size})
Chunks = DetermineChunking(Filename=wksp+extension,MaxChunkSize=self._chunks,OutputWorkspace='Chunks').workspace()
# What about no chunks for parallel?
if len(Chunks) == 1:
strategy.append({'ChunkNumber':comm.rank+1,'TotalChunks':comm.size})
else:
strategy.append({})
for row in Chunks:
if (int(row["ChunkNumber"])-1)%comm.size == comm.rank:
strategy.append(row)

else:
if self._chunks > 0 and not "histo" in extension:
Chunks = DetermineChunking(Filename=wksp+extension,MaxChunkSize=self._chunks,OutputWorkspace='Chunks').workspace()
for row in Chunks: strategy.append(row)
else:
strategy.append({})
Chunks = DetermineChunking(Filename=wksp+extension,MaxChunkSize=self._chunks,OutputWorkspace='Chunks').workspace()
for row in Chunks: strategy.append(row)

return strategy

Expand Down Expand Up @@ -335,10 +332,10 @@ def _focusChunks(self, runnumber, extension, filterWall, calib, filterLogs=None,
if HAVE_MPI and len(strategy) > 1:
alg = GatherWorkspaces(InputWorkspace=wksp, PreserveEvents=preserveEvents, AccumulationMethod="Add", OutputWorkspace=wksp)
wksp = alg['OutputWorkspace']
if self._chunks > 0 and not "histo" in extension:
if self._chunks > 0:
# When chunks are added, proton charge is summed for all chunks
wksp.getRun().integrateProtonCharge()
mtd.deleteWorkspace('Chunks')
mtd.deleteWorkspace('Chunks')
if preserveEvents and not "histo" in self.getProperty("Extension"):
CompressEvents(InputWorkspace=wksp, OutputWorkspace=wksp, Tolerance=COMPRESS_TOL_TOF) # 100ns
if normByCurrent:
Expand Down

0 comments on commit eccf6b0

Please sign in to comment.