Пример #1
0
BOOST_AUTO_TEST_CASE_TEMPLATE( buildTest, T, test_types ) 
{
    typedef T ValueType;

    PartitionId size = comm->getSize();

    int numRows = 3 * size;
    int numCols = 5 * size;

    scoped_array<ValueType> values( new ValueType[ numRows * numCols ] );

    for ( IndexType i = 0; i < numRows; ++i)
    {
        for ( IndexType j = 0; j < numCols; ++j )
        {
            ValueType value = static_cast<ValueType> ( i * numCols + j + 1.0 );
            values[ i * numCols + j ] = value;
        }
    }

    DenseMatrix<ValueType> repM;
    repM.setRawDenseData( numRows, numCols, values.get() );

    for ( IndexType i = 0; i < numRows; ++i )
    {
        for ( IndexType j = 0; j<numCols; ++j )
        {
            Scalar value = repM.getValue( i , j );
            Scalar expectedvalue = Scalar( static_cast<ValueType>(values[i * numCols + j]) );
            LAMA_CHECK_SCALAR_SMALL( value - expectedvalue, ValueType, eps<ValueType>() );
        }
    }

    shared_ptr<Distribution> dist( new BlockDistribution(numRows, comm) );
    shared_ptr<Distribution> distCol( new BlockDistribution(numCols, comm) );

    DenseMatrix<ValueType> distM( repM, dist, distCol );

    for (IndexType i = 0; i<numRows; ++i)
    {
        for (IndexType j = 0; j<numCols; ++j)
        {
            Scalar value = distM.getValue( i, j );
            Scalar expectedvalue = repM.getValue( i, j );
            LAMA_CHECK_SCALAR_SMALL( value - expectedvalue , ValueType, eps<ValueType>() );
        }
    }
}
Пример #2
0
void cyclicDistTestImpl( const IndexType chunkSize, const IndexType n )
{
    boost::scoped_array<float> values( new float[n * n] );
    for ( IndexType i = 0; i < n; ++i )
    {
        for ( IndexType j = 0; j < n; ++j )
        {
            values[i * n + j] = static_cast<float>( i * n + j );
        }
    }

    DenseMatrix<float> repMatrix;
    repMatrix.setRawDenseData( n, n, values.get() );

    boost::shared_ptr<Distribution> dist( new CyclicDistribution( n, chunkSize, comm ) );

    DenseMatrix<float> distMatrix( repMatrix, dist, dist );

    for ( IndexType i = 0; i < n; i++ )
    {
        for ( IndexType j = 0; j < n; j++ )
        {
            Scalar expectedvalue = repMatrix.getValue( i, j );
            Scalar value = distMatrix.getValue( i, j );
            Scalar diff = expectedvalue - value;
            LAMA_CHECK_SCALAR_SMALL( diff, float, 1E-8 );
        }
    }
}