Workspace_sptr GenericDataProcessorAlgorithm<Base>::assemble(const std::string &partialWSName, const std::string &outputWSName) { #ifdef MPI_BUILD std::string threadOutput = partialWSName; Workspace_sptr partialWS = AnalysisDataService::Instance().retrieve(partialWSName); IAlgorithm_sptr gatherAlg = createChildAlgorithm("GatherWorkspaces"); gatherAlg->setLogging(true); gatherAlg->setAlwaysStoreInADS(true); gatherAlg->setProperty("InputWorkspace", partialWS); gatherAlg->setProperty("PreserveEvents", true); gatherAlg->setPropertyValue("OutputWorkspace", outputWSName); gatherAlg->execute(); if (isMainThread()) threadOutput = outputWSName; #else UNUSED_ARG(outputWSName) const std::string &threadOutput = partialWSName; #endif Workspace_sptr outputWS = AnalysisDataService::Instance().retrieve(threadOutput); return outputWS; }
Workspace_sptr GenericDataProcessorAlgorithm<Base>::load(const std::string &inputData, const bool loadQuiet) { Workspace_sptr inputWS; // First, check whether we have the name of an existing workspace if (AnalysisDataService::Instance().doesExist(inputData)) { inputWS = AnalysisDataService::Instance().retrieve(inputData); } else { std::string foundFile = FileFinder::Instance().getFullPath(inputData); if (foundFile.empty()) { // Get facility extensions FacilityInfo facilityInfo = ConfigService::Instance().getFacility(); const std::vector<std::string> facilityExts = facilityInfo.extensions(); foundFile = FileFinder::Instance().findRun(inputData, facilityExts); } if (!foundFile.empty()) { Poco::Path p(foundFile); const std::string outputWSName = p.getBaseName(); IAlgorithm_sptr loadAlg = createChildAlgorithm(m_loadAlg); loadAlg->setProperty(m_loadAlgFileProp, foundFile); if (!loadQuiet) { loadAlg->setAlwaysStoreInADS(true); } // Set up MPI if available #ifdef MPI_BUILD // First, check whether the loader allows use to chunk the data if (loadAlg->existsProperty("ChunkNumber") && loadAlg->existsProperty("TotalChunks")) { m_useMPI = true; // The communicator containing all processes boost::mpi::communicator world; g_log.notice() << "Chunk/Total: " << world.rank() + 1 << "/" << world.size() << '\n'; loadAlg->setPropertyValue("OutputWorkspace", outputWSName); loadAlg->setProperty("ChunkNumber", world.rank() + 1); loadAlg->setProperty("TotalChunks", world.size()); } #endif loadAlg->execute(); if (loadQuiet) { inputWS = loadAlg->getProperty("OutputWorkspace"); } else { inputWS = AnalysisDataService::Instance().retrieve(outputWSName); } } else throw std::runtime_error( "DataProcessorAlgorithm::load could process any data"); } return inputWS; }
Workspace_sptr GenericDataProcessorAlgorithm<Base>::assemble(Workspace_sptr partialWS) { Workspace_sptr outputWS = partialWS; #ifdef MPI_BUILD IAlgorithm_sptr gatherAlg = createChildAlgorithm("GatherWorkspaces"); gatherAlg->setLogging(true); gatherAlg->setAlwaysStoreInADS(true); gatherAlg->setProperty("InputWorkspace", partialWS); gatherAlg->setProperty("PreserveEvents", true); gatherAlg->setPropertyValue("OutputWorkspace", "_total"); gatherAlg->execute(); if (isMainThread()) { outputWS = AnalysisDataService::Instance().retrieve("_total"); } #endif return outputWS; }