Skip to content

Commit

Permalink
Executioner_unit and run.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
billsioros committed Dec 7, 2018
1 parent fc5ecdb commit 9248cc6
Show file tree
Hide file tree
Showing 4 changed files with 148 additions and 27 deletions.
33 changes: 33 additions & 0 deletions benchmark.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash

if [ "$#" -lt 2 ]
then
echo "Usage: $(basename "$0") [EXE] [OUT] [MACROS]"
exit 1
fi

exe="$1"; shift;
out="$1"; shift;

if [ -f "$out" ]
then
read -p "Are you sure you want to overwrite $out: " answer
if [[ "$answer" != [yY] ]] && [[ "$answer" != [yY][eE][sS] ]]
then
exit 2
fi
fi

truncate --size=0 "$out"

macros=(__SMALL__ ""$*""); shift;

for ((pow = 4; pow <= 64; pow *= 2))
do
eval "./build.sh -g __CACHE_SIZE__=$((pow * 1024))"
for macro in "${macros[@]}"
do
eval "./build.sh -b -q -u $macro -u __CACHE_SIZE__=$((pow * 1024)) -x $exe"
"$exe" >> "$out"
done
done
34 changes: 11 additions & 23 deletions run.sh
Original file line number Diff line number Diff line change
@@ -1,33 +1,21 @@
#!/bin/bash

if [ "$#" -lt 2 ]
if [ "$#" -lt 4 ]
then
echo "Usage: $(basename "$0") [EXE] [OUT] [MACROS]"
echo "Usage: $(basename "$0") <UNIT> <WORKLOAD> <RESULTS> <FILES>"
exit 1
fi

exe="$1"; shift;
out="$1"; shift;
unit="$1"; shift
workload="$1"; shift
results="$1"; shift

if [ -f "$out" ]
then
read -p "Are you sure you want to overwrite $out: " answer
if [[ "$answer" != [yY] ]] && [[ "$answer" != [yY][eE][sS] ]]
then
exit 2
fi
fi
eval "./build.sh -x $unit"

files=$(for file in "$*"; do echo "$(realpath $file)"; done)

truncate --size=0 "$out"
queries=$(cat "$workload")

macros=(__SMALL__ ""$*""); shift;
input=$(echo -e "$files\nDone\n$queries")

for ((pow = 4; pow <= 64; pow *= 2))
do
eval "./build.sh -g __CACHE_SIZE__=$((pow * 1024))"
for macro in "${macros[@]}"
do
eval "./build.sh -b -q -u $macro -u __CACHE_SIZE__=$((pow * 1024)) -x $exe"
"$exe" >> "$out"
done
done
echo "$input" | "$unit" &> "$results"
38 changes: 34 additions & 4 deletions test/executioner_unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@

#include <fcntl.h>

#include <relation.hpp>
#include <list.hpp>

// Generate a list of the full paths of the relations and store it in files.txt
// for file in "$(ls ./test_data/small/r*)"; do echo "$(realpath $file)"; done > ./test_data/files.txt && echo "Done" >> ./test_data/files.txt
#include <relation.hpp>
#include <query.hpp>
#include <executioner.hpp>

// Macro used in order to exit if condition is met
#define exit_if(condition, message) \
Expand Down Expand Up @@ -96,10 +95,14 @@ int main()
std::memmove(rsptr, mapping_clone, sizeof(tuple_key_t));
reinterpret_cast<tuple_key_t *&>(mapping_clone)++;

std::cout << "RHJ::meta[" << i << "].rowSize = " << RHJ::meta[i].rowSize << std::endl;

void * csptr = reinterpret_cast<void *>(&RHJ::meta[i].columnSize);
std::memmove(csptr, mapping_clone, sizeof(tuple_key_t));
reinterpret_cast<tuple_key_t *&>(mapping_clone)++;

std::cout << "RHJ::meta[" << i << "].columnSize = " << RHJ::meta[i].columnSize << std::endl;

// Create Index
RHJ::meta[i].columns = new tuple_payload_t*[RHJ::meta[i].columnSize];
for(tuple_key_t j = 0UL; j < RHJ::meta[i].columnSize; j++)
Expand All @@ -112,6 +115,33 @@ int main()
}
}

std::size_t query_max = 256UL; char * query_str = new char[query_max];

for (;;)
{
ssize_t query_len;
if ((query_len = getline(&query_str, &query_max, stdin)) < 0)
{
exit_if(errno == EINVAL || errno == ENOMEM, query_str); break;
}

if (query_str[query_len - 1] == '\n') query_str[--query_len] = '\0';

if (!std::strcmp(query_str, "F"))
continue;

RHJ::Executioner demios;

std::vector<std::string> checksums = demios.execute(RHJ::Query(query_str));

for (const auto &checksum : checksums)
std::cout << checksum << ' ';

std::cout << std::endl;
}

delete[] query_str;

for(std::size_t i = 0; i < total; i++)
{
exit_if(munmap(RHJ::meta[i].mapping, RHJ::meta[i].mappingSize) < 0, ("munmap No." + std::to_string(i)).c_str());
Expand Down
70 changes: 70 additions & 0 deletions test_data/input.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/home/massiva/Documents/Courses/Application-Development-for-Information-Systems/test_data/small/r0
/home/massiva/Documents/Courses/Application-Development-for-Information-Systems/test_data/small/r1
/home/massiva/Documents/Courses/Application-Development-for-Information-Systems/test_data/small/r10
/home/massiva/Documents/Courses/Application-Development-for-Information-Systems/test_data/small/r11
/home/massiva/Documents/Courses/Application-Development-for-Information-Systems/test_data/small/r12
/home/massiva/Documents/Courses/Application-Development-for-Information-Systems/test_data/small/r13
/home/massiva/Documents/Courses/Application-Development-for-Information-Systems/test_data/small/r2
/home/massiva/Documents/Courses/Application-Development-for-Information-Systems/test_data/small/r3
/home/massiva/Documents/Courses/Application-Development-for-Information-Systems/test_data/small/r4
/home/massiva/Documents/Courses/Application-Development-for-Information-Systems/test_data/small/r5
/home/massiva/Documents/Courses/Application-Development-for-Information-Systems/test_data/small/r6
/home/massiva/Documents/Courses/Application-Development-for-Information-Systems/test_data/small/r7
/home/massiva/Documents/Courses/Application-Development-for-Information-Systems/test_data/small/r8
/home/massiva/Documents/Courses/Application-Development-for-Information-Systems/test_data/small/r9
Done
3 0 1|0.2=1.0&0.1=2.0&0.2>3499|1.2 0.1
5 0|0.2=1.0&0.3=9881|1.1 0.2 1.0
9 0 2|0.1=1.0&1.0=2.2&0.0>12472|1.0 0.3 0.4
9 0|0.1=1.0&0.1>1150|0.3 1.0
6 1 12|0.1=1.0&1.0=2.2&0.0<62236|1.0
11 0 5|0.2=1.0&1.0=2.2&0.1=5784|2.3 0.1 0.1
4 1 2 11|0.1=1.0&1.0=2.1&1.0=3.1&0.1>2493|3.2 2.2 2.1
10 0 13 1|0.2=1.0&1.0=2.2&0.1=3.0&0.1=209|0.2 2.5 2.2
6 1 11 5|0.1=1.0&1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.2
0 13 7 10|0.0=1.2&0.0=2.1&0.0=3.2&1.2>295|3.2 0.0
7 1 3|0.2=1.0&1.0=2.1&1.0=0.2&0.2>6082|2.3 2.1
0 7 10 5|0.0=1.1&0.0=2.2&0.0=3.2&1.3=8728|2.0 3.1
1 4 9 8|0.0=1.1&0.0=2.2&0.0=3.1&1.1>2936|1.0 1.0 3.0
4 1|0.1=1.0&0.1<9795|1.2 0.1
11 1|0.1=1.0&0.1<1688|0.1
5 0|0.2=1.0&0.0<1171|1.0 0.3
4 1 6|0.1=1.0&1.0=2.1&0.0<13500|2.1 0.1 0.0
13 13|0.1=1.2&1.6=8220|1.5
F
11 0 8|0.2=1.0&1.0=2.2&0.2>4041|1.0 1.1 1.0
8 0 10|0.2=1.0&1.0=2.2&0.3<9473|0.3 2.0
5 1 8|0.1=1.0&1.0=2.1&0.1<3560|1.2
13 0 2|0.2=1.0&1.0=0.1&1.0=2.2&0.1>4477|2.0 2.3 1.2
8 0 13 13|0.2=1.0&1.0=2.2&2.1=3.2&0.1>7860|3.3 2.1 3.6
F

0 comments on commit 9248cc6

Please sign in to comment.