File: GB_macrofy_name.c

package info (click to toggle)
suitesparse 1%3A7.10.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, trixie
  • size: 254,920 kB
  • sloc: ansic: 1,134,743; cpp: 46,133; makefile: 4,875; fortran: 2,087; java: 1,826; sh: 996; ruby: 725; python: 495; asm: 371; sed: 166; awk: 44
file content (52 lines) | stat: -rw-r--r-- 1,810 bytes parent folder | download
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
//------------------------------------------------------------------------------
// GB_macrofy_name: construct the name for a kernel
//------------------------------------------------------------------------------

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

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

// The kernel name has the following form, if the suffix is non-NULL:
//
//      namespace__kname__012345__suffix
//
// or, when suffix is NULL:
//
//      namespace__kname__012345
//
// where "012345" is a hexadecimal printing of the method_code.  Note the
// double underscores (2 or 3 of them).  These are used by GB_demacrofy_name
// for parsing the kernel_name of a PreJIT kernel.
//
// The suffix is used only for user-defined types and operators.

#include "GB.h"
#include "jitifyer/GB_stringify.h"

void GB_macrofy_name
(
    // output:
    char *kernel_name,      // string of length GB_KLEN
    // input
    const char *name_space, // namespace for the kernel_name
    const char *kname,      // kname for the kernel_name
    int method_code_digits, // # of hexadecimal digits printed
    uint64_t method_code,   // enumify'd code of the kernel
    const char *suffix      // suffix for the kernel_name (NULL if none)
)
{
    if (suffix == NULL)
    { 
        // kernel uses only built-in types and operators
        snprintf (kernel_name, GB_KLEN-1, "%s__%s__%0*" PRIx64,
            name_space, kname, method_code_digits, method_code) ;
    }
    else
    { 
        // kernel uses at least one built-in types and/or operator
        snprintf (kernel_name, GB_KLEN-1, "%s__%s__%0*" PRIx64 "__%s",
            name_space, kname, method_code_digits, method_code, suffix) ;
    }
}