LCOV - code coverage report
Current view: top level - src/utility - LAGraph_SizeOfType.c (source / functions) Hit Total Coverage
Test: LAGraph code coverage report. Commit id: 3b461aa. Current time (UTC): 2024-01-25T16:04:32Z Lines: 6 6 100.0 %
Date: 2024-01-25 16:05:28 Functions: 1 1 100.0 %

          Line data    Source code
       1             : //------------------------------------------------------------------------------
       2             : // LAGraph_SizeOfType: return the sizeof(...) of a GraphBLAS GrB_Type
       3             : //------------------------------------------------------------------------------
       4             : 
       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
       6             : // SPDX-License-Identifier: BSD-2-Clause
       7             : //
       8             : // For additional details (including references to third party source code and
       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
      10             : // Contributors.txt for a full list of contributors. Created, in part, with
      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
      12             : // DM22-0790
      13             : 
      14             : // Contributed by Timothy A. Davis, Texas A&M University
      15             : 
      16             : //------------------------------------------------------------------------------
      17             : 
      18             : #include "LG_internal.h"
      19             : 
      20          15 : int LAGraph_SizeOfType
      21             : (
      22             :     // output:
      23             :     size_t *size,   // size of the type
      24             :     // input:
      25             :     GrB_Type type,  // GraphBLAS type
      26             :     char *msg
      27             : )
      28             : {
      29             : 
      30             :     //--------------------------------------------------------------------------
      31             :     // check inputs
      32             :     //--------------------------------------------------------------------------
      33             : 
      34          15 :     LG_CLEAR_MSG ;
      35          15 :     LG_ASSERT (type != NULL, GrB_NULL_POINTER) ;
      36          13 :     LG_ASSERT (size != NULL, GrB_NULL_POINTER) ;
      37          12 :     (*size) = 0 ;
      38             : 
      39             :     //--------------------------------------------------------------------------
      40             :     // determine the size of the type
      41             :     //--------------------------------------------------------------------------
      42             : 
      43             :     #if LAGRAPH_SUITESPARSE
      44             : 
      45             :         // always succeeds, even for user-defined types, unless the
      46             :         // type is an invalid object
      47          12 :         return (GxB_Type_size (size, type)) ;
      48             : 
      49             :     #else
      50             : 
      51             :         if      (type == GrB_BOOL  ) (*size) = sizeof (bool)     ;
      52             :         else if (type == GrB_INT8  ) (*size) = sizeof (int8_t)   ;
      53             :         else if (type == GrB_INT16 ) (*size) = sizeof (int16_t)  ;
      54             :         else if (type == GrB_INT32 ) (*size) = sizeof (int32_t)  ;
      55             :         else if (type == GrB_INT64 ) (*size) = sizeof (int64_t)  ;
      56             :         else if (type == GrB_UINT8 ) (*size) = sizeof (uint8_t)  ;
      57             :         else if (type == GrB_UINT16) (*size) = sizeof (uint16_t) ;
      58             :         else if (type == GrB_UINT32) (*size) = sizeof (uint32_t) ;
      59             :         else if (type == GrB_UINT64) (*size) = sizeof (uint64_t) ;
      60             :         else if (type == GrB_FP32  ) (*size) = sizeof (float)    ;
      61             :         else if (type == GrB_FP64  ) (*size) = sizeof (double)   ;
      62             :         #if 0
      63             :         else if (type == GxB_FC32  ) (*size) = sizeof (GxB_FC32_t) ;
      64             :         else if (type == GxB_FC64  ) (*size) = sizeof (GxB_FC64_t) ;
      65             :         #endif
      66             :         else
      67             :         {
      68             :             LG_ASSERT_MSG (false,
      69             :                 GrB_NOT_IMPLEMENTED, "user-defined types not supported") ;
      70             :         }
      71             :         return (GrB_SUCCESS) ;
      72             : 
      73             :     #endif
      74             : }

Generated by: LCOV version 1.14