forked from rose-compiler/rose
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CharmNotes.txt
74 lines (59 loc) · 1.58 KB
/
CharmNotes.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// There are three specific problems:
// 1) Automated Pack and Unpack functions
// These are for arbitrary data structures (using the data structure
// handling capabilities within ROSE from Andreas's work).
// 2) Incapsulation of global variables
// wrap-up global variables into a separate data structure (for
// thread support, as I recall)
//
// 3) Blocking on 1D arrays (I forget the details of this problem)
// "= a[i]" get
// "a[i] =" set
// It was suggested that problem 2 would make a useful example
// problem (also useful for the tutorial)
// Previous test at top of example CharmSupport.C:
// This is [or will be] an example program to solve a specific problem
// suggested by the Charm++ research project.
#if 0
/********** original code **********/
//global variables
int max_size;
mytype myinfo;
double *data;
void f(){
for(int i = 0; i < max_size; i++)
data[i] += myinfo.some_var;
}
void g(int A){
f();
}
int main(void){
// do some stuff...
g();
}
/* transformed code
* All functions (except main) must take in new parameter
*/
/* in global scope */
struct AMPI_globals_t{
int max_size;
mytype myinfo;
double *data;
}
/* declared as "void f()" */
void f(AMPI_globals_t *AMPI_globals){
for(int i = 0; i < AMPI_globals->max_size; i++)
AMPI_globals->data[i] += AMPI_globals->myinfo.some_var;
}
/* declared as "void g(int A)" */
void g(int A, AMPI_globals_t *AMPI_globals){
f(AMPI_globals);
}
int main(void){
/* NEW CODE */
AMPI_globals_t *AMPI_globals =
(AMPI_globals_t*) malloc(sizeof(AMPI_globals_t));
// do some stuff...
g(AMPI_globals);
}
#endif