Intel SPMD Program Compiler  1.12.0
Macros | Typedefs | Functions
builtins.c File Reference
#include <unistd.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Include dependency graph for builtins.c:

Go to the source code of this file.

Macros

#define _FORTIFY_SOURCE   0
 
#define PRINT_BUF_SIZE   4096
 
#define APPEND(str)
 
#define PRINT_SCALAR(fmt, type)
 
#define PRINT_VECTOR(fmt, type)
 

Typedefs

typedef int Bool
 

Functions

void __do_print (const char *format, const char *types, int width, uint64_t mask, void **args)
 
int __num_cores ()
 

Macro Definition Documentation

◆ _FORTIFY_SOURCE

#define _FORTIFY_SOURCE   0

Definition at line 61 of file builtins.c.

◆ APPEND

#define APPEND (   str)
Value:
do { \
int offset = bufp - &printString[0]; \
*bufp = '\0'; \
strncat(bufp, str, PRINT_BUF_SIZE - offset); \
bufp += strlen(str); \
if (bufp >= &printString[PRINT_BUF_SIZE]) \
goto done; \
} while (0) /* eat semicolon */
#define PRINT_BUF_SIZE
Definition: builtins.c:83

Definition at line 85 of file builtins.c.

Referenced by __do_print().

◆ PRINT_BUF_SIZE

#define PRINT_BUF_SIZE   4096

Definition at line 83 of file builtins.c.

Referenced by __do_print().

◆ PRINT_SCALAR

#define PRINT_SCALAR (   fmt,
  type 
)
Value:
sprintf(tmpBuf, fmt, *((type *)ptr)); \
APPEND(tmpBuf); \
break

Definition at line 95 of file builtins.c.

Referenced by __do_print().

◆ PRINT_VECTOR

#define PRINT_VECTOR (   fmt,
  type 
)
Value:
*bufp++ = '['; \
if (bufp == &printString[PRINT_BUF_SIZE]) \
break; \
for (int i = 0; i < width; ++i) { \
/* only print the value if the current lane is executing */ \
if (mask & (1ull << i)) \
sprintf(tmpBuf, fmt, ((type *)ptr)[i]); \
else \
sprintf(tmpBuf, "((" fmt "))", ((type *)ptr)[i]); \
APPEND(tmpBuf); \
*bufp++ = (i != width - 1 ? ',' : ']'); \
} \
break
#define PRINT_BUF_SIZE
Definition: builtins.c:83

Definition at line 100 of file builtins.c.

Referenced by __do_print().

Typedef Documentation

◆ Bool

typedef int Bool

Definition at line 81 of file builtins.c.

Function Documentation

◆ __do_print()

void __do_print ( const char *  format,
const char *  types,
int  width,
uint64_t  mask,
void **  args 
)

This function is called by PrintStmt to do the work of printing values from ispc programs. Note that the function signature here must match the parameters that PrintStmt::EmitCode() generates.

Parameters
formatPrint format string
typesEncoded types of the values being printed. (See lEncodeType()).
widthVector width of the compilation target
maskCurrent lane mask when the print statemnt is called
argsArray of pointers to the values to be printed

Definition at line 126 of file builtins.c.

References APPEND, PRINT_BUF_SIZE, PRINT_SCALAR, and PRINT_VECTOR.

◆ __num_cores()

int __num_cores ( )

Definition at line 282 of file builtins.c.