FK20 CUDA
test.h File Reference
#include <stdio.h>
#include <unistd.h>
#include <memory>
Include dependency graph for test.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define COLOR_RED   "\x1b[31m"
 
#define COLOR_GREEN   "\x1b[32m"
 
#define COLOR_RESET   "\x1b[0m"
 
#define COLOR_BOLD   "\x1b[1m"
 
#define PRINTPASS(pass)
 
#define NEGPRINTPASS(pass)
 
#define WRITEU64(writing_stream, var, nu64Elem)
 
#define WRITEU64TOFILE(fileName, var, nu64Elem)
 
#define WRITEU64STDOUT(var, nu64Elem)
 
#define CUDASYNC(fmt, ...)
 
#define SET_SHAREDMEM(SZ, FN)
 
#define clearRes
 
#define clearRes512
 
#define CLOCKINIT   clock_t start, end
 
#define CLOCKSTART   start = clock()
 
#define CLOCKEND
 
#define CMPCHECK(LENGTH)
 
#define NEGCMPCHECK(LENGTH)
 

Functions

void testinit ()
 Sets a global variable to true if the STDOUT is a terminal. Needs to be done like so because while a kernel is able to print to stdout, it is unable to execute isatty. More...
 

Variables

__managed__ int stdout_isatty
 

Macro Definition Documentation

◆ clearRes

#define clearRes
Value:
for (int i = 0; i < 16 * 512; i++) \
cmp[i] = 0; \
pass = true;

Definition at line 87 of file test.h.

◆ clearRes512

#define clearRes512
Value:
for (int i = 0; i < rows * 16 * 512; i++) \
cmp[i] = 0; \
pass = true;

Definition at line 92 of file test.h.

◆ CLOCKEND

#define CLOCKEND
Value:
end = clock(); \
printf(" (%.1f ms)\n", (end - start) * (1000. / CLOCKS_PER_SEC))

Definition at line 100 of file test.h.

◆ CLOCKINIT

#define CLOCKINIT   clock_t start, end

Definition at line 98 of file test.h.

◆ CLOCKSTART

#define CLOCKSTART   start = clock()

Definition at line 99 of file test.h.

◆ CMPCHECK

#define CMPCHECK (   LENGTH)
Value:
for (int i = 0; pass && i < LENGTH; i++) { \
if (cmp[i] != 1) { \
printf("%s:%d %s() error idx %d...\n", __FILE__, __LINE__, __func__, i); \
pass = false; \
break; \
} \
}

Definition at line 106 of file test.h.

◆ COLOR_BOLD

#define COLOR_BOLD   "\x1b[1m"

Definition at line 22 of file test.h.

◆ COLOR_GREEN

#define COLOR_GREEN   "\x1b[32m"

Definition at line 20 of file test.h.

◆ COLOR_RED

#define COLOR_RED   "\x1b[31m"

Definition at line 19 of file test.h.

◆ COLOR_RESET

#define COLOR_RESET   "\x1b[0m"

Definition at line 21 of file test.h.

◆ CUDASYNC

#define CUDASYNC (   fmt,
  ... 
)
Value:
err = cudaDeviceSynchronize(); \
if (err != cudaSuccess) \
printf("%s:%d " fmt " Error: %d (%s)\n", __FILE__, __LINE__, err, cudaGetErrorName(err), ##__VA_ARGS__)

Definition at line 70 of file test.h.

◆ NEGCMPCHECK

#define NEGCMPCHECK (   LENGTH)
Value:
for (int i = 0; pass && i < LENGTH; i++) { \
if (cmp[i] != 1) { \
pass = false; \
break; \
} \
}

Definition at line 116 of file test.h.

◆ NEGPRINTPASS

#define NEGPRINTPASS (   pass)
Value:
if (isatty(fileno(stdout))){ \
printf("--- %s (intentional error detected)\n", pass ? COLOR_RED COLOR_BOLD "FAIL" COLOR_RESET : COLOR_GREEN "PASS" COLOR_RESET);\
}else{\
printf("--- %s\n", pass ? "FAIL" : "PASS" );\
}
#define COLOR_RESET
Definition: test.h:21
#define COLOR_BOLD
Definition: test.h:22
#define COLOR_RED
Definition: test.h:19
#define COLOR_GREEN
Definition: test.h:20

Definition at line 32 of file test.h.

◆ PRINTPASS

#define PRINTPASS (   pass)
Value:
if (stdout_isatty){ \
printf("--- %s\n", pass ? COLOR_GREEN "PASS" COLOR_RESET : COLOR_RED COLOR_BOLD "FAIL" COLOR_RESET);\
}else{ \
printf("--- %s\n", pass ? "PASS" : "FAIL" );\
}
__managed__ int stdout_isatty
Definition: test.cu:8

Definition at line 25 of file test.h.

◆ SET_SHAREDMEM

#define SET_SHAREDMEM (   SZ,
  FN 
)
Value:
err = cudaFuncSetAttribute(FN, cudaFuncAttributeMaxDynamicSharedMemorySize, SZ); \
cudaDeviceSynchronize(); \
if (err != cudaSuccess) \
printf("Error cudaFuncSetAttribute: %s:%d, error %d (%s)\n", __FILE__, __LINE__, err, cudaGetErrorName(err));

Definition at line 79 of file test.h.

◆ WRITEU64

#define WRITEU64 (   writing_stream,
  var,
  nu64Elem 
)
Value:
do { \
uint64_t *pointer = (uint64_t *)(*var); \
for (int count = 0; count < (nu64Elem); count++) { \
fprintf(writing_stream, "%016lx\n", pointer[count]); \
} \
} while (0)

Definition at line 40 of file test.h.

◆ WRITEU64STDOUT

#define WRITEU64STDOUT (   var,
  nu64Elem 
)
Value:
do { \
uint64_t *pointer = (uint64_t *)(var); \
for (int count = 0; count < (nu64Elem); count++) { \
printf("%016lx ", pointer[count]); \
if (count % 6 == 5) \
printf("\n"); \
} \
} while (0)

Definition at line 57 of file test.h.

◆ WRITEU64TOFILE

#define WRITEU64TOFILE (   fileName,
  var,
  nu64Elem 
)
Value:
do { \
FILE *filepointer = fopen(fileName, "w"); \
WRITEU64(filepointer, var, (nu64Elem)); \
fclose(filepointer); \
} while (0)

Definition at line 48 of file test.h.

Function Documentation

◆ testinit()

void testinit ( )

Sets a global variable to true if the STDOUT is a terminal. Needs to be done like so because while a kernel is able to print to stdout, it is unable to execute isatty.

Currently used so piping to a file doesn't output terminal control characters.

Definition at line 18 of file test.cu.

Here is the caller graph for this function:

Variable Documentation

◆ stdout_isatty

__managed__ int stdout_isatty
extern

Definition at line 8 of file test.cu.