7#ifndef ETISS_FASTSTRING_H_
8#define ETISS_FASTSTRING_H_
17#include "etiss/jit/types.h"
28template <
unsigned maxlen_plus1>
32void strcpy(
char *dst,
const char *src)
35 while (pos < maxlen_plus1)
37 const char sc = src[pos];
54 std::vector<std::pair<size_t, size_t>>
fields;
58 size_t char_size(
unsigned,
size_t *,
bool *) {
return 0; }
59 template <
typename... O>
60 size_t char_size(
unsigned pos,
size_t *
size,
bool *isPlaceholder,
const char *
s, O... others)
62 size[pos] = strlen(
s);
63 isPlaceholder[pos] =
false;
66 template <
typename... O>
67 size_t char_size(
unsigned pos,
size_t *
size,
bool *isPlaceholder,
size_t len, O... others)
70 isPlaceholder[pos] =
true;
77 template <
typename... O>
78 void char_copy(
unsigned pos,
char *buf,
size_t *
size,
const char *
s, O... others)
83 template <
typename... O>
84 void char_copy(
unsigned pos,
char *buf,
size_t *
size,
size_t , O... others)
91 template <
typename... T>
95 size_t element[
sizeof...(str)];
96 bool placeholder[
sizeof...(str)];
97 size_t total =
char_size(0, element, placeholder, str...);
99 buffer =
new char[total + 1];
107 for (
size_t i = 0; i <
sizeof...(str); i++)
111 fields.push_back(std::make_pair(offset, element[i]));
113 offset = offset + element[i];
117 template <
typename T>
118 std::enable_if<std::is_integral<T>::value,
void>
write_dec(
unsigned field, T value)
120 std::pair<size_t, size_t> f =
fields[field];
121 size_t pos = f.first + f.second;
130 std::cerr <<
"out of range buffer operation" << std::endl;
136 char c = (char)(value % 10);
142 while (pos >= f.first)
157 std::cerr <<
"out of range buffer operation" << std::endl;
165 inline void writet(
unsigned field,
const char *buf,
size_t length,
char terminator =
' ',
char fill =
' ')
169 if (
length + 2 > f.second)
174 std::cerr <<
"out of range buffer operation" << std::endl;
general configuration and logging
__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)
__DEVICE__ void * memset(void *__a, int __b, size_t __c)
__device__ __2f16 float c
__device__ __2f16 float bool s
std::ostream & operator<<(std::ostream &os, const form_string &fs)
void strcpy(char *dst, const char *src)
void log(Verbosity level, std::string msg)
write log message at the given level.
float __ovld __cnfn length(float p)
Return the length of vector p, i.e., sqrt(p.x2 + p.y 2 + ...)