19 #define COLOR_RED "\x1b[31m"
20 #define COLOR_GREEN "\x1b[32m"
21 #define COLOR_RESET "\x1b[0m"
22 #define COLOR_BOLD "\x1b[1m"
25 #define PRINTPASS(pass) if (stdout_isatty){ \
26 printf("--- %s\n", pass ? COLOR_GREEN "PASS" COLOR_RESET : COLOR_RED COLOR_BOLD "FAIL" COLOR_RESET);\
28 printf("--- %s\n", pass ? "PASS" : "FAIL" );\
32 #define NEGPRINTPASS(pass) if (isatty(fileno(stdout))){ \
33 printf("--- %s (intentional error detected)\n", pass ? COLOR_RED COLOR_BOLD "FAIL" COLOR_RESET : COLOR_GREEN "PASS" COLOR_RESET);\
35 printf("--- %s\n", pass ? "FAIL" : "PASS" );\
40 #define WRITEU64(writing_stream, var, nu64Elem) \
42 uint64_t *pointer = (uint64_t *)(*var); \
43 for (int count = 0; count < (nu64Elem); count++) { \
44 fprintf(writing_stream, "%016lx\n", pointer[count]); \
48 #define WRITEU64TOFILE(fileName, var, nu64Elem) \
50 FILE *filepointer = fopen(fileName, "w"); \
51 WRITEU64(filepointer, var, (nu64Elem)); \
52 fclose(filepointer); \
57 #define WRITEU64STDOUT(var, nu64Elem) \
59 uint64_t *pointer = (uint64_t *)(var); \
60 for (int count = 0; count < (nu64Elem); count++) { \
61 printf("%016lx ", pointer[count]); \
70 #define CUDASYNC(fmt, ...) \
71 err = cudaDeviceSynchronize(); \
72 if (err != cudaSuccess) \
73 printf("%s:%d " fmt " Error: %d (%s)\n", __FILE__, __LINE__, err, cudaGetErrorName(err), ##__VA_ARGS__)
79 #define SET_SHAREDMEM(SZ, FN) \
80 err = cudaFuncSetAttribute(FN, cudaFuncAttributeMaxDynamicSharedMemorySize, SZ); \
81 cudaDeviceSynchronize(); \
82 if (err != cudaSuccess) \
83 printf("Error cudaFuncSetAttribute: %s:%d, error %d (%s)\n", __FILE__, __LINE__, err, cudaGetErrorName(err));
88 for (int i = 0; i < 16 * 512; i++) \
93 for (int i = 0; i < rows * 16 * 512; i++) \
98 #define CLOCKINIT clock_t start, end
99 #define CLOCKSTART start = clock()
102 printf(" (%.1f ms)\n", (end - start) * (1000. / CLOCKS_PER_SEC))
106 #define CMPCHECK(LENGTH) \
107 for (int i = 0; pass && i < LENGTH; i++) { \
109 printf("%s:%d %s() error idx %d...\n", __FILE__, __LINE__, __func__, i); \
116 #define NEGCMPCHECK(LENGTH) \
117 for (int i = 0; pass && i < LENGTH; i++) { \
__managed__ int stdout_isatty
void testinit()
Sets a global variable to true if the STDOUT is a terminal. Needs to be done like so because while a ...