Basilisk CFD
Adaptive Cartesian mesh PDE framework
Loading...
Searching...
No Matches
gpu.h File Reference
#include <grid/gpu/glad.h>
#include <GLFW/glfw3.h>
Include dependency graph for gpu.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  GLString
 
struct  RegionParameters
 

Macros

#define GL_C(stmt)
 
#define tracing_foreach(name, file, line)
 
#define end_tracing_foreach(name, file, line)
 
#define realloc_scalar(size)   realloc_scalar_gpu (size)
 

Functions

static void gpu_check_error (const char *stmt, const char *fname, int line)
 
void gpu_free_solver (void)
 
static chargetShaderLogInfo (GLuint shader)
 
static chargetProgramLogInfo (GLuint program)
 
chargpu_errors (const char *errors, const char *source, char *fout)
 
static GLuint createShaderFromString (const char *shaderSource, const GLenum shaderType)
 
static GLuint loadNormalShader (const char *vsSource, const char *fsShader)
 
void printWorkGroupsCapabilities ()
 
macro2 BEGIN_FOREACH ()
 
bool gpu_end_stencil (ForeachData *loop, const RegionParameters *region, External *externals, const char *kernel)
 
macro2 foreach_stencil_generic (char flags, Reduce reductions, int _parallel, External *_externals, const char *_kernel)
 
macro2 foreach_stencil (char flags, Reduce reductions, int _parallel, External *_externals, const char *_kernel)
 
macro2 foreach_level_stencil (int _level, char flags, Reduce reductions, int _parallel, External *_externals, const char *_kernel)
 
macro2 foreach_point_stencil (double _xp, double _yp, double _zp, char flags, Reduce reductions, int _parallel, External *_externals, const char *_kernel)
 
macro2 foreach_region_stencil (coord _p, coord _box[2], coord _n, char flags, Reduce reductions, int _parallel, External *_externals, const char *_kernel)
 
macro2 foreach_vertex_stencil (char flags, Reduce reductions, int _parallel, External *_externals, const char *_kernel)
 
macro2 foreach_face_stencil (char flags, Reduce reductions, const char *_order, int _parallel, External *_externals, const char *_kernel)
 
macro2 foreach_coarse_level_stencil (int _level, char flags, Reduce reductions, int _parallel, External *_externals, const char *_kernel)
 
macro2 foreach_level_or_leaf_stencil (int _level, char flags, Reduce reductions, int _parallel, External *_externals, const char *_kernel)
 
ifndef tracing def tracing (func, file, line) do
 
 while (0) @ @ def end_tracing(func
 
 end_tracing (func, file, line)
 
static void gpu_cpu_sync_scalar (scalar s, char *sep, GLenum mode)
 
void realloc_scalar_gpu (int size)
 
void gpu_boundary_level (scalar *list, int l)
 

Variables

struct { 
 
   GLFWwindow *   window 
 
   GLuint *   ssbo 
 
   bool   fragment_shader 
 
   int   current_shader 
 
   int   nssbo 
 
   size_t   max_ssbo_size 
 
   size_t   current_size 
 
GPUContext 
 
GLString gpu_limits_list []
 
 file
 
line do
 

Macro Definition Documentation

◆ end_tracing_foreach

#define end_tracing_foreach (   name,
  file,
  line 
)

Definition at line 227 of file gpu.h.

◆ GL_C

#define GL_C (   stmt)
Value:
do { \
} while (0)
int x
Definition common.h:76
#define LINENO
Definition config.h:105

Definition at line 37 of file gpu.h.

◆ realloc_scalar

#define realloc_scalar (   size)    realloc_scalar_gpu (size)

Definition at line 480 of file gpu.h.

◆ tracing_foreach

#define tracing_foreach (   name,
  file,
  line 
)

Definition at line 226 of file gpu.h.

Function Documentation

◆ BEGIN_FOREACH()

macro2 BEGIN_FOREACH ( )

Definition at line 230 of file gpu.h.

References _gpu_done_, end_tracing_foreach, S__FILE__, S_LINENO, and tracing_foreach.

◆ createShaderFromString()

static GLuint createShaderFromString ( const char shaderSource,
const GLenum  shaderType 
)
static

Definition at line 81 of file gpu.h.

References error, free(), getShaderLogInfo(), GL_C, GL_COMPILE_STATUS, GL_TRUE, glCompileShader, glCreateShader, glDeleteShader, glGetShaderiv, glShaderSource, gpu_errors(), and x.

Referenced by loadNormalShader().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ end_tracing()

end_tracing ( func  ,
file  ,
line   
)

◆ foreach_coarse_level_stencil()

macro2 foreach_coarse_level_stencil ( int  _level,
char  flags,
Reduce  reductions,
int  _parallel,
External _externals,
const char _kernel 
)

Definition at line 343 of file gpu.h.

References flags, foreach_level_stencil(), reductions, and x.

Here is the call graph for this function:

◆ foreach_face_stencil()

macro2 foreach_face_stencil ( char  flags,
Reduce  reductions,
const char _order,
int  _parallel,
External _externals,
const char _kernel 
)

Definition at line 335 of file gpu.h.

References flags, foreach_stencil_generic(), reductions, and x.

Here is the call graph for this function:

◆ foreach_level_or_leaf_stencil()

macro2 foreach_level_or_leaf_stencil ( int  _level,
char  flags,
Reduce  reductions,
int  _parallel,
External _externals,
const char _kernel 
)

Definition at line 351 of file gpu.h.

References flags, foreach_level_stencil(), reductions, and x.

Here is the call graph for this function:

◆ foreach_level_stencil()

macro2 foreach_level_stencil ( int  _level,
char  flags,
Reduce  reductions,
int  _parallel,
External _externals,
const char _kernel 
)

Definition at line 295 of file gpu.h.

References flags, foreach_stencil_generic(), reductions, and x.

Referenced by foreach_coarse_level_stencil(), and foreach_level_or_leaf_stencil().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ foreach_point_stencil()

macro2 foreach_point_stencil ( double  _xp,
double  _yp,
double  _zp,
char  flags,
Reduce  reductions,
int  _parallel,
External _externals,
const char _kernel 
)

Definition at line 304 of file gpu.h.

References flags, foreach_stencil_generic(), reductions, and x.

Here is the call graph for this function:

◆ foreach_region_stencil()

macro2 foreach_region_stencil ( coord  _p,
coord  _box[2],
coord  _n,
char  flags,
Reduce  reductions,
int  _parallel,
External _externals,
const char _kernel 
)

Definition at line 315 of file gpu.h.

References flags, foreach_stencil_generic(), reductions, and x.

Here is the call graph for this function:

◆ foreach_stencil()

macro2 foreach_stencil ( char  flags,
Reduce  reductions,
int  _parallel,
External _externals,
const char _kernel 
)

Definition at line 288 of file gpu.h.

References flags, foreach_stencil_generic(), reductions, and x.

Referenced by foreach_visible_stencil().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ foreach_stencil_generic()

macro2 foreach_stencil_generic ( char  flags,
Reduce  reductions,
int  _parallel,
External _externals,
const char _kernel 
)

Definition at line 249 of file gpu.h.

References _attribute, _gpu_done_, baseblock, check_stencil(), end_tracing_foreach, ForeachData::fname, gpu_end_stencil(), scalar::i, i, _Attributes::name, point, s, S__FILE__, s_input, S_LINENO, s_output, tracing_foreach, and x.

Referenced by foreach_face_stencil(), foreach_level_stencil(), foreach_point_stencil(), foreach_region_stencil(), foreach_stencil(), and foreach_vertex_stencil().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ foreach_vertex_stencil()

macro2 foreach_vertex_stencil ( char  flags,
Reduce  reductions,
int  _parallel,
External _externals,
const char _kernel 
)

Definition at line 325 of file gpu.h.

References flags, foreach_stencil_generic(), reductions, and x.

Here is the call graph for this function:

◆ getProgramLogInfo()

static char * getProgramLogInfo ( GLuint  program)
static

Definition at line 66 of file gpu.h.

References GL_C, GL_INFO_LOG_LENGTH, glGetProgramInfoLog, glGetProgramiv, and x.

Referenced by loadNormalShader().

Here is the caller graph for this function:

◆ getShaderLogInfo()

static char * getShaderLogInfo ( GLuint  shader)
static

Definition at line 53 of file gpu.h.

References GL_C, GL_INFO_LOG_LENGTH, glGetShaderInfoLog, glGetShaderiv, and x.

Referenced by createShaderFromString().

Here is the caller graph for this function:

◆ gpu_boundary_level()

void gpu_boundary_level ( scalar list,
int  l 
)

Definition at line 467 of file gpu.h.

References cartesian_boundary_level(), free(), l, list, list_prepend(), s, and x.

Referenced by gpu_cartesian_methods(), and gpu_multigrid_methods().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gpu_check_error()

static void gpu_check_error ( const char stmt,
const char fname,
int  line 
)
static

Definition at line 22 of file gpu.h.

References fname, GL_NO_ERROR, glGetError, line, and x.

◆ gpu_cpu_sync_scalar()

static void gpu_cpu_sync_scalar ( scalar  s,
char sep,
GLenum  mode 
)
static

◆ gpu_end_stencil()

bool gpu_end_stencil ( ForeachData loop,
const RegionParameters region,
External externals,
const char kernel 
)

Definition at line 2045 of file grid.h.

Referenced by foreach_stencil_generic().

Here is the caller graph for this function:

◆ gpu_errors()

char * gpu_errors ( const char errors,
const char source,
char fout 
)

Definition at line 2230 of file errors.c.

References buf, fname, free(), line, merge(), source, sout, str_append, x, yy_delete_buffer, yy_scan_string, yylex, and yyunput().

Referenced by createShaderFromString().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gpu_free_solver()

void gpu_free_solver ( void  )

Definition at line 43 of file gpu.h.

References free(), GL_C, GL_FRAMEBUFFER, glBindFramebuffer, glDeleteBuffers, glFinish, GPUContext, and x.

Here is the call graph for this function:

◆ loadNormalShader()

static GLuint loadNormalShader ( const char vsSource,
const char fsShader 
)
static

Definition at line 109 of file gpu.h.

References createShaderFromString(), free(), fs, getProgramLogInfo(), GL_COMPUTE_SHADER, GL_FALSE, GL_FRAGMENT_SHADER, GL_LINK_STATUS, GL_VERTEX_SHADER, glAttachShader, glCreateProgram, glDeleteProgram, glDeleteShader, glDetachShader, glGetProgramiv, glLinkProgram, and x.

Here is the call graph for this function:

◆ printWorkGroupsCapabilities()

◆ realloc_scalar_gpu()

void realloc_scalar_gpu ( int  size)

Definition at line 461 of file gpu.h.

References realloc_scalar, size, and x.

◆ tracing()

ifndef tracing def tracing ( func  ,
file  ,
line   
)

Definition at line 360 of file gpu.h.

References file, func, glFinish, line, and tracing().

Referenced by tracing().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ while()

while ( )

Definition at line 367 of file gpu.h.

Variable Documentation

◆ current_shader

int current_shader

Definition at line 16 of file gpu.h.

◆ current_size

size_t current_size

Definition at line 17 of file gpu.h.

◆ do

line do
Initial value:
{
PFNGLFINISHPROC glad_glFinish
Definition glad.c:471

Definition at line 364 of file gpu.h.

◆ file

file

Definition at line 364 of file gpu.h.

Referenced by tracing().

◆ fragment_shader

bool fragment_shader

Definition at line 15 of file gpu.h.

◆ gpu_limits_list

GLString gpu_limits_list[]

Definition at line 157 of file gpu.h.

◆ [struct]

struct { ... } GPUContext
Initial value:
= {
.current_shader = -1,
}

Referenced by cpu_reduction(), gpu_free_solver(), and gpu_reduction().

◆ max_ssbo_size

size_t max_ssbo_size

Definition at line 17 of file gpu.h.

◆ nssbo

int nssbo

Definition at line 16 of file gpu.h.

◆ ssbo

GLuint* ssbo

Definition at line 14 of file gpu.h.

◆ window

GLFWwindow* window

Definition at line 13 of file gpu.h.