Issue with rowBlocksSize and ComputeRowBlocks function.
jpola opened this issue · 4 comments
Running the blas2 tests for SMALL/Reuters911/Reuters911.mtx matrix gives an issue with the rowBlocksSize. Checking the flow of the parameter I discovered that the issue is in clsparseCsrMetaCompute function.
The clsparseCsrMetaSize sets the upper bound of the rowBlocksSize, however the clsparseCsrMetaCompute returns higher value. In that case the next mapping returns CL_INVALID_VALUE error
// Compute the csr matrix meta data and fill in buffers
if( pCsrMatx->rowBlockSize )
{
//here the rowBlocksSize have value = 1738
clMemRAII< cl_ulong > rRowBlocks( control->queue( ), pCsrMatx->rowBlocks );
// after call of this function, the rowBlocksSize value is 1880
ComputeRowBlocks( (cl_ulong*)NULL, pCsrMatx->rowBlockSize, iCsrRowOffsets, pCsrMatx->num_rows, BLKSIZE, BLOCK_MULTIPLIER, ROWS_FOR_VECTOR, false );
//therefore this mapping fails.
cl_int mapStatus = 0;
cl_ulong* ulCsrRowBlocks = rRowBlocks.clMapMem( CL_TRUE, CL_MAP_WRITE_INVALIDATE_REGION, pCsrMatx->rowBlocksOffset( ), pCsrMatx->rowBlockSize, &mapStatus );
With this function where I keep track of the mapping status status :
pType* clMapMem( cl_bool clBlocking, const cl_map_flags clFlags, const size_t clOff, const size_t clSize, cl_int *clStatus = nullptr)
{
// Right now, we don't support returning an event to wait on
clBlocking = CL_TRUE;
cl_int _clStatus = 0;
clMem = static_cast< pType* >( ::clEnqueueMapBuffer( clQueue, clBuff, clBlocking, clFlags, clOff,
clSize * sizeof( pType ), 0, NULL, NULL, &_clStatus ) );
if (clStatus != nullptr)
{
*clStatus = _clStatus;
}
return clMem;
}
We can temporarily easily prevent from getting segfault in the code:
// Compute the csr matrix meta data and fill in buffers
if( pCsrMatx->rowBlockSize )
{
clMemRAII< cl_ulong > rRowBlocks( control->queue( ), pCsrMatx->rowBlocks );
ComputeRowBlocks( (cl_ulong*)NULL, pCsrMatx->rowBlockSize, iCsrRowOffsets, pCsrMatx->num_rows, BLKSIZE, BLOCK_MULTIPLIER, ROWS_FOR_VECTOR, false );
// matrix SMALL/Reuters/Reuters911.mtx throws here segfault
// due to wrong estimation of rowBlockSize in function clsparseCsrMetaSize.
cl_int mapStatus = 0;
cl_ulong* ulCsrRowBlocks = rRowBlocks.clMapMem( CL_TRUE, CL_MAP_WRITE_INVALIDATE_REGION, pCsrMatx->rowBlocksOffset( ), pCsrMatx->rowBlockSize, &mapStatus );
if (mapStatus != CL_SUCCESS)
{
std::cerr << "Error: Row block estimation too low, invalid value returned from mapping" << std::endl;
return clsparseInvalidValue;
}
ComputeRowBlocks( ulCsrRowBlocks, pCsrMatx->rowBlockSize, iCsrRowOffsets, pCsrMatx->num_rows, BLKSIZE, BLOCK_MULTIPLIER, ROWS_FOR_VECTOR, true );
}
return clsparseSuccess;
By that all the matrices will be processed
Hi @jpola , I believe the patch merged above should fix this issue. Could you confirm?
Thanks.
The code is working correctly now. I tested that with all problematic
matrices like reutets and hydr1c
28 sie 2015 18:41 "Joseph Greathouse" notifications@github.com napisał(a):
Hi @jpola https://github.com/jpola , I believe the patch merged above
should fix this issue. Could you confirm?Thanks.
—
Reply to this email directly or view it on GitHub
#127 (comment)
.