PIPS
hardware_accelerator.c
Go to the documentation of this file.
1 /*
2 
3  $Id: hardware_accelerator.c 23422 2017-10-16 15:51:07Z guillou $
4 
5  Copyright 1989-2016 MINES ParisTech
6 
7  This file is part of PIPS.
8 
9  PIPS is free software: you can redistribute it and/or modify it
10  under the terms of the GNU General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  any later version.
13 
14  PIPS is distributed in the hope that it will be useful, but WITHOUT ANY
15  WARRANTY; without even the implied warranty of MERCHANTABILITY or
16  FITNESS FOR A PARTICULAR PURPOSE.
17 
18  See the GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with PIPS. If not, see <http://www.gnu.org/licenses/>.
22 
23 */
24 
25 #ifdef HAVE_CONFIG_H
26 #include "pips_config.h"
27 #endif
28 
29 #include "genC.h"
30 #include "linear.h"
31 
32 // newgen
33 #include "ri.h"
34 #include "effects.h"
35 // needs some arg_label & vertex_label types
36 // #include "graph.h"
37 
38 #include "misc.h"
39 #include "ri-util.h"
40 #include "effects-util.h"
41 #include "callgraph.h"
42 
43 #include "resources.h"
44 #include "pipsdbm.h"
45 
46 #include "control.h" // for clean_up_sequences
47 #include "effects-generic.h" // {set,reset}_proper_rw_effects
48 
49 #include "freia.h"
50 #include "hwac.h"
51 
52 static string commenter(__attribute__((unused)) entity e)
53 {
54  return strdup(" hardware accelerator generated variable");
55  //return string_undefined; // no comment?
56 }
57 
58 /************************************************************ FREIA COMPILERS */
59 
60 /* compile FREIA calls for some target.
61  */
62 static bool freia_compiler(const string module, const string hardware)
63 {
64  debug_on("PIPS_HWAC_DEBUG_LEVEL");
65  pips_debug(1, "considering module %s for hardware %s\n", module, hardware);
66 
67  // this will be usefull
69  (statement) db_get_memory_resource(DBR_CODE, module, true);
72  // should be pure?
74  db_get_memory_resource(DBR_CUMULATED_EFFECTS, module, false));
75  // useless... but...
77  db_get_memory_resource(DBR_PROPER_EFFECTS, module, false));
79 
80  pips_debug(1, "considering module %s\n", module);
81 
82  // accelerated code generation
83  string freia_file = freia_compile(module, mod_stat, hardware);
84 
85  // some code cleanup
87 
88  // put updated code and accelerated helpers
90 
91  // update callees
92  DB_PUT_MEMORY_RESOURCE(DBR_CALLEES, module,
93  (void*) compute_callees(mod_stat));
94 
95  // other possibly generated resources
96  // Argh, as soon as it is put, it is obsolete. Indeed, the code is updated,
97  // and the file depends on the code and resources derived from the code.
98  if (freia_spoc_p(hardware))
99  DB_PUT_NEW_FILE_RESOURCE(DBR_SPOC_FILE, module, freia_file);
100  else if (freia_terapix_p(hardware))
101  DB_PUT_NEW_FILE_RESOURCE(DBR_TERAPIX_FILE, module, freia_file);
102  else if (freia_opencl_p(hardware))
103  DB_PUT_NEW_FILE_RESOURCE(DBR_OPENCL_FILE, module, freia_file);
104  else if (freia_sigmac_p(hardware))
105  DB_PUT_NEW_FILE_RESOURCE(DBR_SIGMAC_FILE, module, freia_file);
106  else if (freia_mppa_p(hardware))
107  DB_PUT_NEW_FILE_RESOURCE(DBR_MPPA_FILE, module, freia_file);
108  // else no helper file for AIPO target, which is just a code transformation
109 
110  // release resources
111  // ??? free statement_effects? MEMORY LEAK...
112  // but some statements contents where freed
113  // there may be some sharing between * effects & statements?
119 
120  debug_off();
121  return true;
122 }
123 
124 bool freia_spoc_compiler(const string module)
125 {
126  return freia_compiler(module, "spoc");
127 }
128 
129 bool freia_terapix_compiler(const string module)
130 {
131  return freia_compiler(module, "terapix");
132 }
133 
134 bool freia_aipo_compiler(const string module)
135 {
136  return freia_compiler(module, "aipo");
137 }
138 
139 bool freia_opencl_compiler(const string module)
140 {
141  return freia_compiler(module, "opencl");
142 }
143 
144 bool freia_sigmac_compiler(const string module)
145 {
146  return freia_compiler(module, "sigmac");
147 }
148 
149 bool freia_mppa_compiler(const string module) {
150  return freia_compiler(module, "mppa");
151 }
152 
153 /* int freia_vhdl_compiler(string module) :-)
154  */
float a2sf[2] __attribute__((aligned(16)))
USER generates a user error (i.e., non fatal) by printing the given MSG according to the FMT.
Definition: 3dnow.h:3
callees compute_callees(const statement stat)
Recompute the callees of a module statement.
Definition: callgraph.c:355
bool clean_up_sequences(statement s)
Recursively clean up the statement sequences by fusing them if possible and by removing useless one.
struct _newgen_struct_statement_ * statement
Definition: cloning.h:21
void reset_proper_rw_effects(void)
void set_proper_rw_effects(statement_effects)
void set_cumulated_rw_effects(statement_effects)
void reset_cumulated_rw_effects(void)
string freia_compile(string module, statement mod_stat, string target)
freia_compile: compile freia module & statement for target
Definition: freia.c:785
#define freia_opencl_p(s)
Definition: freia.h:61
#define freia_sigmac_p(s)
Definition: freia.h:62
#define freia_mppa_p(s)
Definition: freia.h:63
#define freia_spoc_p(s)
Definition: freia.h:59
#define freia_terapix_p(s)
Definition: freia.h:60
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
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 DB_PUT_NEW_FILE_RESOURCE(res_name, own_name, res_val)
Put a new file resource into the current workspace database.
void pop_generated_variable_commenter(void)
Definition: statement.c:2623
void push_generated_variable_commenter(string(*)(entity))
Definition: statement.c:2616
bool freia_sigmac_compiler(const string module)
static string commenter(__attribute__((unused)) entity e)
bool freia_terapix_compiler(const string module)
bool freia_opencl_compiler(const string module)
bool freia_mppa_compiler(const string module)
bool freia_aipo_compiler(const string module)
bool freia_spoc_compiler(const string module)
Warning! Do not modify this file that is automatically generated!
static bool freia_compiler(const string module, const string hardware)
compile FREIA calls for some target.
static statement mod_stat
We want to keep track of the current statement inside the recurse.
Definition: impact_check.c:41
#define debug_on(env)
Definition: misc-local.h:157
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145
#define debug_off()
Definition: misc-local.h:160
static char * module
Definition: pips.c:74
entity module_name_to_entity(const char *mn)
This is an alias for local_name_to_top_level_entity.
Definition: entity.c:1479
char * strdup()