Intel SPMD Program Compiler  1.9.1
Macros | Typedefs | Functions
builtins.c File Reference
#include <unistd.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.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 __puts_nvptx (const char *)
 
void __do_print_nvptx (const char *format, const char *types, int width, uint64_t mask, void **args)
 
int __num_cores ()
 

Macro Definition Documentation

#define _FORTIFY_SOURCE   0

Definition at line 61 of file builtins.c.

#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:76

Definition at line 78 of file builtins.c.

Referenced by __do_print(), and __do_print_nvptx().

#define PRINT_BUF_SIZE   4096

Definition at line 76 of file builtins.c.

Referenced by __do_print(), and __do_print_nvptx().

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

Definition at line 89 of file builtins.c.

Referenced by __do_print(), and __do_print_nvptx().

#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:76

Definition at line 94 of file builtins.c.

Referenced by __do_print(), and __do_print_nvptx().

Typedef Documentation

typedef int Bool

Definition at line 74 of file builtins.c.

Function Documentation

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 119 of file builtins.c.

References APPEND, PRINT_BUF_SIZE, PRINT_SCALAR, and PRINT_VECTOR.

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

Definition at line 190 of file builtins.c.

References __puts_nvptx(), APPEND, PRINT_BUF_SIZE, PRINT_SCALAR, and PRINT_VECTOR.

int __num_cores ( )

Definition at line 264 of file builtins.c.

int __puts_nvptx ( const char *  )

Referenced by __do_print_nvptx().