Skip to content

Commit

Permalink
radix
Browse files Browse the repository at this point in the history
  • Loading branch information
jerryidk committed Feb 16, 2024
1 parent 631e164 commit e789be2
Show file tree
Hide file tree
Showing 6 changed files with 223 additions and 110 deletions.
3 changes: 3 additions & 0 deletions .gitconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[user]
name = jerryidk
email = [email protected]
22 changes: 15 additions & 7 deletions include/input_reader/file.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@ class FileReader : public InputReader<std::string_view> {
: FileReader(std::move(input_file), 0, 1) {}

~FileReader() {
PLOG_INFO_IF(offset_ != part_end_)
<< "Offset mismatch: expected " << part_end_ << "; actual: " << offset_;
if(offset_ != part_end_)
{
PLOG_INFO << "Offset mismatch: expected " << part_end_ << "; actual: " << offset_;
}
}

/// Copy the next line to `output` and advance the offset.
Expand Down Expand Up @@ -131,8 +133,11 @@ class FileReader : public InputReader<std::string_view> {
part_id_(part_id),
num_parts_(num_parts),
buffer_(4096) {
PLOG_FATAL_IF(part_id >= num_parts)
<< "part_id(" << part_id << " ) >= num_parts(" << num_parts << ")";
if(part_id >= num_parts)
{
PLOG_FATAL << "part_id(" << part_id << " ) >= num_parts(" << num_parts << ")";
}

// Get the size of the file and calculate the range of this partition.
// We are doing it here for now because I don't want to mess with the
// parameter passing.
Expand All @@ -158,9 +163,12 @@ class FileReader : public InputReader<std::string_view> {

/// Creats a ifstream and log if fail.
static std::ifstream open_file(std::string_view filename) {
std::ifstream file(filename.data());
PLOG_FATAL_IF(file.fail())
<< "Failed to open file " << filename << ": " << file.rdstate();
std::ifstream file(filename.data());

if(file.fail())
{
PLOG_FATAL << "Failed to open file " << filename << ": " << file.rdstate();
}
return file;
}

Expand Down
6 changes: 6 additions & 0 deletions include/tests/KmerTest.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,15 @@ class KmerTest {

void count_kmer_radix(Shard *sh, const Configuration &config,
std::barrier<VoidFn> *barrier, RadixContext &context);

void count_kmer_radix_custom(Shard *sh, const Configuration &config,
std::barrier<VoidFn> *barrier,
RadixContext &context);


void count_kmer_radix_jerry(Shard *sh, const Configuration &config,
std::barrier<VoidFn> *barrier,
RadixContext &context, BaseHashTable *ht);
};

} // namespace kmercounter
Expand Down
44 changes: 44 additions & 0 deletions jerry-benchmark.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash

# ./build/dramhit --help to see flags

function bench_regular()
{
sudo ./build/dramhit \
--mode 4 \
--ht-type 3 \
--numa-split 0 \
--num-threads 64 \
--ht-size 8589934592 \
--in-file /opt/dramhit/kmer_dataset/SRR1513870.fastq \
--k 6 > jerry_benchmark.log
}

function bench_radix()
{
sudo ./build/dramhit \
--mode 14 \
--ht-type 3 \
--numa-split 0 \
--num-threads 64 \
--ht-size 8589934592 \
--in-file /opt/dramhit/kmer_dataset/SRR1513870.fastq \
--k 6 --d 8 > jerry_benchmark.log
}

function bench() {
bench_radix
bench_regular
}

function build() {
cmake --build build/
}

if [ "$1" == "build" ]; then
build
elif [ "$1" == "bench" ]; then
bench
else
echo "Invalid option"
fi
12 changes: 4 additions & 8 deletions src/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ void Application::shard_thread(int tid,
int Application::spawn_shard_threads() {
cpu_set_t cpuset;

PLOG_INFO.printf("kosustartNumber of shards: %u", config.num_threads);
PLOG_INFO.printf("Number of shards: %u", config.num_threads);
this->shards = (Shard *)std::aligned_alloc(
CACHE_LINE_SIZE, sizeof(Shard) * config.num_threads);

Expand Down Expand Up @@ -315,14 +315,10 @@ int Application::spawn_shard_threads() {
exit(-1);
}

std::function<void()> on_completion = []() noexcept {
// For debugging
// PLOG_INFO << "Phase completed.";
};

std::function<void()> on_sync_complete = sync_complete;

std::barrier barrier(config.num_threads, on_sync_complete);

uint32_t i = 0;
for (uint32_t assigned_cpu : this->np->get_assigned_cpu_list()) {
if (assigned_cpu == 0) continue;
Expand All @@ -339,7 +335,6 @@ int Application::spawn_shard_threads() {
i += 1;
}

PLOG_INFO.printf("kos i:%u", i);
// Pin main application thread to cpu 0 and run our thread routine
CPU_ZERO(&cpuset);
CPU_SET(0, &cpuset);
Expand Down Expand Up @@ -400,7 +395,8 @@ int Application::process(int argc, char *argv[]) {
"10: Cache Miss test\n"
"11: Zipfian non-bqueue test\n"
"12: RW-ratio test\n"
"13: Hashjoin")("base",
"13: Hashjoin\n"
"14: Fastq insert with Radix Parition")("base",
po::value<uint64_t>(&config.kmer_create_data_base)
->default_value(def.kmer_create_data_base),
"Number of base K-mers")(
Expand Down
Loading

0 comments on commit e789be2

Please sign in to comment.