Skip to content

Commit

Permalink
feat: use huge pages via TBBmalloc per default
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielSeemaier committed Apr 29, 2024
1 parent c7bc3dc commit 8aeed8c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
8 changes: 7 additions & 1 deletion apps/KaMinPar.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

#include <iostream>

#include <tbb/global_control.h>
#include <tbb/scalable_allocator.h>

#if __has_include(<numa.h>)
#include <numa.h>
Expand Down Expand Up @@ -54,6 +54,8 @@ struct ApplicationContext {
std::string graph_filename = "";
std::string partition_filename = "";
io::GraphFileFormat graph_file_format = io::GraphFileFormat::METIS;

bool no_huge_pages = false;
};

void setup_context(CLI::App &cli, ApplicationContext &app, Context &ctx) {
Expand Down Expand Up @@ -156,6 +158,7 @@ The output should be stored in a file and can be used by the -C,--config option.
"Validate input parameters before partitioning (currently only "
"checks the graph format)."
);
cli.add_flag("--no-huge-pages", app.no_huge_pages, "Do not use huge pages via TBBmalloc.");

// Algorithmic options
create_all_options(&cli, ctx);
Expand Down Expand Up @@ -193,6 +196,9 @@ int main(int argc, char *argv[]) {
std::exit(0);
}

// If available, use huge pages for large allocations
scalable_allocation_mode(TBBMALLOC_USE_HUGE_PAGES, !app.no_huge_pages);

ENABLE_HEAP_PROFILER();

// Read the input graph and allocate memory for the partition
Expand Down
24 changes: 17 additions & 7 deletions apps/dKaMinPar.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@

#include <kagen.h>
#include <mpi.h>
#include <tbb/scalable_allocator.h>

#include "kaminpar-common/environment.h"
#include "kaminpar-common/strutils.h"

#include "apps/io/dist_io.h"

Expand Down Expand Up @@ -42,6 +42,8 @@ struct ApplicationContext {

std::string graph_filename = "";
std::string partition_filename = "";

bool no_huge_pages = false;
};

void setup_context(CLI::App &cli, ApplicationContext &app, Context &ctx) {
Expand Down Expand Up @@ -91,9 +93,11 @@ The output should be stored in a file and can be used by the -C,--config option.
->default_val(app.num_threads);
cli.add_option("--io-format", app.io_format)
->transform(CLI::CheckedTransformer(kagen::GetInputFormatMap()).description(""))
->description(R"(Graph input format. By default, guess the file format from the file extension. Explicit options are:
->description(
R"(Graph input format. By default, guess the file format from the file extension. Explicit options are:
- metis: text format used by the Metis family
- parhip: binary format used by ParHiP (+ extensions))")
- parhip: binary format used by ParHiP (+ extensions))"
)
->capture_default_str();
cli.add_option("--io-distribution", app.io_distribution)
->transform(CLI::CheckedTransformer(kagen::GetGraphDistributionMap()).description(""))
Expand All @@ -112,6 +116,8 @@ The output should be stored in a file and can be used by the -C,--config option.
->capture_default_str();
cli.add_flag("--check-input-graph", app.check_input_graph, "Check input graph for errors.");

cli.add_flag("--no-huge-pages", app.no_huge_pages, "Do not use huge pages via TBBmalloc.");

// Algorithmic options
create_all_options(&cli, ctx);
}
Expand Down Expand Up @@ -171,8 +177,9 @@ NodeID load_kagen_graph(const ApplicationContext &app, dKaMinPar &partitioner) {
} // namespace

int main(int argc, char *argv[]) {
int provided;
int provided, rank;
MPI_Init_thread(&argc, &argv, MPI_THREAD_FUNNELED, &provided);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);

CLI::App cli("dKaMinPar: (Somewhat) Minimal Distributed Deep Multilevel "
"Graph Partitioner");
Expand All @@ -181,18 +188,21 @@ int main(int argc, char *argv[]) {
setup_context(cli, app, ctx);
CLI11_PARSE(cli, argc, argv);

if (app.dump_config) {
if (rank == 0 && app.dump_config) {
CLI::App dump;
create_all_options(&dump, ctx);
std::cout << dump.config_to_str(true, true);
std::exit(1);
}

if (app.show_version) {
LOG << Environment::GIT_SHA1;
if (rank == 0 && app.show_version) {
std::cout << Environment::GIT_SHA1 << std::endl;
std::exit(0);
}

// If available, use huge pages for large allocations
scalable_allocation_mode(TBBMALLOC_USE_HUGE_PAGES, !app.no_huge_pages);

dKaMinPar partitioner(MPI_COMM_WORLD, app.num_threads, ctx);
dKaMinPar::reseed(app.seed);

Expand Down

0 comments on commit 8aeed8c

Please sign in to comment.