Skip to content

Commit

Permalink
Add hybrid test for pcsr.
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeyZi1 committed May 23, 2024
1 parent e0b4b2a commit 8b9c887
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 0 deletions.
11 changes: 11 additions & 0 deletions log/pcsr/propotion.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
livejournal,16,e,insert-read,500000-500000,1.53587e+06
livejournal,16,e,insert-read,500000-500000,1.56299e+06
livejournal,16,e,insert-read,500000-500000,1.52229e+06

livejournal,16,e,insert-read,100000-900000,4.55711e+06
livejournal,16,e,insert-read,100000-900000,4.58366e+06
livejournal,16,e,insert-read,100000-900000,4.56831e+06

livejournal,16,e,insert-read,900000-100000,980870
livejournal,16,e,insert-read,900000-100000,1.00775e+06
livejournal,16,e,insert-read,900000-100000,1.00096e+06
1 change: 1 addition & 0 deletions sys/pcsr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ include_directories(include/algorithms)

add_executable(pcsr_alg test/pcsr_test_alg.cpp)
add_executable(pcsr_edge test/pcsr_test_edge.cpp)
add_executable(pcsr_propotion test/pcsr_test_propotion.cpp)
add_executable(pcsr_mem test/pcsr_test_memory.cpp)
add_executable(pcsr_scala test/pcsr_test_scala.cpp)
# -src 9 -maxiters 5 -f ../../../data/slashdot.adj
2 changes: 2 additions & 0 deletions sys/pcsr/test/pcsr_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
PCSR *G;
std::vector<uint32_t> new_srcs;
std::vector<uint32_t> new_dests;
std::vector<uint32_t> query_srcs;
std::vector<uint32_t> query_dests;
uint32_t num_nodes;
uint64_t num_edges;
std::string src, dest;
Expand Down
105 changes: 105 additions & 0 deletions sys/pcsr/test/pcsr_test_propotion.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#include "pcsr_test.h"

void batch_ins_del_read(commandLine& P){
PRINT("=============== Batch Insert BEGIN ===============");

auto gname = P.getOptionValue("-gname", "none");
auto thd_num = P.getOptionLongValue("-core", 1);
auto log = P.getOptionValue("-log","none");
std::ofstream log_file(log, ios::app);

PCSR &Ga = *G;
// std::vector<uint32_t> update_sizes = {10, 100, 1000 ,10000,100000,1000000, 10000000};
std::vector<uint32_t> update_sizes = {900000};
std::vector<uint32_t> update_sizes2 = {100000};
auto r = random_aspen();
auto update_times = std::vector<double>();
size_t n_trials = 1;
for (size_t us=0; us<update_sizes.size(); us++) {
Ga = *G;
printf("GN: %u %u\n",Ga.get_n(),Ga.edges.N);
double avg_insert = 0;
double avg_delete = 0;
double avg_read = 0;
std::cout << "Running batch size: " << update_sizes[us] << std::endl;

if (update_sizes[us] < 10000000)
n_trials = 20;
else n_trials = 5;
size_t updates_to_run = update_sizes[us];
size_t updates_to_run2 = update_sizes2[us];
auto perm = get_random_permutation(updates_to_run);
for (size_t ts=0; ts<n_trials; ts++) {
uint32_t num_nodes = Ga.get_n();
new_srcs.clear();
new_dests.clear();
query_srcs.clear();
query_dests.clear();

double a = 0.5;
double b = 0.1;
double c = 0.1;
size_t nn = 1 << (log2_up(num_nodes) - 1);
auto rmat = rMat<uint32_t>(nn, r.ith_rand(100+ts), a, b, c);
for( uint32_t i = 0; i < updates_to_run; i++) {
std::pair<uint32_t, uint32_t> edge = rmat(i);
new_srcs.push_back(edge.first);
new_dests.push_back(edge.second);
}
// generate random deges from new_srcs and new_dests
std::default_random_engine generator;
std::uniform_int_distribution<size_t> distribution(0, new_srcs.size() - 1);
for (size_t i = 0; i < updates_to_run2; i++) {
size_t index = distribution(generator);
query_srcs.push_back(new_srcs[index]);
query_dests.push_back(new_dests[index]);
}


gettimeofday(&t_start, &tzp);

// for (uint32_t i =0 ; i< 500000;i++){
// Ga.add_edge_update(new_srcs[i],new_dests[i],1);
// Ga.find_value(query_srcs[i], query_dests[i]);
// }
// for (uint32_t i =0 ; i< 100000;i++){
// Ga.add_edge_update(new_srcs[i],new_dests[i],1);
// for (uint32_t n = 0; n < 9; n++){
// Ga.find_value(query_srcs[i*9+n], query_dests[i*9+n]);
// }
// }
for (uint32_t i =0 ; i< 100000;i++){
for (uint32_t n = 0; n < 9; n++){
Ga.add_edge_update(new_srcs[i*9+n], new_dests[i*9+n], 1);
}
Ga.find_value(query_srcs[i],query_dests[i]);
}

gettimeofday(&t_end, &tzp);
avg_insert += cal_time_elapsed(&t_start, &t_end);

}
double time_i = (double) avg_insert / n_trials;
double insert_throughput = 1000000 / time_i;
printf("batch_size = %zu, average insert: %f, throughput %e\n", updates_to_run, time_i, insert_throughput);
log_file<< gname<<","<<thd_num<<",e,insert-read,"<< update_sizes[us] <<"-" << update_sizes2[us]<<","<<insert_throughput << "\n";
}
PRINT("=============== Batch Insert END ===============");
}


// -src 9 -maxiters 5 -f ../../../data/slashdot.adj
// -gname LiveJournal -core 1 -f ../../../data/ADJgraph/LiveJournal.adj
int main(int argc, char** argv) {
srand(time(NULL));
commandLine P(argc, argv);
auto thd_num = P.getOptionLongValue("-core", 1);
printf("Running PCSR using %ld threads.\n", thd_num );
load_graph(P);

batch_ins_del_read(P);

del_G();
printf("!!!!! TEST OVER !!!!!\n");
return 0;
}

0 comments on commit 8b9c887

Please sign in to comment.