File: gbver.c

package info (click to toggle)
suitesparse-graphblas 7.4.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 67,112 kB
  • sloc: ansic: 1,072,243; cpp: 8,081; sh: 512; makefile: 503; asm: 369; python: 125; awk: 10
file content (83 lines) | stat: -rw-r--r-- 2,957 bytes parent folder | download | duplicates (2)
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
82
83
//------------------------------------------------------------------------------
// gbver: struct with SuiteSparse:GraphBLAS version
//------------------------------------------------------------------------------

// SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2022, All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

//------------------------------------------------------------------------------

// v = gbver

#include "gb_interface.h"

#define USAGE "usage: v = gbver"

static const char *vfields [3] = { "Name", "Version", "Date" } ;

void mexFunction
(
    int nargout,
    mxArray *pargout [ ],
    int nargin,
    const mxArray *pargin [ ]
)
{

    //--------------------------------------------------------------------------
    // check inputs
    //--------------------------------------------------------------------------

    gb_usage (nargin == 0 && nargout <= 1, USAGE) ;

    //--------------------------------------------------------------------------
    // get the version and date information and return it as a struct
    //--------------------------------------------------------------------------

    int version [3] ;
    OK (GxB_Global_Option_get (GxB_LIBRARY_VERSION, version)) ;

    char *date ;
    OK (GxB_Global_Option_get (GxB_LIBRARY_DATE, &date)) ;

    if (nargout == 0)
    {
        char *license, *about, *spec, *url ;
        printf ("----------------------------------------"
                "-----------------------------------\n") ;
        OK (GxB_Global_Option_get (GxB_LIBRARY_ABOUT, &about)) ;
        printf ("%s\n", about) ;
        printf ("Version: %d.%d.%d (%s)\n",
                version [0], version [1], version [2], date) ;
        char *compiler ;
        int cver [3] ;
        bool have_openmp ;
        OK (GxB_get (GxB_COMPILER_NAME, &compiler)) ;
        OK (GxB_get (GxB_COMPILER_VERSION, cver)) ;
        OK (GxB_get (GxB_LIBRARY_OPENMP, &have_openmp)) ;
        printf ("GraphBLAS compiled with %s (v%d.%d.%d), %s OpenMP\n", compiler,
            cver [0], cver [1], cver [2],
            have_openmp ? "with" : "without") ;
        printf ("@GrB License: Apache-2.0\n\n") ;
        OK (GxB_Global_Option_get (GxB_API_ABOUT, &spec)) ;
        printf ("Spec:\n%s\n", spec) ;
        OK (GxB_Global_Option_get (GxB_API_URL, &url)) ;
        printf ("URL: %s\n", url) ;
        printf ("----------------------------------------"
                "-----------------------------------\n") ;
    }
    else
    {
        #define LEN 256
        char s [LEN+1] ;
        snprintf (s, LEN, "%d.%d.%d", version [0], version [1], version [2]) ;
        pargout [0] = mxCreateStructMatrix (1, 1, 3, vfields) ;
        mxSetFieldByNumber (pargout [0], 0, 0,
                mxCreateString ("SuiteSparse:GraphBLAS")) ;
        mxSetFieldByNumber (pargout [0], 0, 1, mxCreateString (s)) ;
        mxSetFieldByNumber (pargout [0], 0, 2, mxCreateString (date)) ;
    }

    GB_WRAPUP ;
}