Skip to content
Snippets Groups Projects
Commit 184d584d authored by Recolic Keghart's avatar Recolic Keghart
Browse files

bugfix & add test

parent 46d3d3b3
No related branches found
No related tags found
No related merge requests found
Pipeline #29 failed with stages
in 3 minutes and 45 seconds
......@@ -26,3 +26,4 @@ hw3/kmer_hash
hw3/include
hw3/smaller
hw3/kv_test
hw3/dvector_test
......@@ -18,13 +18,28 @@ build:
paths:
- hw3/kmer_hash
- hw3/kv_test
- hw3/dvector_test
expire_in: 20 minutes
test:
test_1proc_whole:
stage: test
script:
- wget https://recolic.net/tmp/tiny.txt
- hw3/kmer_hash tiny.txt test
- timeout 1m hw3/kmer_hash tiny.txt test
- sha1sum test_0.dat | grep 69af6081642850426f1b545ccf61b704820f5251
\ No newline at end of file
test_par_whole:
stage: test
script:
- export PATH="/opt/upcxx/bin/:$PATH"
- wget https://recolic.net/tmp/tiny.txt
- timeout 1m upcxx-run -n 16 hw3/kmer_hash tiny.txt test
- ls test_15.dat test_0.dat test_9.dat
test_component:
stage: test
script:
- export PATH="/opt/upcxx/bin/:$PATH"
- upcxx-run -n 2 hw3/kv_test
- upcxx-run -n 2 hw3/dvector_test
......@@ -13,7 +13,7 @@ CXX = upcxx -O3 -std=c++14 -DHASHMAP_SIZE_HINT_FACTOR=$(SIZEHINT) -g
CXXFLAGS = `upcxx-meta PPFLAGS` `upcxx-meta LDFLAGS`
LDFLAGS = `upcxx-meta LIBFLAGS`
all: kmer_hash kv_naive_test
all: kmer_hash kv_naive_test dvector_naive_test
.PHONY: kmer_hash all
......@@ -26,3 +26,5 @@ clean:
kv_naive_test:
upcxx kv_test.cc -o kv_test -std=c++17 -z muldefs -g
dvector_naive_test:
upcxx dvector_test.cc -o dvector_test -std=c++17 -z muldefs -g
#include "upcxx_dist_vector.hpp"
#include <upcxx/upcxx.hpp>
#include <stdexcept>
#define dynamic_assert(b) do { \
if(not (b)) \
throw std::runtime_error(std::string("Assertion failed at ") + __FILE__ + ":" + std::to_string(__LINE__)); \
} while(false)
struct dataType {
uint64_t padding;
int data;
};
int main() {
upcxx::init();
upcxx_matrix<dataType> mat(1024);
size_t rows = 1024;
mat.set_rows(rows);
try {
dynamic_assert(mat.get_cols_of_row(32) == 0);
mat.get(64, 0);
dynamic_assert(("Unwanted success! get should fail", false));
}
catch(std::out_of_range &o) {
}
upcxx::barrier(); // without this barrier, the access above may success at rank1.
if(upcxx::rank_me() == 0) {
mat.push_to_row(100, dataType{123, 666});
mat.push_to_row(100, dataType{124, 666});
mat.push_to_row(100, dataType{125, 666});
mat.push_to_row(100, dataType{126, 666});
mat.push_to_row(100, dataType{127, 666});
mat.push_to_row(101, dataType{777, 555});
dynamic_assert(mat.get_cols_of_row(100) == 5);
rlib::println("rank0 pushed!");
}
if(upcxx::rank_me() == 1) {
mat.push_to_row(100101, dataType{123, 666});
mat.push_to_row(100101, dataType{124, 666});
mat.push_to_row(100101, dataType{125, 666});
mat.push_to_row(100101, dataType{126, 666});
mat.push_to_row(100101, dataType{127, 666});
mat.push_to_row(101, dataType{777, 555});
mat.push_to_row(101, dataType{777, 5525});
mat.push_to_row(101, dataType{777, 5525});
dynamic_assert(mat.get_cols_of_row(100101) == 5);
rlib::println("rank0 pushed!");
}
upcxx::barrier();
dynamic_assert(mat.get_cols_of_row(101) == 4);
auto val = mat.get(100101, 4);
dynamic_assert(val.data == 666 and val.padding == 127);
val = mat.get(101, 3);
dynamic_assert(val.padding == 777);
upcxx::finalize();
}
......@@ -70,7 +70,8 @@ int main(int argc, char **argv) {
for (auto &kmer : kmers) {
bool success = hashmap.insert(kmer);
if (!success) {
throw std::runtime_error("Error: HashMap is full!");
// Recolic: this insert is set_if_is_mine now.
//throw std::runtime_error("Error: HashMap is full!");
}
if (upcxx::rank_me()==0 and kmer.backwardExt() == 'F') {
......
......@@ -8,7 +8,7 @@ int main() {
try {
auto [succ, val] = kvs.get(1.23);
if(succ)
rlib::println("FUCK! succ! val is", val);
throw std::runtime_error("get empty db failed.");
}
catch(std::out_of_range &o) {
......@@ -27,8 +27,9 @@ int main() {
auto [succ, val] = kvs.get(6.666);
if(not succ)
rlib::println("not succ!");
rlib::println(upcxx::rank_me(), val);
throw std::runtime_error("not succ!");
if(val != 123)
throw std::runtime_error("not succ!");
upcxx::finalize();
......
......@@ -56,7 +56,7 @@ public:
static_assert(sizeof(T) >= sizeof(uint64_t), "T should larger than 64b");
void set_rows(uint64_t val) {
// set size of col 0
buf.set(index2key(SIZE_SLOT, 0), val);
buf.set(index2key(SIZE_SLOT, 0), *(T*)&val);
}
void push_to_row(uint64_t row_index, const T &data) {
//std::cout << "push_to:" << row_index << std::endl;
......
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