Exemplo n.º 1
0
        // Perform the MPI scatter
        public void Scatter()
        {
            Stopwatch scatterTimer = Stopwatch.StartNew();

            TDistance[][][] sentBlockValues = new TDistance[MPI.Intracommunicator.world.Size][][];

            _partialMatrix = _partialMatrix.Transpose();
            for (int k = 0; k < _processBlocks[_rank].Length; k++)
            {
                Block block = _processBlocks[_rank][k].Transpose();
                sentBlockValues[k] = _partialMatrix.GetBlockValues(block);
            }
            _partialMatrix = _partialMatrix.Transpose();

            for (int receivedRank = 0; receivedRank < MPI.Intracommunicator.world.Size; receivedRank++)
            {
                TDistance[][] transposedBlockValues = MPI.Intracommunicator.world.Scatter <TDistance[][]>(sentBlockValues, receivedRank);
                int           rowIndex    = _rank;
                int           columnIndex = receivedRank;

                if ((rowIndex < columnIndex) && !IsOdd(rowIndex + columnIndex))
                {
                    _partialMatrix.SetBlockValues(_processBlocks[rowIndex][columnIndex], transposedBlockValues);
                }

                if ((rowIndex > columnIndex) && IsOdd(rowIndex + columnIndex))
                {
                    _partialMatrix.SetBlockValues(_processBlocks[rowIndex][columnIndex], transposedBlockValues);
                }
            }

            _mpiScatterTime = scatterTimer.ElapsedMilliseconds;
        }
Exemplo n.º 2
0
 public MPIComputeLowerTriangularBlocked(int size, ComputeBlockHandler blockHandler)
 {
     _size             = size;
     _blockHander      = blockHandler;
     _rank             = MPI.Intracommunicator.world.Rank;
     _processBlocks    = BlockPartitioner.Partition(size, size, MPI.Intracommunicator.world.Size, MPI.Intracommunicator.world.Size);
     _processRowRanges = RangePartitioner.Partition(size, MPI.Intracommunicator.world.Size);
     _processRowRange  = _processRowRanges[MPI.Intracommunicator.world.Rank];
     _partialMatrix    = new PartialMatrix <TDistance>(_processRowRange.StartIndex, _processRowRange.EndIndex, 0, size - 1);
 }
Exemplo n.º 3
0
        static int ComputeBlock(Block block, PartialMatrix <TDistance> matrix, bool isDiagonal)
        {
            int count = 0;
            SmithWatermanGotoh aligner       = new SmithWatermanGotoh(_alignmentType);
            ScoringMatrix      scoringMatrix = ScoringMatrix.Load(_scoringMatrixName);

            if (isDiagonal)
            {
                for (int i = block.RowRange.StartIndex; i <= block.RowRange.EndIndex; i++)
                {
                    Sequence si = _sequences[i];

                    for (int j = block.ColumnRange.StartIndex; j < i; j++)
                    {
                        Sequence sj = _sequences[j];

                        PairwiseAlignment alignment = aligner.Align(si, sj, scoringMatrix, _gapOpen, _gapExtension);

                        if ((_writeAlignments) && (_writeAlignmentsWriter != null))
                        {
                            WriteAlignment(_writeAlignmentsWriter, alignment);
                        }

                        matrix[i, j] = matrix[j, i] = ComputeDistance(alignment);

                        count++;
                    }
                }
            }
            else
            {
                for (int i = block.RowRange.StartIndex; i <= block.RowRange.EndIndex; i++)
                {
                    Sequence si = _sequences[i];

                    for (int j = block.ColumnRange.StartIndex; j <= block.ColumnRange.EndIndex; j++)
                    {
                        Sequence sj = _sequences[j];

                        PairwiseAlignment alignment = aligner.Align(si, sj, scoringMatrix, _gapOpen, _gapExtension);

                        if ((_writeAlignments) && (_writeAlignmentsWriter != null))
                        {
                            WriteAlignment(_writeAlignmentsWriter, alignment);
                        }

                        matrix[i, j] = ComputeDistance(alignment);

                        count++;
                    }
                }
            }

            return(count);
        }