Skip to content
Snippets Groups Projects
Commit d9256e91 authored by Daniel Maier's avatar Daniel Maier
Browse files

info2: add baseline strategy

parent 0bfe900f
No related branches found
No related tags found
No related merge requests found
#include <osl/osl.h>
#include <math.h>
#include <cstring>
#include <string>
#include <iostream>
#include <tuple>
......@@ -8,6 +10,7 @@
#include <list>
using perf_t = std::tuple<int, std::set<int>, int>;
enum Strategy { baseline, permutation };
std::ostream & operator << (std::ostream &out, const perf_t &p) {
auto [j, xx, k] = p;
......@@ -22,12 +25,25 @@ std::ostream & operator << (std::ostream &out, const perf_t &p) {
}
int main(int argc, char *argv[]) {
if(argc != 2) {
std::cerr << "usage: <SCOP>\n";
/* parse arguments */
if(argc != 3) {
std::cerr << "usage: <strategy> <SCOP>\n"
<< " -p all permutations\n"
<< " -b baseline\n\n";
return -1;
}
Strategy strategy;
if(!strcmp(argv[1], "-p"))
strategy = permutation;
else if(!strcmp(argv[1], "-b"))
strategy = baseline;
else {
std::cerr << "invalid strategy\n";
return -1;
}
auto *fp = fopen(argv[1], "r");
auto *fp = fopen(argv[2], "r");
if(!fp) {
std::cerr << "openscop read failed\n";
return -1;
......@@ -62,7 +78,7 @@ int main(int argc, char *argv[]) {
while(s) {
if(!current_scop
|| !(osl_relation_equal(current_scop->domain, s->domain))) {
|| !(osl_relation_equal(current_scop->domain, s->domain))) {
/* new scop */
if(current_scop) {
add_scop();
......@@ -81,24 +97,36 @@ int main(int argc, char *argv[]) {
std::vector<perf_t> list{ std::make_move_iterator(std::begin(l)),
std::make_move_iterator(std::end(l)) };
if(strategy == permutation) {
for(unsigned i = 1; i < pow(2, list.size()); i++) {
std::cout << "config;" << i << "\n";
for(unsigned j = 0; j < list.size(); j++) {
if ((i>>j)&1) {
std::cout << list[j] << "\n";
}
}
std::cout << "\n";
}
}
else if(strategy == baseline) {
int last_scop = -1;
for(auto el : list) {
if(last_scop != std::get<0>(el)) {
std::cout << el << "\n";
last_scop = std::get<0>(el);
}
}
}
#if 0
std::cerr << "list size is now " << list.size() << "\n";
for(auto x : list) {
std::cerr << x << "\n";
std::cerr << "--" << x << "\n";
}
return 0;
#endif
for(unsigned i = 1; i < pow(2, list.size()); i++) {
std::cout << "config;" << i << "\n";
for(unsigned j = 0; j < list.size(); j++) {
if ((i>>j)&1) {
std::cout << list[j] << "\n";
}
}
std::cout << "\n";
}
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment