Skip to content

Commit

Permalink
converter
Browse files Browse the repository at this point in the history
  • Loading branch information
ldhulipala committed Jan 24, 2020
1 parent 8f5cc93 commit 3833624
Show file tree
Hide file tree
Showing 7 changed files with 887 additions and 11 deletions.
8 changes: 4 additions & 4 deletions ligra/encodings/byte_pd_amortized.h
Original file line number Diff line number Diff line change
Expand Up @@ -1258,19 +1258,19 @@ inline void filter(P pred, uchar* edge_start, const uintE& source,

template <class W, class I>
inline long sequentialCompressEdgeSet(uchar* edgeArray, size_t current_offset,
uintT degree, uintE source, I& it) {
uintT degree, uintE source, I& it, size_t encoded_degree=PARALLEL_DEGREE) {
if (degree > 0) {
size_t start_offset = current_offset;
size_t num_blocks = 1 + (degree - 1) / PARALLEL_DEGREE;
size_t num_blocks = 1 + (degree - 1) / encoded_degree;
uintE* vertex_ctr = (uintE*)edgeArray;
*vertex_ctr = degree;
uintE* block_offsets = (uintE*)(edgeArray + sizeof(uintE));
current_offset +=
sizeof(uintE) +
(num_blocks - 1) * sizeof(uintE); // virtual deg + block_offs
for (size_t i = 0; i < num_blocks; i++) {
size_t o = i * PARALLEL_DEGREE;
size_t end = std::min<size_t>(PARALLEL_DEGREE, degree - o);
size_t o = i * encoded_degree;
size_t end = std::min<size_t>(encoded_degree, degree - o);

if (i > 0)
block_offsets[i - 1] =
Expand Down
4 changes: 4 additions & 0 deletions utils/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Using converter:
`numactl -i all ./converter -bs 32 -rounds 1 -s -m -enc bytepd-amortized -o /ssd1/graphs/tmp/soc-LJ_sym.bytepda ~/inputs/soc-LiveJournal1_sym.adj`
Converts a symmetric adjacencygraph into a bytepd-amortized encoded graph, where
the compression block size is 32.
11 changes: 5 additions & 6 deletions utils/compressor.C
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace bytepd_amortized {
template <class Graph>
void write_graph_bytepd_amortized_directed(Graph& GA, ofstream& out) {
using W = typename Graph::weight_type;
size_t n = GA.n; size_t m = GA.m;
size_t n = GA.n;

// out-edges
// 1. Calculate total size
Expand Down Expand Up @@ -72,7 +72,7 @@ namespace bytepd_amortized {
uintE deg = degrees[i];
if (deg > 0) {
auto it = GA.get_vertex(i).getOutIter(i);
long nbytes = byte::sequentialCompressEdgeSet<W>(edges.begin() + byte_offsets[i], 0, deg, (uintE)i, it);
size_t nbytes = byte::sequentialCompressEdgeSet<W>(edges.begin() + byte_offsets[i], 0, deg, (uintE)i, it);
if (nbytes != (byte_offsets[i+1] - byte_offsets[i])) {
std::cout << "nbytes = " << nbytes << ". Should be: " << (byte_offsets[i+1] - byte_offsets[i]) << " deg = " << deg << " i = " << i << std::endl;
exit(0);
Expand Down Expand Up @@ -141,7 +141,7 @@ namespace bytepd_amortized {
uintE deg = degrees[i];
if (deg > 0) {
auto it = GA.get_vertex(i).getInIter(i);
long nbytes = byte::sequentialCompressEdgeSet<W>(edges.begin() + byte_offsets[i], 0, deg, (uintE)i, it);
size_t nbytes = byte::sequentialCompressEdgeSet<W>(edges.begin() + byte_offsets[i], 0, deg, (uintE)i, it);
if (nbytes != (byte_offsets[i+1] - byte_offsets[i])) {
std::cout << "nbytes = " << nbytes << ". Should be: " << (byte_offsets[i+1] - byte_offsets[i]) << " deg = " << deg << " i = " << i << std::endl;
exit(0);
Expand All @@ -166,7 +166,7 @@ namespace bytepd_amortized {
write_graph_bytepd_amortized_directed(GA, out);
return;
}
size_t n = GA.n; size_t m = GA.m;
size_t n = GA.n;

// auto xors = sequence<size_t>(n);
// parallel_for(size_t i=0; i<n; i++) {
Expand Down Expand Up @@ -290,7 +290,7 @@ namespace bytepd_amortized {
uintE deg = degrees[i];
if (deg > 0) {
auto it = GA.get_vertex(i).getOutIter(i);
long nbytes = byte::sequentialCompressEdgeSet<W>(edges.begin() + byte_offsets[i], 0, deg, (uintE)i, it);
size_t nbytes = byte::sequentialCompressEdgeSet<W>(edges.begin() + byte_offsets[i], 0, deg, (uintE)i, it);

// uchar* edgeArray = edges.begin() + byte_offsets[i];
// size_t degree = deg;
Expand Down Expand Up @@ -405,7 +405,6 @@ namespace bytepd_amortized {

template <class Graph>
double converter(Graph& GA, commandLine P) {
using W = typename Graph::weight_type;
auto outfile = P.getOptionValue("-o", "");
bool symmetric = P.getOptionValue("-s");
std::cout << "Outfile: " << outfile << std::endl;
Expand Down
3 changes: 3 additions & 0 deletions utils/converter.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#include "converter.h"

generate_main(converter, false);
Loading

0 comments on commit 3833624

Please sign in to comment.