Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
How Approximation Affects Parallelization
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nathanael Sandy
How Approximation Affects Parallelization
Commits
4ace07f9
Commit
4ace07f9
authored
5 years ago
by
Daniel Maier
Browse files
Options
Downloads
Patches
Plain Diff
inital bpp
parent
fa4c1552
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CMakeLists.txt
+5
-0
5 additions, 0 deletions
CMakeLists.txt
bpp.cpp
+180
-0
180 additions, 0 deletions
bpp.cpp
with
185 additions
and
0 deletions
CMakeLists.txt
+
5
−
0
View file @
4ace07f9
cmake_minimum_required
(
VERSION 2.6
)
project
(
perf
)
include_directories
(
"../clan-0.8.0/osl/include"
)
include_directories
(
"../candl/include"
)
link_directories
(
"/home/daniel/polyhedral_perforation/clan-0.8.0/osl/.libs"
)
link_directories
(
"/home/daniel/polyhedral_perforation/candl/.libs"
)
set
(
CMAKE_CXX_FLAGS
"-g -Wall -std=c++17"
)
add_executable
(
perf main.cpp
)
...
...
@@ -15,3 +17,6 @@ target_link_libraries(info osl)
add_executable
(
info2 info2.cpp
)
target_link_libraries
(
info2 osl
)
add_executable
(
bpp bpp.cpp
)
target_link_libraries
(
bpp osl candl
)
This diff is collapsed.
Click to expand it.
bpp.cpp
0 → 100644
+
180
−
0
View file @
4ace07f9
#include
<iostream>
#include
<string>
#include
<algorithm>
#include
<iterator>
#include
<sstream>
#include
<osl/osl.h>
#include
<candl/candl.h>
/* BPP implementation */
/* TODO: how to interface candl? */
int
main
(
int
argc
,
char
*
argv
[])
{
if
(
argc
!=
3
)
{
std
::
cerr
<<
"usage: <INPUT OPENSCOP> <SCOP ID>
\n
"
;
return
-
1
;
}
int
scop_id
=
atoi
(
argv
[
2
]);
auto
*
fp
=
fopen
(
argv
[
1
],
"r"
);
if
(
!
fp
)
{
std
::
cerr
<<
"file read failed
\n
"
;
return
-
1
;
}
auto
scop
=
osl_scop_read
(
fp
);
fclose
(
fp
);
if
(
!
scop
)
{
std
::
cerr
<<
"scop read failed
\n
"
;
return
-
1
;
}
candl_options_p
options
;
options
=
candl_options_malloc
();
options
->
waw
=
1
;
candl_scop_usr_init
(
scop
);
auto
dependence
=
candl_dependence
(
scop
,
options
);
auto
get_stmnt
=
[](
auto
scop
,
int
n
)
{
auto
s
=
scop
->
statement
;
for
(;
n
>
0
&&
s
;
n
--
)
s
=
s
->
next
;
return
s
;
};
auto
get_variables
=
[](
auto
string
)
{
std
::
string
ret
=
string
;
std
::
vector
<
std
::
string
>
vec
;
/* scan for [+-/*]= */
bool
opassign
=
(
std
::
string
::
npos
!=
ret
.
find
(
"+="
)
||
std
::
string
::
npos
!=
ret
.
find
(
"-="
)
||
std
::
string
::
npos
!=
ret
.
find
(
"*="
)
||
std
::
string
::
npos
!=
ret
.
find
(
"-="
)
||
std
::
string
::
npos
!=
ret
.
find
(
"%="
)
);
/* FIXME: treat numbers in variable names different, e.g., temp2 */
/* replace all non variables with spaces and split into tokens */
std
::
replace_if
(
ret
.
begin
(),
ret
.
end
(),
[](
auto
x
)
{
return
!
(
std
::
isalpha
(
x
)
||
x
==
'['
||
x
==
']'
||
x
==
'_'
||
x
==
' '
);
},
' '
);
std
::
istringstream
iss
(
ret
);
std
::
copy
(
std
::
istream_iterator
<
std
::
string
>
(
iss
),
std
::
istream_iterator
<
std
::
string
>
(),
std
::
back_inserter
(
vec
));
if
(
opassign
)
/* insert first element again, because of += */
vec
.
insert
(
vec
.
begin
(),
vec
[
0
]);
return
vec
;
};
/* build 2d vector of variables per statement*/
std
::
vector
<
std
::
vector
<
std
::
string
>>
variables
;
int
i
=
0
;
while
(
auto
x
=
get_stmnt
(
scop
,
i
))
{
auto
body
=
osl_statement_get_body
(
x
);
variables
.
push_back
(
get_variables
(
*
body
->
expression
->
string
));
i
++
;
}
FILE
*
file
=
stdout
;
while
(
dependence
!=
NULL
)
{
if
(
dependence
->
label_source
==
scop_id
){
std
::
cout
<<
"from:
\n
"
;
fprintf
(
file
,
"%d (%d)
\n
"
,
dependence
->
label_source
,
dependence
->
ref_source
);
auto
x
=
get_stmnt
(
scop
,
dependence
->
label_source
);
auto
body
=
osl_statement_get_body
(
x
);
//osl_strings_dump(stdout, body->expression);
std
::
cout
<<
"to:
\n
"
;
fprintf
(
file
,
"%d (%d)
\n
"
,
dependence
->
label_target
,
dependence
->
ref_target
);
x
=
get_stmnt
(
scop
,
dependence
->
label_target
);
body
=
osl_statement_get_body
(
x
);
osl_strings_dump
(
stdout
,
body
->
expression
);
std
::
cout
<<
""
<<
*
body
->
expression
->
string
<<
"
\n
"
;
// auto x = get_variables(*body->expression->string);
//std::cout << "from " << x;
std
::
cout
<<
"-------------------------------------------------------------------
\n
"
;
std
::
cout
<<
variables
[
dependence
->
label_source
][
dependence
->
ref_source
]
<<
" --> "
<<
variables
[
dependence
->
label_target
][
dependence
->
ref_target
]
<<
"
\n
"
;
std
::
cout
<<
"-------------------------------------------------------------------
\n
"
;
#if 0
fprintf(file, " S%d -> S%d [label=\" ", dependence->label_source,
dependence->label_target);
switch (dependence->type) {
case OSL_UNDEFINED : fprintf(file, "UNSET"); break;
case OSL_DEPENDENCE_RAW : fprintf(file, "RAW") ; break;
case OSL_DEPENDENCE_WAR : fprintf(file, "WAR") ; break;
case OSL_DEPENDENCE_WAW : fprintf(file, "WAW") ; break;
case OSL_DEPENDENCE_RAR : fprintf(file, "RAR") ; break;
case OSL_DEPENDENCE_RAW_SCALPRIV :
fprintf(file, "RAW_SCALPRIV (scalar-priv)") ; break;
default : fprintf(file, "unknown"); break;
}
fprintf(file, " depth %d, ref %d->%d \"];\n", dependence->depth,
dependence->ref_source,
dependence->ref_target);
#endif
}
dependence
=
dependence
->
next
;
}
for
(
int
i
=
0
;
i
<
5
;
i
++
)
{
auto
s
=
get_stmnt
(
scop
,
i
);
if
(
s
)
{
auto
body
=
osl_statement_get_body
(
s
);
osl_strings_dump
(
stdout
,
body
->
expression
);
}
}
return
12
;
auto
stmnt
=
scop
->
statement
;
while
(
stmnt
)
{
auto
body
=
osl_statement_get_body
(
stmnt
);
//std::cout << "stmnt " << *(body->expression) << "\n";
osl_strings_dump
(
stdout
,
body
->
expression
);
osl_strings_dump
(
stdout
,
body
->
iterators
);
stmnt
=
stmnt
->
next
;
std
::
cout
<<
"-----
\n
"
;
}
return
0
;
//candl_dependence_add_extension(scop, options);
{
auto
dep
=
(
osl_dependence_p
)
osl_generic_lookup
(
scop
->
extension
,
OSL_URI_DEPENDENCE
);
//osl_dependence_dump(stdout, dep);
osl_dependence_print
(
stdout
,
dep
);
}
/* steps:
* - get SCoP passed, find all depending SCoPs
*/
return
0
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment