1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
|
//------------------------------------------------------------------------------
// gb_usage: check usage and make sure GrB.init has been called
//------------------------------------------------------------------------------
// SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2022, All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
//------------------------------------------------------------------------------
#include "gb_interface.h"
void gb_usage // check usage and make sure GrB.init has been called
(
bool ok, // if false, then usage is not correct
const char *usage // error message if usage is not correct
)
{
//--------------------------------------------------------------------------
// clear the debug memory table (for debugging only)
//--------------------------------------------------------------------------
GB_Global_memtable_clear ( ) ;
//--------------------------------------------------------------------------
// make sure GrB.init has been called
//--------------------------------------------------------------------------
if (!GB_Global_GrB_init_called_get ( ))
{
//----------------------------------------------------------------------
// initialize GraphBLAS
//----------------------------------------------------------------------
OK (GxB_init (GrB_NONBLOCKING, mxMalloc, mxCalloc, mxRealloc, mxFree)) ;
// mxMalloc, mxCalloc, mxRealloc, and mxFree are not thread safe
GB_Global_malloc_is_thread_safe_set (false) ;
// must use mexPrintf to print to Command Window
OK (GxB_Global_Option_set (GxB_PRINTF, mexPrintf)) ;
OK (GxB_Global_Option_set (GxB_FLUSH, gb_flush)) ;
// disable the memory pool
int64_t free_pool_limit [64] =
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } ;
OK (GxB_Global_Option_set (GxB_MEMORY_POOL, free_pool_limit)) ;
// built-in matrices are stored by column
OK (GxB_Global_Option_set (GxB_FORMAT, GxB_BY_COL)) ;
// print 1-based indices
OK (GxB_Global_Option_set (GxB_PRINT_1BASED, true)) ;
// for debug only
GB_Global_abort_function_set (gb_abort) ;
// for printing memory sizes of matrices
GB_Global_print_mem_shallow_set (true) ;
}
//--------------------------------------------------------------------------
// check usage
//--------------------------------------------------------------------------
if (!ok)
{
ERROR (usage) ;
}
//--------------------------------------------------------------------------
// get test coverage
//--------------------------------------------------------------------------
#ifdef GBCOV
gbcov_get ( ) ;
#endif
}
|