コード例 #1
0
ファイル: myrimatchMPI.cpp プロジェクト: lgatto/proteowizard
    int ReceiveUnpreparedSpectraBatchFromRootProcess()
    {
        int batchSize;

        MPI_Ssend( &g_pid,        1,    MPI_INT,        0,    0xFF, MPI_COMM_WORLD );
        string pack;
        int len;

        #ifdef MPI_DEBUG
            cout << g_hostString << " is receiving a batch of unsequenced spectra." << endl;
            Timer receiveTime(true);
        #endif
        MPI_Recv( &len,                    1,            MPI_INT,    0,    0x00, MPI_COMM_WORLD, &st );
        pack.resize( len );
        MPI_Recv( (void*) pack.data(),    len,        MPI_CHAR,    0,    0x01, MPI_COMM_WORLD, &st );

        stringstream compressedStream( pack );
        stringstream packStream;
        boost::iostreams::filtering_ostream decompressorStream;
        decompressorStream.push( boost::iostreams::zlib_decompressor() );
        decompressorStream.push( packStream );
        boost::iostreams::copy( compressedStream, decompressorStream );
        decompressorStream.reset();

        binary_iarchive packArchive( packStream );

        try
        {
            packArchive & batchSize;

            if( !batchSize )
            {
                #ifdef MPI_DEBUG
                    cout << g_hostString << " is informed that all spectra have been sequence tagged." << endl;
                #endif

                return 0; // do not expect another batch
            }

            #ifdef MPI_DEBUG
                cout << g_hostString << " finished receiving a batch of " << batchSize << " unsequenced spectra; " <<
                        receiveTime.End() << " seconds elapsed." << endl;
            #endif

            for( int j=0; j < batchSize; ++j )
            {
                Spectrum* s = new Spectrum;
                packArchive & *s;
                spectra.push_back( s );

            }
        } catch( exception& e )
        {
            cerr << g_hostString << " had an error: " << e.what() << endl;
            exit(1);
        }

        return 1; // expect another batch
    }
コード例 #2
0
ファイル: myrimatchMPI.cpp プロジェクト: lgatto/proteowizard
    int ReceiveSpectraFromRootProcess()
    {
        int numSpectra;
        int done;

        #ifdef MPI_DEBUG
            cout << g_hostString << " is receiving " << numSpectra << " unprepared spectra." << endl;
            Timer receiveTime(true);
        #endif

        string pack;
        int len;

        MPI_Recv( &len,                    1,            MPI_INT,    0,    0x00, MPI_COMM_WORLD, &st );
        pack.resize( len );
        MPI_Recv( (void*) pack.data(),    len,        MPI_CHAR,    0,    0x01, MPI_COMM_WORLD, &st );

        stringstream compressedStream( pack );
        stringstream packStream;
        boost::iostreams::filtering_ostream decompressorStream;
        decompressorStream.push( boost::iostreams::zlib_decompressor() );
        decompressorStream.push( packStream );
        boost::iostreams::copy( compressedStream, decompressorStream );
        decompressorStream.reset();

        binary_iarchive packArchive( packStream );

        try
        {
            //cout << g_hostString << " is unpacking spectra." << endl;
            packArchive & numSpectra;
            //cout << g_hostString << " has " << numSpectra << " spectra." << endl;
            packArchive & done;

            for( int j=0; j < numSpectra; ++j )
            {
                Spectrum* s = new Spectrum;
                packArchive & *s;
                spectra.push_back( s );

            }
            //cout << g_hostString << " is finished unpacking spectra." << endl;
        } catch( exception& e )
        {
            cerr << g_hostString << " had an error: " << e.what() << endl;
            exit(1);
        }

        #ifdef MPI_DEBUG
            cout << g_hostString << " finished receiving " << numSpectra << " unprepared spectra; " <<
                    receiveTime.End() << " seconds elapsed." << endl;
        #endif

        return done;
    }
コード例 #3
0
// returns true if something changed
bool Clipboard::UpdateClipTextEx(ClipboardData& clipboardData, CARD32 overrideFlags)
{
	if (m_crc == clipboardData.m_crc && overrideFlags == 0) {
		return false;
	}

	if (overrideFlags & clipPeek) {
		// don't reset anything regarding providing new data, just 'include' any
		// formats into the notify response.
		if (clipboardData.m_lengthText != 0) {
			extendedClipboardDataNotifyMessage.AddFlag(clipText);
			m_bNeedToNotify = true;
		}
		if (clipboardData.m_lengthRTF != 0) {
			extendedClipboardDataNotifyMessage.AddFlag(clipRTF);
			m_bNeedToNotify = true;
		}
		if (clipboardData.m_lengthHTML != 0) {
			extendedClipboardDataNotifyMessage.AddFlag(clipHTML);
			m_bNeedToNotify = true;
		}
		if (clipboardData.m_lengthDIB != 0) {
			extendedClipboardDataNotifyMessage.AddFlag(clipDIB);
			m_bNeedToNotify = true;
		}
	} else {

		m_bNeedToProvide = false;
		m_bNeedToNotify = false;
		extendedClipboardDataMessage.Reset();
		extendedClipboardDataNotifyMessage.Reset();

		extendedClipboardDataMessage.AddFlag(clipProvide);
		extendedClipboardDataNotifyMessage.AddFlag(clipNotify);

		rdr::MemOutStream memStream;
		{
			rdr::ZlibOutStream compressedStream(&memStream, 0, 9); //Z_BEST_COMPRESSION

			if (clipboardData.m_lengthText != 0) {
				extendedClipboardDataNotifyMessage.AddFlag(clipText);

				if (clipboardData.m_lengthText <= settings.m_nLimitText || (overrideFlags & clipText)) {
					compressedStream.writeU32(clipboardData.m_lengthText);
					compressedStream.writeBytes(clipboardData.m_pDataText, clipboardData.m_lengthText);
					extendedClipboardDataMessage.AddFlag(clipText);
					m_bNeedToProvide = true;
				} else {
					m_bNeedToNotify = true;
				}
			}
			if (clipboardData.m_lengthRTF != 0) {
				extendedClipboardDataNotifyMessage.AddFlag(clipRTF);

				if (clipboardData.m_lengthRTF <= settings.m_nLimitRTF || (overrideFlags & clipRTF)) {
					compressedStream.writeU32(clipboardData.m_lengthRTF);
					compressedStream.writeBytes(clipboardData.m_pDataRTF, clipboardData.m_lengthRTF);
					extendedClipboardDataMessage.AddFlag(clipRTF);
					m_bNeedToProvide = true;
				} else {
					m_bNeedToNotify = true;
				}
			}
			if (clipboardData.m_lengthHTML != 0) {
				extendedClipboardDataNotifyMessage.AddFlag(clipHTML);

				if (clipboardData.m_lengthHTML <= settings.m_nLimitHTML || (overrideFlags & clipHTML)) {
					compressedStream.writeU32(clipboardData.m_lengthHTML);
					compressedStream.writeBytes(clipboardData.m_pDataHTML, clipboardData.m_lengthHTML);
					extendedClipboardDataMessage.AddFlag(clipHTML);
					m_bNeedToProvide = true;
				} else {
					m_bNeedToNotify = true;
				}
			}
			if (clipboardData.m_lengthDIB != 0) {
				extendedClipboardDataNotifyMessage.AddFlag(clipDIB);

				if (clipboardData.m_lengthDIB <= settings.m_nLimitDIB || (overrideFlags & clipDIB)) {
					compressedStream.writeU32(clipboardData.m_lengthDIB);
					compressedStream.writeBytes(clipboardData.m_pDataDIB, clipboardData.m_lengthDIB);
					extendedClipboardDataMessage.AddFlag(clipDIB);
					m_bNeedToProvide = true;
				} else {
					m_bNeedToNotify = true;
				}
			}

			compressedStream.flush();
		}

		if (m_bNeedToProvide) {
			extendedClipboardDataMessage.AppendBytes((BYTE*)memStream.data(), memStream.length());
			memStream.clear();
		}

		m_strLastCutText = "";
		if (!settings.m_bSupportsEx && clipboardData.m_lengthText > 0 && clipboardData.m_lengthText < settings.m_nLimitText) {			
			// now we have to translate to UTF-16
			int nConvertedSize = MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)clipboardData.m_pDataText, clipboardData.m_lengthText, NULL, 0);

			if (nConvertedSize > 0) {
				wchar_t* clipStr = new wchar_t[nConvertedSize];
				int nFinalConvertedSize = MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)clipboardData.m_pDataText, clipboardData.m_lengthText, (LPWSTR)clipStr, nConvertedSize);

				if (nFinalConvertedSize > 0) {
					std::wstring wstrClipboard(clipStr);
					m_strLastCutText.assign(wstrClipboard.begin(), wstrClipboard.end());
				}

				delete[] clipStr;
			}
		}

		m_crc = clipboardData.m_crc;

		if ( (!(settings.m_remoteCaps & clipNotify)) || (overrideFlags != 0) ) {
			m_bNeedToNotify = false;
			extendedClipboardDataNotifyMessage.Reset();
		}
	}

	return m_bNeedToProvide || m_bNeedToNotify;
}
コード例 #4
0
ファイル: myrimatchMPI.cpp プロジェクト: lgatto/proteowizard
    int ReceiveResultsFromChildProcesses(bool firstBatch = false)
    {
        int numSpectra;
        int sourceProcess;

        Timer ResultsTime( true );
        float totalResultsTime = 0.01f;
        float lastUpdate = 0.0f;

        for( int p=0; p < g_numChildren; ++p )
        {
            MPI_Recv( &sourceProcess,        1,        MPI_INT,    MPI_ANY_SOURCE,    0xEE, MPI_COMM_WORLD, &st );

            #ifdef MPI_DEBUG
                cout << g_hostString << " is receiving search results." << endl;
                Timer receiveTime(true);
            #endif

            string pack;
            int len;

            MPI_Recv( &len,                    1,        MPI_INT,    sourceProcess,    0x00, MPI_COMM_WORLD, &st );
            pack.resize( len );
            MPI_Recv( (void*) pack.data(),    len,    MPI_CHAR,    sourceProcess,    0x01, MPI_COMM_WORLD, &st );

            stringstream compressedStream( pack );
            stringstream packStream;
            boost::iostreams::filtering_ostream decompressorStream;
            decompressorStream.push( boost::iostreams::zlib_decompressor() );
            decompressorStream.push( packStream );
            boost::iostreams::copy( compressedStream, decompressorStream );
            decompressorStream.reset();

            binary_iarchive packArchive( packStream );

            try
            {
                SearchStatistics childSearchStats;
                packArchive & numSpectra;
                packArchive & childSearchStats;
                if(firstBatch)
                {
                    searchStatistics = searchStatistics + childSearchStats;
                }
                else 
                {
                    searchStatistics.numPeptidesGenerated += childSearchStats.numPeptidesGenerated;
                    searchStatistics.numVariantsGenerated += childSearchStats.numVariantsGenerated;
                    searchStatistics.numComparisonsDone += childSearchStats.numComparisonsDone;
                    searchStatistics.numPeptidesSkipped += childSearchStats.numPeptidesSkipped;
                }

                //cout << g_hostString << " is unpacking results for " << numSpectra << " spectra." << endl;
                for( SpectraList::iterator sItr = spectra.begin(); sItr != spectra.end(); ++sItr )
                {
                    Spectrum* childSpectrum = new Spectrum;
                    Spectrum* rootSpectrum = *sItr;
                    packArchive & *childSpectrum;
                    rootSpectrum->numTargetComparisons += childSpectrum->numTargetComparisons;
                    rootSpectrum->numDecoyComparisons += childSpectrum->numDecoyComparisons;
                    rootSpectrum->processingTime += childSpectrum->processingTime;

                    rootSpectrum->resultsByCharge.resize(childSpectrum->resultsByCharge.size());
                    for (size_t z=0; z < childSpectrum->resultsByCharge.size(); ++z)
                    {
                        Spectrum::SearchResultSetType& rootResults = rootSpectrum->resultsByCharge[z];
                        Spectrum::SearchResultSetType& childResults = childSpectrum->resultsByCharge[z];

                        BOOST_FOREACH(const Spectrum::SearchResultPtr& result, childResults)
                            rootResults.add( result );

                        if (childResults.bestFullySpecificTarget().get()) rootResults.add(childResults.bestFullySpecificTarget());
                        if (childResults.bestFullySpecificDecoy().get()) rootResults.add(childResults.bestFullySpecificDecoy());
                        if (childResults.bestSemiSpecificTarget().get()) rootResults.add(childResults.bestSemiSpecificTarget());
                        if (childResults.bestSemiSpecificDecoy().get()) rootResults.add(childResults.bestSemiSpecificDecoy());
                        if (childResults.bestNonSpecificTarget().get()) rootResults.add(childResults.bestNonSpecificTarget());
                        if (childResults.bestNonSpecificDecoy().get()) rootResults.add(childResults.bestNonSpecificDecoy());
                    }

                    for(flat_map<int,int>::iterator itr = childSpectrum->mvhScoreDistribution.begin(); itr != childSpectrum->mvhScoreDistribution.end(); ++itr)
                        rootSpectrum->mvhScoreDistribution[(*itr).first] += (*itr).second;
                    for(flat_map<int,int>::iterator itr = childSpectrum->mzFidelityDistribution.begin(); itr != childSpectrum->mzFidelityDistribution.end(); ++itr)
                        rootSpectrum->mzFidelityDistribution[(*itr).first] += (*itr).second;
                    rootSpectrum->scoreHistogram += childSpectrum->scoreHistogram;
                    delete childSpectrum;
                }
                //cout << g_hostString << " is finished unpacking results." << endl;
            } catch( exception& e )
            {
                cerr << g_hostString << " had an error: " << e.what() << endl;
                exit(1);
            }

            #ifdef MPI_DEBUG
                cout << g_hostString << " finished receiving " << numSpectra << " search results; " <<
                        receiveTime.End() << " seconds elapsed.";
            #endif

            totalResultsTime = ResultsTime.TimeElapsed();
            if( ( totalResultsTime - lastUpdate > g_rtConfig->StatusUpdateFrequency ) || p+1 == g_numChildren )
            {
                float nodesPerSec = float(p+1) / totalResultsTime;
                float estimatedTimeRemaining = float(g_numChildren-p-1) / nodesPerSec;
                cout << "Received results from " << p+1 << " of " << g_numChildren << " worker nodes; " << nodesPerSec <<
                        " per second, " << estimatedTimeRemaining << " seconds remaining." << endl;
                lastUpdate = totalResultsTime;
            }

        }

        return 0;
    }