24 #if defined(BUILDER_LIMIT_NESTED_PARALLELISM) || \
25 defined(BUILDER_LIMIT_PARALLELISM_USING_COMPLEXITY)
28 #include "pips_config.h"
55 static bool identify_outer_loops (
loop l) {
66 static bool collect_privates (
loop l) {
76 static void process_loop (
loop l) {
89 "MANAGE_PARALLEL_LOOPS_DEBUG_LEVEL");
97 for (
int i = 2; i <= threshold; i++) {
137 typedef struct limit_uninteresting_parallelism_context{
138 bool (*loop_cost_testing_function)(
statement,
struct limit_uninteresting_parallelism_context *);
139 int startup_overhead;
143 } limit_uninteresting_parallelism_context;
145 static void init_limit_uninteresting_parallelism_context(limit_uninteresting_parallelism_context *p_ctxt,
146 bool (*loop_cost_testing_function)(
statement, limit_uninteresting_parallelism_context *))
148 p_ctxt->loop_cost_testing_function = loop_cost_testing_function;
149 p_ctxt->startup_overhead =
get_int_property(
"COMPUTATION_INTENSITY_STARTUP_OVERHEAD");
152 p_ctxt->parallel_loops =
NIL;
162 static bool complexity_cost_effective_loop_p(
statement s,
163 limit_uninteresting_parallelism_context * p_ctxt)
174 pips_debug(1,
"max_degree is: %d\n", max_degree);
179 if(curr_degree == max_degree) {
187 result = (coeff > (float) (p_ctxt->startup_overhead + 10));
191 static bool limit_uninteresting_parallelism_statement_in(
statement s,
192 limit_uninteresting_parallelism_context * p_ctxt)
196 pips_debug(1,
"Entering loop statement with ordering: %03zd and number: %03zd\n",
203 p_ctxt->parallel_loops =
CONS(
LOOP, l, p_ctxt->parallel_loops);
209 static void limit_uninteresting_parallelism_statement_out(
statement s,
210 limit_uninteresting_parallelism_context * p_ctxt)
215 pips_debug(1,
"Dealing with loop statement with ordering: %03zd and number: %03zd\n",
222 if (
loop_parallel_p(l) && ! p_ctxt->loop_cost_testing_function(s, p_ctxt))
224 POP(p_ctxt->parallel_loops);
229 if (!
ENDP(p_ctxt->parallel_loops) && !
ENDP(l_locals))
231 loop previous_parallel_loop =
LOOP(
CAR(p_ctxt->parallel_loops));
232 list previous_parallel_loop_locals =
loop_locals(previous_parallel_loop);
256 "MANAGE_PARALLEL_LOOPS_DEBUG_LEVEL");
259 limit_uninteresting_parallelism_context ctxt;
260 init_limit_uninteresting_parallelism_context(&ctxt, complexity_cost_effective_loop_p);
262 statement_domain, limit_uninteresting_parallelism_statement_in, limit_uninteresting_parallelism_statement_out);
int get_int_property(const string)
list gen_entity_cons(entity p, list l)
list gen_loop_cons(loop p, list l)
void const char const char const int
struct _newgen_struct_statement_ * statement
Ppolynome complexity_polynome(complexity comp)
Because complexity is composed of two elements, we use this function to get the first element : polyn...
complexity load_statement_complexity(statement)
void reset_complexity_map(void)
void set_complexity_map(statement_mapping)
const char * module_name(const char *s)
Return the module part of an entity name.
#define gen_context_recurse(start, ctxt, domain_number, flt, rwt)
#define gen_recurse(start, domain_number, flt, rwt)
statement get_current_module_statement(void)
Get the current module statement.
void gen_null(__attribute__((unused)) void *unused)
Ignore the argument.
bool loop_parallel_p(loop l)
Test if a loop is parallel.
list loop_private_variables_as_entites(loop obj, bool local, bool index)
Get the variables local or private to a loop.
#define ENDP(l)
Test if a list is empty.
#define POP(l)
Modify a list pointer to point on the next element of the list.
#define NIL
The empty list (nil in Lisp)
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
list gen_nconc(list cp1, list cp2)
physically concatenates CP1 and CP2 but do not duplicates the elements
#define CAR(pcons)
Get the value of the first element of a list.
void gen_free_list(list l)
free the spine of the list
bool gen_in_list_p(const void *vo, const list lx)
tell whether vo belongs to lx
#define FOREACH(_fe_CASTER, _fe_item, _fe_list)
Apply/map an instruction block on all the elements of a list.
void * gen_find_eq(const void *item, const list seq)
list gen_append(list l1, const list l2)
#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.
string db_get_memory_resource(const char *rname, const char *oname, bool pure)
Return the pointer to the resource, whatever it is.
loop statement_loop(statement)
Get the loop of a statement.
bool statement_loop_p(statement)
Value vect_sum(Pvecteur v)
Value vect_sum(Pvecteur v): somme des coefficients d'un vecteur (i.e.
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
int bool
we cannot use an enum or stdbool because we need to be compatible with newgen, thus boolean need to h...
Ppolynome polynome_dup(Ppolynome pp)
Ppolynome polynome_dup(Ppolynome pp) creates and returns a copy of pp.
void polynome_rm(Ppolynome *ppp)
void polynome_rm(Ppolynome* ppp) frees space occupied by polynomial *ppp returns *ppp pointing to POL...
int polynome_max_degree(Ppolynome pp)
int polynome_max_degree(Ppolynome pp) returns the degree of polynomial pp Let's hope there aren't too...
void polynome_scalar_add(Ppolynome *ppp, float term)
void polynome_scalar_add(Ppolynome* ppp, float term) (*ppp) = (*ppp) + term !usage: polynome_scalar_a...
void polynome_scalar_mult(Ppolynome *ppp, float factor)
void polynome_scalar_mult(Ppolynome* ppp, float factor) (*ppp) = factor * (*ppp) !...
#define polynome_monome(pp)
#define monome_coeff(pm)
Macros definitions.
#define POLYNOME_NUL_P(pp)
#define polynome_succ(pp)
void print_statement(statement)
Print a statement on stderr.
#define loop_execution(x)
#define loop_domain
newgen_language_domain_defined
#define statement_ordering(x)
#define statement_domain
newgen_sizeofexpression_domain_defined
@ is_execution_sequential
#define statement_number(x)
#define execution_parallel_p(x)
The structure used to build lists in NewGen.