PIPS
gpu.h File Reference
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

string build_outline_name (const char *, const char *)
 Warning! Do not modify this file that is automatically generated! More...
 
bool gpu_ify (const string)
 Transform all the parallel loop nests of a module into smaller independent functions suitable for GPU-style accelerators. More...
 
void xml_print_entity_full (entity)
 xml_output.c More...
 
void gather_grid_dim (statement, void *)
 
bool gpu_xml_dump (string)
 PIPSMAKE INTERFACE. More...
 
bool gpu_loop_nest_annotate_on_statement (statement)
 loop_nest_annotate.c More...
 
bool gpu_loop_nest_annotate (const char *)
 
bool gpu_parallelize_annotated_loop_nest (const string)
 Parallelize the launcher based on loop nest annotate sentinels. More...
 
bool clear_annotated_loop_nest (statement)
 Callback for gen_recurse Remove annotation on a loop nest. More...
 
bool gpu_clear_annotations_on_loop_nest (const string)
 Remove all annotations on a loop nest. More...
 
bool one_thread_parallelize (string)
 one_thread_kernel.c More...
 
void do_gpu_qualify_pointers (entity, statement code, callees, bool)
 gpu_qualify_pointers.c More...
 
bool gpu_qualify_pointers (const string)
 

Function Documentation

◆ build_outline_name()

string build_outline_name ( const char *  base_prefix,
const char *  mod_name 
)

Warning! Do not modify this file that is automatically generated!

Modify src/Libs/gpu/gpu-local.h instead, to add your own modifications. header file built by cproto gpu-local.h Nothing yet... cproto-generated files gpu-ify.c

Warning! Do not modify this file that is automatically generated!

Parameters
base_prefixase_prefix
mod_nameod_name

Definition at line 78 of file gpu-ify.c.

79  {
80  bool name_suffix_p = get_bool_property("GPU_OUTLINE_SUFFIX_WITH_OWNER_NAME");
81 
82  char *prefix;
83  if(name_suffix_p) {
84  // strdup because concatenate is used during build_new_top_level_module_name
85  prefix = strdup(concatenate(base_prefix,"_",mod_name,NULL));
86  } else {
87  prefix = strdup(base_prefix);
88  }
89 
90  string outline_name = build_new_top_level_module_name(prefix,true);
91 
92  free(prefix);
93 
94  return outline_name;
95 }
bool get_bool_property(const string)
FC 2015-07-20: yuk, moved out to prevent an include cycle dependency include "properties....
void free(void *)
string concatenate(const char *,...)
Return the concatenation of the given strings.
Definition: string.c:183
static const char * prefix
string build_new_top_level_module_name(const char *prefix, bool prevent_suffix)
Get a new name for a module built from a prefix.
Definition: module.c:55
char * strdup()

References build_new_top_level_module_name(), concatenate(), free(), get_bool_property(), prefix, and strdup().

Referenced by get_next_task_name(), and gpu_ify_statement().

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

◆ clear_annotated_loop_nest()

bool clear_annotated_loop_nest ( statement  s)

Callback for gen_recurse Remove annotation on a loop nest.

Definition at line 465 of file loop_nest_annotate.c.

465  {
466  string comment = statement_comments(s);
468  && (NULL != strstr(comment, "Loop nest P4A end")|| NULL != strstr(comment, "Loop nest P4A begin"))) {
469  // clear the comment
470  // We may instead filter out only the annotation inside the comment
472  }
473  return true;
474 }
static void comment(string_buffer code, spoc_hardware_type hw, dagvtx v, int stage, int side, bool flip)
Definition: freia_spoc.c:52
bool empty_comments_p(const char *)
Definition: statement.c:107
#define string_undefined
Definition: newgen_types.h:40
#define statement_comments(x)
Definition: ri.h:2456

References comment(), empty_comments_p(), statement_comments, and string_undefined.

Referenced by gpu_clear_annotations_on_loop_nest().

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

◆ do_gpu_qualify_pointers()

void do_gpu_qualify_pointers ( entity  module,
statement  code,
callees  funcs,
bool  do_casts 
)

gpu_qualify_pointers.c

Parameters
moduleodule
funcsuncs
do_castso_casts

Definition at line 378 of file gpu_qualify_pointers.c.

383 {
384  pips_debug(2, "qualifying pointers in module %s\n", entity_name(module));
385 
386  // check for module parameters, mark them if needed
387  // note: there are declarations in the code and in the function signature
388  // should it be set on both?
389  pips_assert(entity_function_p(module), "module must be a function");
390  value val = entity_initial(module);
391  pips_assert(value_code_p(val), "function must have code");
392 
393  // set formal parameters as private or global, in doubt set as global
396  {
397  if (formal_parameter_p(var))
398  {
399  if (entity_pointer_p(var) || entity_array_p(var))
400  {
401  int number = formal_offset(storage_formal(entity_storage(var)));
402  type tn = parameter_type(PARAMETER(gen_nth(number-1, params)));
403  pips_assert(type_variable_p(tn), "formal parameter is a variable");
404  variable fp = type_variable(tn);
405 
406  if (variable_is_glopriv(fp, true))
407  set_global(var);
408  else if (variable_is_glopriv(fp, false))
409  set_as_private(var);
410  else // in doubt, assume it is a global pointer
411  {
412  pips_user_warning("no clue, set formal parameter %s as global\n",
413  entity_name(var));
414  set_variable_qualifier(fp, true);
415  set_global(var);
416  }
417  }
418  }
419  else if (entity_array_p(var))
420  // just a private array declaration
421  set_as_private(var);
422  }
423 
424  // pass through the code
425  glopriv_context_t * glc = new_glopriv();
426  glc->do_casts = do_casts;
427  bool try_again = true;
428  int iteration = 0;
429 
430  while (try_again)
431  {
432  iteration++;
433  pips_debug(3, "propagating privates & globals iteration %d\n", iteration);
434 
435  // update global/private information
436  glc->changed = false;
438 
439  // if something is needed and it is not converging?
440  if (iteration > 1 && !glc->changed)
441  // this may happen if some pointers are not used,
442  // or point to unqualified scalars
443  break;
444 
445  // if changed, more expr may be qualified even if no entity is concerned
446  // this iteration is needed for ensuring that calls are well qualified.
447  try_again = glc->changed;
448 
449  // qualify pointers if possible
451  {
452  if (entity_variable_p(var))
453  {
454  pips_debug(8, "considering variable %s (global=%d, private=%d)\n",
455  entity_name(var), is_global(var), is_private(var));
456  if (!formal_parameter_p(var) &&
457  (entity_pointer_p(var) || entity_array_p(var)) &&
458  !is_private(var) && !is_global(var))
459  {
460  bool
461  var_is_global = set_belong_p(glc->globals, var),
462  var_is_private = set_belong_p(glc->privates, var);
463 
464  // no "else", so as to trigger user errors if need be
465  if (var_is_global)
466  set_global(var);
467  if (var_is_private)
468  set_as_private(var);
469  if (!var_is_global && !var_is_private) // in doubt? set_as_private(var);
470  {
471  pips_debug(5, "in doubt about %s, retrying...\n", entity_name(var));
472  try_again = true;
473  }
474  }
475  }
476  }
477  }
478 
479  // unmarked remaining pointers are expected to be private only
480  // see x/z w/v in "validation/Gpu/glopriv04.c"
482  {
483  if (entity_variable_p(var) && !formal_parameter_p(var) &&
484  (entity_pointer_p(var) || entity_array_p(var)) &&
485  !is_private(var) && !is_global(var))
486  set_as_private(var);
487  }
488 
489  // now mark/check callee parameters
490  FOREACH(string, f, callees_callees(funcs))
491  {
492  pips_debug(3, "updating call to %s\n", f);
495 
496  if (hash_defined_p(glc->call_sites, callee))
497  {
498  FOREACH(call, c, (list) hash_get(glc->call_sites, callee))
499  {
500  pips_assert(call_function(c) == callee, "good function called");
502  "matching #arguments & #parameters");
503  list lp = params;
504  int nparam = 0;
506  {
507  parameter p = PARAMETER(CAR(lp));
508  dummy d = parameter_dummy(p);
509  const string sp = dummy_unknown_p(d)?
510  "?": (const string) entity_local_name(dummy_identifier(d));
511  type te = parameter_type(p);
512  lp = CDR(lp);
513  nparam += 1;
514 
515  if (!pointer_type_p(te) && !array_type_p(te))
516  {
517  pips_debug(5, "skipping non pointer parameter %s:%d (%s)\n",
518  entity_name(callee), nparam, sp);
519  continue;
520  }
521 
522  pips_assert(type_variable_p(te), "type is a variable");
523  variable var = type_variable(te);
524  bool global_expr = set_belong_p(glc->globals, e),
525  private_expr = set_belong_p(glc->privates, e),
526  var_is_global = variable_is_glopriv(var, true),
527  var_is_private = variable_is_glopriv(var, false);
528 
529  if (global_expr && private_expr)
530  // is it possible, or would it be an internal error?
531  pips_user_error("formal parameter \"%s\" (#%d of \"%s\") is both "
532  "private & global\n",
533  sp, nparam, entity_name(callee));
534  if (global_expr && var_is_private)
535  pips_user_error("formal parameter \"%s\" (#%d of \"%s\") is "
536  "already private, cannot switch it to global\n",
537  sp, nparam, entity_name(callee));
538  if (private_expr && var_is_global)
539  pips_user_error("formal parameter \"%s\" (#%d of \"%s\") is "
540  "already global, cannot switch it to private\n",
541  sp, nparam, entity_name(callee));
542 
543  // no else so as to possibly trigger some errors...
544  if (global_expr)
545  set_variable_qualifier(var, true);
546  if (private_expr)
547  set_variable_qualifier(var, false);
548  if (!global_expr && !private_expr) // in doubt, set as private...
549  {
550  pips_debug(5, "setting %s:%d (%s) as private by default\n",
551  entity_name(callee), nparam, sp);
552  set_variable_qualifier(var, false);
553  }
554  }
555  }
556  }
557  // else the callee is not called? unlikely:-)
558  }
559 
560  // cleanup
561  free_glopriv(&glc);
562 }
struct paramStruct params
static entity callee
Definition: alias_pairs.c:62
int dummy
A dummy file, to prevent empty libraries from breaking builds.
Definition: dummy.c:41
static void set_variable_qualifier(variable var, bool is_glob)
static void free_glopriv(glopriv_context_t **pglc)
static void set_global(entity evar)
static bool is_global(entity evar)
static void collect_glopriv_data(entity f, statement s, glopriv_context_t *glc)
static void set_as_private(entity evar)
static glopriv_context_t * new_glopriv(void)
static bool is_private(entity evar)
static bool variable_is_glopriv(variable var, bool is_glob)
size_t gen_length(const list l)
Definition: list.c:150
#define CAR(pcons)
Get the value of the first element of a list.
Definition: newgen_list.h:92
#define FOREACH(_fe_CASTER, _fe_item, _fe_list)
Apply/map an instruction block on all the elements of a list.
Definition: newgen_list.h:179
#define CDR(pcons)
Get the list less its first element.
Definition: newgen_list.h:111
gen_chunk gen_nth(int n, const list l)
to be used as ENTITY(gen_nth(3, l))...
Definition: list.c:710
void * hash_get(const hash_table htp, const void *key)
this function retrieves in the hash table pointed to by htp the couple whose key is equal to key.
Definition: hash.c:449
bool hash_defined_p(const hash_table htp, const void *key)
true if key has e value in htp.
Definition: hash.c:484
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145
#define pips_user_warning
Definition: misc-local.h:146
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172
#define pips_user_error
Definition: misc-local.h:147
bool set_belong_p(const set, const void *)
Definition: set.c:194
char * string
STRING.
Definition: newgen_types.h:39
int f(int off1, int off2, int n, float r[n], float a[n], float b[n])
Definition: offsets.c:15
static char * module
Definition: pips.c:74
#define entity_variable_p(e)
An entity_variable_p(e) may hide a typedef and hence a functional type.
const char * entity_local_name(entity e)
entity_local_name modified so that it does not core when used in vect_fprint, since someone thought t...
Definition: entity.c:453
bool entity_array_p(entity e)
Is e a variable with an array type?
Definition: entity.c:754
entity module_name_to_entity(const char *mn)
This is an alias for local_name_to_top_level_entity.
Definition: entity.c:1479
bool entity_function_p(entity e)
Definition: entity.c:724
bool entity_pointer_p(entity e)
Definition: entity.c:745
bool array_type_p(type)
Definition: type.c:2942
bool pointer_type_p(type)
Check for scalar pointers.
Definition: type.c:2993
bool formal_parameter_p(entity)
Definition: variable.c:1489
#define formal_offset(x)
Definition: ri.h:1408
#define dummy_identifier(x)
Definition: ri.h:1033
#define value_code_p(x)
Definition: ri.h:3065
#define parameter_dummy(x)
Definition: ri.h:1823
#define parameter_type(x)
Definition: ri.h:1819
#define call_function(x)
Definition: ri.h:709
#define callees_callees(x)
Definition: ri.h:675
#define type_functional(x)
Definition: ri.h:2952
#define type_variable(x)
Definition: ri.h:2949
#define entity_storage(x)
Definition: ri.h:2794
#define code_declarations(x)
Definition: ri.h:784
#define storage_formal(x)
Definition: ri.h:2524
#define dummy_unknown_p(x)
Definition: ri.h:1028
#define entity_name(x)
Definition: ri.h:2790
#define functional_parameters(x)
Definition: ri.h:1442
#define PARAMETER(x)
PARAMETER.
Definition: ri.h:1788
#define value_code(x)
Definition: ri.h:3067
#define call_arguments(x)
Definition: ri.h:711
#define entity_type(x)
Definition: ri.h:2792
#define type_variable_p(x)
Definition: ri.h:2947
#define entity_initial(x)
Definition: ri.h:2796
The structure used to build lists in NewGen.
Definition: newgen_list.h:41
structure to collect whether anything should be qualified as private or global, for OpenCL 1....

References array_type_p(), call_arguments, call_function, glopriv_context_t::call_sites, callee, callees_callees, CAR, CDR, glopriv_context_t::changed, code_declarations, collect_glopriv_data(), glopriv_context_t::do_casts, dummy_identifier, dummy_unknown_p, entity_array_p(), entity_function_p(), entity_initial, entity_local_name(), entity_name, entity_pointer_p(), entity_storage, entity_type, entity_variable_p, f(), FOREACH, formal_offset, formal_parameter_p(), free_glopriv(), functional_parameters, gen_length(), gen_nth(), glopriv_context_t::globals, hash_defined_p(), hash_get(), is_global(), is_private(), module, module_name_to_entity(), new_glopriv(), PARAMETER, parameter_dummy, parameter_type, params, pips_assert, pips_debug, pips_user_error, pips_user_warning, pointer_type_p(), glopriv_context_t::privates, set_as_private(), set_belong_p(), set_global(), set_variable_qualifier(), storage_formal, type_functional, type_variable, type_variable_p, value_code, value_code_p, and variable_is_glopriv().

Referenced by gpu_qualify_pointers().

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

◆ gather_grid_dim()

void gather_grid_dim ( statement  s,
void *  ctx 
)
Parameters
ctxtx

Definition at line 165 of file xml_output.c.

165  {
166  // ctx is a pointer to a list of variable
167  list *dims = (list *)ctx;
168 
169  string comment = statement_comments(s);
170  pips_debug(3,"Statement %p, Compare comment '%s'\n",s,comment);
172  size_t sentinel_len = strlen("// To be assigned to a call to P4A_vp_X: ");
173  string sentinel;
174  while((sentinel=strstr(comment,"// To be assigned to a call to P4A_vp_"))!=NULL) {
175  string varname_ptr = sentinel+sentinel_len;
176  string varname_end = strchr(varname_ptr,'\n');
177  int varname_len = varname_end-varname_ptr;
178  string varname = strndup(varname_ptr,varname_len); // to be freed
179  pips_debug(2,"Catch dimension %s\n",varname);
180  *dims = CONS(string,varname,*dims);
181  comment = varname_end;
182  }
183  }
184 }
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
Definition: newgen_list.h:150
#define string_undefined_p(s)
Definition: newgen_types.h:41
char * strndup(char const *s, size_t n)
A replacement function, for systems that lack strndup.
Definition: strndup.c:26

References comment(), CONS, pips_debug, statement_comments, string_undefined_p, and strndup().

Referenced by gpu_xml_dump().

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

◆ gpu_clear_annotations_on_loop_nest()

bool gpu_clear_annotations_on_loop_nest ( const  string)

Remove all annotations on a loop nest.

Parameters
stringod_name

Definition at line 477 of file loop_nest_annotate.c.

477  {
478  // Use this module name and this environment variable to set
480  "GPU_IFY_DEBUG_LEVEL");
481 
482  // Parallelize loops
485 
486  // Put back the new statement module
488  ;
489  // The macro above does a "return TRUE" indeed.
490 }
static statement module_statement
Definition: alias_check.c:125
#define gen_recurse(start, domain_number, flt, rwt)
Definition: genC.h:283
void gen_null(__attribute__((unused)) void *unused)
Ignore the argument.
Definition: genClib.c:2752
#define PIPS_PHASE_POSTLUDE(new_module_statement)
End a transformation phase by putting back into PIPS the (possibly) modified statement.
#define PIPS_PHASE_PRELUDE(module_name, debug_env_var)
Start a phase that use a module CODE.
bool clear_annotated_loop_nest(statement s)
Callback for gen_recurse Remove annotation on a loop nest.
#define statement_domain
newgen_sizeofexpression_domain_defined
Definition: ri.h:362

References clear_annotated_loop_nest(), gen_null(), gen_recurse, module_statement, PIPS_PHASE_POSTLUDE, PIPS_PHASE_PRELUDE, and statement_domain.

+ Here is the call graph for this function:

◆ gpu_ify()

bool gpu_ify ( const string  mod_name)

Transform all the parallel loop nests of a module into smaller independent functions suitable for GPU-style accelerators.

What can be done is more detailed in gpu_ify_statement(). The various functions are generated or not according to different properties.

Parameters
module_nameis the name of the module to work on.
Returns
true since it should succeed...

Outline the previous marked loop nests. First put the statements to outline in the good order:

Clean module name from prefix

Parameters
mod_nameod_name

Definition at line 347 of file gpu-ify.c.

347  {
348  // Use this module name and this environment variable to set
350  "GPU_IFY_DEBUG_LEVEL");
351 
352  // Get the effects and use them:
353  set_cumulated_rw_effects((statement_effects)db_get_memory_resource(DBR_CUMULATED_EFFECTS,mod_name,true));
354 
355  // Initialize the loop nest set to outline to the empty set yet:
357 
358  // Mark interesting loops:
361 
362  /* Outline the previous marked loop nests.
363  First put the statements to outline in the good order: */
365 
366  /* Clean module name from prefix */
368 
370  // We could have stored the depth, but it complexifies the code...
372  }
373 
375 
376  // No longer use effects:
378 
379  // We may have outline some code, so recompute the callees:
380  DB_PUT_MEMORY_RESOURCE(DBR_CALLEES, mod_name,
382 
383  // Put back the new statement module
385  // The macro above does a "return TRUE" indeed.
386 }
callees compute_callees(const statement stat)
Recompute the callees of a module statement.
Definition: callgraph.c:355
void set_cumulated_rw_effects(statement_effects)
void reset_cumulated_rw_effects(void)
const char * global_name_to_user_name(const char *global_name)
functions on strings for entity names
Definition: entity_names.c:136
static const char * get_clean_mod_name(const char *mod_name)
Trying to get only the original function name without prefix.
Definition: gpu-ify.c:59
static list loop_nests_to_outline
A simple phase that outlines parallel loops onto GPU.
Definition: gpu-ify.c:32
static bool mark_loop_to_outline(const statement s)
Definition: gpu-ify.c:120
static void gpu_ify_statement(statement s, int depth, const char *mod_name)
Transform a loop nest into a GPU or accelerator-like kernel.
Definition: gpu-ify.c:199
statement get_current_module_statement(void)
Get the current module statement.
Definition: static.c:208
entity get_current_module_entity(void)
Get the entity of the current module.
Definition: static.c:85
int depth_of_parallel_perfect_loop_nest(statement s)
Compute the depth of a parallel perfect loop-nest.
Definition: loop.c:436
list gen_nreverse(list cp)
reverse a list in place
Definition: list.c:304
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
void gen_free_list(list l)
free the spine of the list
Definition: list.c:327
string db_get_memory_resource(const char *rname, const char *oname, bool pure)
Return the pointer to the resource, whatever it is.
Definition: database.c:755
#define DB_PUT_MEMORY_RESOURCE(res_name, own_name, res_val)
conform to old interface.
Definition: pipsdbm-local.h:66
#define STATEMENT(x)
STATEMENT.
Definition: ri.h:2413

References compute_callees(), db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, depth_of_parallel_perfect_loop_nest(), entity_name, FOREACH, gen_free_list(), gen_nreverse(), gen_null(), gen_recurse, get_clean_mod_name(), get_current_module_entity(), get_current_module_statement(), global_name_to_user_name(), gpu_ify_statement(), loop_nests_to_outline, mark_loop_to_outline(), module_statement, NIL, PIPS_PHASE_POSTLUDE, PIPS_PHASE_PRELUDE, reset_cumulated_rw_effects(), set_cumulated_rw_effects(), STATEMENT, and statement_domain.

+ Here is the call graph for this function:

◆ gpu_loop_nest_annotate()

bool gpu_loop_nest_annotate ( const char *  module_name)
Parameters
module_nameodule_name

Definition at line 406 of file loop_nest_annotate.c.

406  {
407  // Use this module name and this environment variable to set
409  PIPS_PHASE_PRELUDE(module_name, "P4A_LOOP_NEST_ANOTATE_DEBUG_LEVEL");
410 
412 
413  // Put back the new statement module
415  ;
416  // The macro above does a "return TRUE" indeed.
417 }
const char * module_name(const char *s)
Return the module part of an entity name.
Definition: entity_names.c:296
bool gpu_loop_nest_annotate_on_statement(statement s)
annotates loop nests in the following way :

References gpu_loop_nest_annotate_on_statement(), module_name(), module_statement, PIPS_PHASE_POSTLUDE, and PIPS_PHASE_PRELUDE.

+ Here is the call graph for this function:

◆ gpu_loop_nest_annotate_on_statement()

bool gpu_loop_nest_annotate_on_statement ( statement  s)

loop_nest_annotate.c

loop_nest_annotate.c

for(i=0; i<=100; i++) for(j=0; j<=200; j++) foo();

==>

// Loop nest P4A begin,2D(200, 100) for(i=0; i<=100; i++) for(j=0; j<=200; j++) // Loop nest P4A end if (i<=100&&j<=200) foo();

for loops must have been transformed into loops.

Parameters
mod_namename of the module
Returns
true

Initialize context

Annotate the loop nests of the module.

Clean up things: (hasn't it been done previously in loop_annotate?)

Definition at line 383 of file loop_nest_annotate.c.

383  {
384  /* Initialize context */
385  gpu_lna_context c;
388  c.max_loop_nest_depth = -1;
389  c.loop_nest_depth = 0;
390  c.inner_reached = false;
392  = get_bool_property("GPU_LOOP_NEST_ANNOTATE_PARALLEL");
393  c.fail_p = false;
396 
397  /* Annotate the loop nests of the module. */
399 
400  /* Clean up things: (hasn't it been done previously in loop_annotate?) */
402 
403  return true;
404 }
#define gen_context_recurse(start, ctxt, domain_number, flt, rwt)
Definition: genC.h:285
static void loop_annotate(loop l, gpu_lna_context *p)
Do the real annotation work on previously marked loops bottom-up.
static bool loop_push(loop l, gpu_lna_context *p)
Push a loop that matches the criterion for annotation.
#define loop_undefined
Definition: ri.h:1612
#define loop_domain
newgen_language_domain_defined
Definition: ri.h:218
#define expression_undefined
Definition: ri.h:1223
In modern PIPS programming, all is passed through a context instead of having a global variable.
bool gpu_loop_nest_annotate_parallel_p
True if we only deal with parallel loop nests.
bool fail_p
The generation may fail because of an unhandled case for isntance.
expression guard_expression
bool inner_reached
True only when we reach the inner annotated loop:

References expression_undefined, gpu_lna_context::fail_p, gen_context_recurse, gen_free_list(), get_bool_property(), gpu_lna_context::gpu_loop_nest_annotate_parallel_p, gpu_lna_context::guard_expression, gpu_lna_context::inner_loop, gpu_lna_context::inner_reached, gpu_lna_context::l_enclosing_loops, gpu_lna_context::l_number_iter_exp, loop_annotate(), loop_domain, gpu_lna_context::loop_nest_depth, loop_push(), loop_undefined, gpu_lna_context::max_loop_nest_depth, and NIL.

Referenced by gpu_ify_statement(), and gpu_loop_nest_annotate().

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

◆ gpu_parallelize_annotated_loop_nest()

bool gpu_parallelize_annotated_loop_nest ( const  string)

Parallelize the launcher based on loop nest annotate sentinels.

Parameters
stringod_name

Definition at line 445 of file loop_nest_annotate.c.

445  {
446  // Use this module name and this environment variable to set
448  "GPU_IFY_DEBUG_LEVEL");
449 
450  // Parallelize loops
453 
454  // Put back the new statement module
456  ;
457  // The macro above does a "return TRUE" indeed.
458 }
static bool parallelize_annotated_loop_nest(statement s)
Callback for gen_recurse Parallelize perfectly nested loop nest, till we reach the magic comment.

References gen_null(), gen_recurse, module_statement, parallelize_annotated_loop_nest(), PIPS_PHASE_POSTLUDE, PIPS_PHASE_PRELUDE, and statement_domain.

+ Here is the call graph for this function:

◆ gpu_qualify_pointers()

bool gpu_qualify_pointers ( const  string)
Parameters
stringodule_name

Definition at line 575 of file gpu_qualify_pointers.c.

576 {
579  db_get_memory_resource(DBR_CODE, module_name, true));
580  callees funcs = (callees)
581  db_get_memory_resource(DBR_CALLEES, module_name, true);
582 
583  debug_on("GPU_QUALIFY_POINTERS_DEBUG_LEVEL");
584  pips_debug(1, "running on %s", module_name);
585 
588  funcs,
589  get_bool_property("GPU_QUALIFY_POINTERS_DO_CASTS"));
590 
593 
594  debug_off();
595 
598 
599  return true;
600 }
void do_gpu_qualify_pointers(entity module, statement code, callees funcs, bool do_casts)
gpu_qualify_pointers.c
void reset_current_module_entity(void)
Reset the current module entity.
Definition: static.c:97
void reset_current_module_statement(void)
Reset the current module statement.
Definition: static.c:221
statement set_current_module_statement(statement)
Set the current module statement.
Definition: static.c:165
entity set_current_module_entity(entity)
static.c
Definition: static.c:66
#define debug_on(env)
Definition: misc-local.h:157
#define debug_off()
Definition: misc-local.h:160
struct _newgen_struct_callees_ * callees
Definition: ri.h:55

References db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, debug_off, debug_on, do_gpu_qualify_pointers(), get_bool_property(), get_current_module_entity(), get_current_module_statement(), module_name(), module_name_to_entity(), pips_debug, reset_current_module_entity(), reset_current_module_statement(), set_current_module_entity(), and set_current_module_statement().

+ Here is the call graph for this function:

◆ gpu_xml_dump()

bool gpu_xml_dump ( string  mod_name)

PIPSMAKE INTERFACE.

Set the current module entity required to have many things working in PIPS:

First find grid dimension by looking for magic comments

of const strings

Print current module

Parameters
mod_nameod_name

Definition at line 187 of file xml_output.c.

187  {
188 
190  mod_name,
191  true);
192 
194 
195  /* Set the current module entity required to have many things
196  working in PIPS: */
198 
199  debug_on("GPU_XML_DUMP_DEBUG_LEVEL");
200  pips_assert("Statement should be OK at entry...",
202 
203  // Prepare the output file
204  string xml_file_name = db_build_file_resource_name("RI",
205  mod_name,
206  ".out.xml");
208  "/",
209  xml_file_name,
210  NULL));
211  pips_debug(2, "Output in %s\n", output_file);
212  FILE *fp = safe_fopen(output_file, "w");
213  xml_set_output(fp);
214 
215  /* First find grid dimension by looking for magic comments */
216  list /* of const strings */ dims = NIL;
219 
220  /* Print current module */
222  type module_type = entity_type(module);
223  pips_assert("Functional module", type_functional_p(module_type));
224 
225  // Remove wrapper prefix FIXME: bad hack...
226  string original_name = mod_name + strlen("p4a_wrapper_");
227 
228  // Print Task
229  xml_print("<Task name=\"%s\" kernel=\"%s\" nbParallelLoops=\"%zu\">" NL,
230  original_name, mod_name, gen_length(dims));
231 
232  // Params
233  int nparams = gen_length(functional_parameters(type_functional(module_type)));
234  for(int i = 1; i <= nparams; i++) {
236  bool is_a_dim = false;
237  FOREACH(string, dim, dims) {
239  is_a_dim=true;
240  break;
241  }
242  }
243  xml_print_parameter(param, is_a_dim );
244  }
245 
246  //xml_print_statement(module_statement);
247  xml_print("</Task>" NL);
248 
249  // Reset output file
250  xml_set_output(0);
251  safe_fclose(fp, output_file);
252 
253  DB_PUT_FILE_RESOURCE( DBR_GPU_XML_FILE, strdup( mod_name ), xml_file_name );
254 
255  debug_off();
256 
259 
260  return true;
261 }
bool statement_consistent_p(statement p)
Definition: ri.c:2195
struct _newgen_struct_statement_ * statement
Definition: cloning.h:21
FILE * safe_fopen(const char *filename, const char *what)
Definition: file.c:67
int safe_fclose(FILE *stream, const char *filename)
Definition: file.c:77
bool gen_true2(__attribute__((unused)) gen_chunk *u1, __attribute__((unused)) void *u2)
Definition: genClib.c:2785
#define DB_PUT_FILE_RESOURCE
Put a file resource into the current workspace database.
Definition: pipsdbm-local.h:85
string db_build_file_resource_name(const char *rname, const char *oname, const char *suffix)
returns an allocated file name for a file resource.
Definition: lowlevel.c:169
#define same_string_p(s1, s2)
string db_get_current_workspace_directory(void)
Definition: workspace.c:96
const char * entity_user_name(entity e)
Since entity_local_name may contain PIPS special characters such as prefixes (label,...
Definition: entity.c:487
entity find_ith_parameter(entity, int)
Definition: util.c:93
#define type_functional_p(x)
Definition: ri.h:2950
Definition: replace.c:135
static void xml_print_parameter(entity p, bool is_a_dim)
Definition: xml_output.c:139
#define xml_print(format, args...)
Definition: xml_output.c:62
#define NL
Definition: xml_output.c:48
void gather_grid_dim(statement s, void *ctx)
Definition: xml_output.c:165
static void xml_set_output(FILE *new_fp)
Definition: xml_output.c:55

References concatenate(), db_build_file_resource_name(), db_get_current_workspace_directory(), db_get_memory_resource(), DB_PUT_FILE_RESOURCE, debug_off, debug_on, entity_type, entity_user_name(), find_ith_parameter(), FOREACH, functional_parameters, gather_grid_dim(), gen_context_recurse, gen_length(), gen_true2(), get_current_module_entity(), module, module_name_to_entity(), module_statement, NIL, NL, pips_assert, pips_debug, reset_current_module_entity(), reset_current_module_statement(), safe_fclose(), safe_fopen(), same_string_p, set_current_module_entity(), set_current_module_statement(), statement_consistent_p(), statement_domain, strdup(), type_functional, type_functional_p, xml_print, xml_print_parameter(), and xml_set_output().

+ Here is the call graph for this function:

◆ one_thread_parallelize()

bool one_thread_parallelize ( string  mod_name)

one_thread_kernel.c

Set the current module entity required to have many things working in PIPS:

Parameters
mod_nameod_name

Definition at line 77 of file one_thread_kernel.c.

77  {
79  mod_name,
80  true);
81 
83 
84  /* Set the current module entity required to have many things
85  working in PIPS: */
87 
88  debug_on("ONE_THREAD_PARALLELIZE_DEBUG_LEVEL");
89  pips_assert("Statement should be OK at entry...",
91 
94 
95  DB_PUT_MEMORY_RESOURCE(DBR_CODE, mod_name, (char*) module_statement);
96 
97  debug_off();
98 
101 
102  return true;
103 }
static statement enclose_in_a_parallel_loop(statement module_statement)
bool module_reorder(statement body)
Reorder a module and recompute order to statement if any.
Definition: reorder.c:244

References db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, debug_off, debug_on, enclose_in_a_parallel_loop(), module_name_to_entity(), module_reorder(), module_statement, pips_assert, reset_current_module_entity(), reset_current_module_statement(), set_current_module_entity(), set_current_module_statement(), and statement_consistent_p().

+ Here is the call graph for this function:

◆ xml_print_entity_full()

void xml_print_entity_full ( entity  e)

xml_output.c

Definition at line 132 of file xml_output.c.

132  {
133  xml_output(entity_name( e ));
135  //xml_print_storage(entity_storage( e ));
136  //xml_print_value(entity_initial( e ));
137 }
static void xml_print_type(type t)
Definition: xml_output.c:76
static void xml_output(string s)
Definition: xml_output.c:68

References entity_name, entity_type, xml_output(), and xml_print_type().

+ Here is the call graph for this function: