Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "add parallel binary edge list shuffler script" #68

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions scripts/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ target_link_libraries(divide-into-batches PRIVATE Boost::program_options)

add_executable(count-batched count_batched.cpp)
target_link_libraries(count-batched PRIVATE Boost::program_options)

add_executable(shufbel shufbel.cpp)
target_link_libraries(shufbel PRIVATE Boost::program_options)
77 changes: 77 additions & 0 deletions scripts/shufbel.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
// SPDX-License-Identifier: BSD-2-Clause
// Copyright (c) 2023. University of Texas at Austin. All rights reserved.

#include <stdint.h>
#include <linux/mman.h>

#include <random>
#include <string>
#include <iostream>

#include <boost/program_options.hpp>
#include <boost/interprocess/file_mapping.hpp>
#include <boost/interprocess/mapped_region.hpp>

struct Edge {
uint64_t src;
uint64_t dst;

friend inline void swap(Edge& lhs, Edge& rhs) {
using std::swap;
uint64_t src = lhs.src;
uint64_t dst = lhs.dst;
lhs.src = rhs.src;
lhs.dst = rhs.dst;
rhs.src = src;
rhs.dst = dst;
}
} __attribute__((packed));

static_assert(sizeof(Edge) == 16, "Edge must be 16 bytes.");

namespace bip = boost::interprocess;
namespace po = boost::program_options;

int main(int argc, char const* argv[]) {
po::options_description desc("Shuffle binary edge list in-place");
desc.add_options() //
("help,h", "Print help messages") //
("file", po::value<std::string>(), "Input file path") //
("rseed", po::value<unsigned int>()->default_value(0),
"Fixed random seed");

po::variables_map vm;
try {
// Parse command line arguments
po::store(po::parse_command_line(argc, argv, desc), vm);
po::notify(vm);
} catch (po::error& e) {
std::cout << e.what() << std::endl;
return 1;
}

if (vm.count("help")) {
std::cout << desc << std::endl;
return 1;
}

if (vm.count("file") != 1) {
std::cerr << "Must specify an input file with --file" << std::endl;
return 1;
}

bip::file_mapping input_file_mapping(vm["file"].as<std::string>().c_str(),
bip::read_write);
bip::mapped_region mapped_rgn(input_file_mapping, bip::read_write, 0, 0,
nullptr, MAP_POPULATE);
mapped_rgn.advise(bip::mapped_region::advice_willneed);

// rng
std::mt19937 rng(vm["rseed"].as<unsigned int>());
std::shuffle(reinterpret_cast<Edge*>(mapped_rgn.get_address()),
reinterpret_cast<Edge*>(
reinterpret_cast<char*>(mapped_rgn.get_address()) +
mapped_rgn.get_size()),
rng);
return 0;
}
5 changes: 0 additions & 5 deletions scripts/shufbel/go.mod

This file was deleted.

2 changes: 0 additions & 2 deletions scripts/shufbel/go.sum

This file was deleted.

128 changes: 0 additions & 128 deletions scripts/shufbel/shufbel.go

This file was deleted.