Skip to content

Commit f131413

Browse files
Fixed the nitpick_run.cc error
1 parent 5a48e22 commit f131413

3 files changed

Lines changed: 26 additions & 19 deletions

File tree

nitpick/exprcase.hh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ namespace bparser {
5353

5454
PatchArenaPtr arena;
5555
Parser parser;
56-
std::string parseQuery;
56+
std::string parseExpr;
5757

5858
std::unordered_map<string, VarInfo> variables;
5959
std::unordered_map<string, std::vector<double>> variable_consts;
@@ -76,10 +76,10 @@ namespace bparser {
7676
void set_result_shape(Shape shape) {
7777
variables["_result_"] = VarInfo(Variable, shape);
7878
}
79-
void parse(string query) {
80-
parseQuery = query;
79+
void parse(string expression) {
80+
parseExpr = expression;
8181

82-
parser.parse(query);
82+
parser.parse(expression);
8383
}
8484

8585
public: //Methods for the gen/run files
@@ -118,8 +118,8 @@ namespace bparser {
118118
PatchArenaPtr get_patch_arena() const {
119119
return arena;
120120
}
121-
string get_query() const {
122-
return parseQuery;
121+
string get_expression() const {
122+
return parseExpr;
123123
}
124124

125125
const std::unordered_map<double*, std::string>& get_inv_map() const{

nitpick/nitpick_generate.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ int main() {
2121
//def is in NITPICK_DEF_FILE
2222
def(exprcase);
2323

24+
if (exprcase.get_expression().empty()) {
25+
Throw() << "No expression was set!";
26+
}
27+
2428
exprcase.allocate(1);
2529
Parser& p = exprcase.get_parser();
2630

@@ -35,5 +39,7 @@ int main() {
3539
file << DagPrinter(dag).print_in_cxx(exprcase.get_inv_map());
3640
file.close();
3741
std::cout << "File " << std::filesystem::current_path() << " " << NITPICK_GEN_FILE << " created from " << NITPICK_DEF_FILE;
42+
3843
::operator delete(buffer);
39-
}
44+
45+
} //main

nitpick/nitpick_run.cc

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,25 @@ using namespace bparser;
1212
int main() {
1313

1414
const uint max_vec_size = 2000;
15-
const size_t buffer_size = sizeof(double) * max_vec_size + 50000;
15+
const size_t buffer_size = sizeof(double) * max_vec_size + 500000;
1616

17-
const uint N = 2048U;
17+
const uint N = 1073741824U; //2^30
1818

1919
void* buffer = ::operator new(buffer_size);
2020
ExprCase exprcase(max_vec_size, (void*)buffer, buffer_size);
2121

2222
def(exprcase);
2323

24-
if (exprcase.get_query().empty()) {
24+
if (exprcase.get_expression().empty()) {
2525
Throw() << "No expression was set!";
2626
}
2727

28-
std::vector<uint> subset = { 0, 1, 2, 3 }; //ctverice doubluu //TODO: autocreate from vec_size
28+
std::vector<uint> subset = { 0, 1, 2, 3, 4,5,6,7,8,9,10,11,12 }; //ctverice doubluu //TODO: autocreate from vec_size
2929
std::vector<uint> vec_sizes({ 16U, 64U, 256U, 1024U });
3030

3131
PatchArenaPtr arena = exprcase.get_patch_arena();
3232
for (uint vec_size : vec_sizes) {
33+
3334
uint n_repeats = N / vec_size;
3435
std::cout << "Running \"" << exprcase.get_query() << "\" " << n_repeats << "x for vec_size: " << vec_size << std::endl;
3536
exprcase.allocate(vec_size);
@@ -38,7 +39,6 @@ int main() {
3839
ExpressionDAG se = gen(exprcase.get_node_map());
3940

4041
ProcessorBase* processor = ProcessorBase::create_processor(se, max_vec_size, bparser::get_simd_size(), arena); //get arena from ExprCase
41-
//ProcessorBase* processor = ProcessorBase::create_processor(se, max_vec_size, bparser::get_simd_size(), nullptr);
4242
processor->set_subset(subset);
4343

4444
auto start_time = std::chrono::high_resolution_clock::now();
@@ -49,17 +49,18 @@ int main() {
4949

5050
double time = std::chrono::duration_cast<std::chrono::duration<double>>(end_time - start_time).count();
5151
std::cout << "Finished in " << time << std::endl;
52-
//processor.get_arena();
53-
delete processor;
5452

55-
exprcase.deallocate();
56-
}
57-
//auto start_time = std::chrono::high_resolution_clock::now();
5853

59-
//TODO:
54+
exprcase.deallocate(); //processor is allocated in arena
55+
} //for
56+
57+
58+
//TODO: have result
6059
//std::cout << "Result: \n";
6160

6261
// Result in the 'vres' value space.
6362
//std::cout << print_vec(vres, vres_size);
63+
6464
::operator delete(buffer);
65-
}
65+
66+
} //main

0 commit comments

Comments
 (0)