| 37 | //------------------------------------------------------------------------------ |
| 38 | |
| 39 | GrB_Info GB_init // start up GraphBLAS |
| 40 | ( |
| 41 | const GrB_Mode mode, // blocking or non-blocking mode |
| 42 | |
| 43 | // pointers to memory management functions. |
| 44 | void * (* malloc_function ) (size_t), // required |
| 45 | void * (* realloc_function ) (void *, size_t), // optional, can be NULL |
| 46 | void (* free_function ) (void *), // required |
| 47 | |
| 48 | GB_Context Context // from GrB_init or GxB_init |
| 49 | ) |
| 50 | { |
| 51 | |
| 52 | //-------------------------------------------------------------------------- |
| 53 | // check inputs |
| 54 | //-------------------------------------------------------------------------- |
| 55 | |
| 56 | #ifdef GBCUDA_DEV |
| 57 | printf ("\n==== GBCUDA_DEV enabled: for CUDA development only! ====\n") ; |
| 58 | #endif |
| 59 | |
| 60 | if (GB_Global_GrB_init_called_get ( )) |
| 61 | { |
| 62 | // GrB_init can only be called once |
| 63 | return (GrB_INVALID_VALUE) ; |
| 64 | } |
| 65 | |
| 66 | GB_Global_GrB_init_called_set (true) ; |
| 67 | |
| 68 | if (mode < GrB_NONBLOCKING || mode > GxB_BLOCKING_GPU) |
| 69 | { |
| 70 | // invalid mode |
| 71 | return (GrB_INVALID_VALUE) ; |
| 72 | } |
| 73 | |
| 74 | //-------------------------------------------------------------------------- |
| 75 | // query hardware features for future use |
| 76 | //-------------------------------------------------------------------------- |
| 77 | |
| 78 | GB_Global_cpu_features_query ( ) ; |
| 79 | |
| 80 | //-------------------------------------------------------------------------- |
| 81 | // establish malloc/realloc/free |
| 82 | //-------------------------------------------------------------------------- |
| 83 | |
| 84 | // GrB_init passes in the ANSI C11 malloc/realloc/free |
| 85 | |
| 86 | GB_Global_malloc_function_set (malloc_function ) ; // cannot be NULL |
| 87 | GB_Global_realloc_function_set (realloc_function) ; // ok if NULL |
| 88 | GB_Global_free_function_set (free_function ) ; // cannot be NULL |
| 89 | GB_Global_malloc_is_thread_safe_set (true) ; // malloc must be thread-safe |
| 90 | GB_Global_memtable_clear ( ) ; |
| 91 | GB_Global_free_pool_init (true) ; |
| 92 | |
| 93 | //-------------------------------------------------------------------------- |
| 94 | // max number of threads |
| 95 | //-------------------------------------------------------------------------- |
| 96 |
no test coverage detected