Skip to content

Commit

Permalink
c
Browse files Browse the repository at this point in the history
  • Loading branch information
jerryidk committed Mar 23, 2024
1 parent 42672ba commit 9f270e8
Show file tree
Hide file tree
Showing 14 changed files with 377 additions and 466 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ option(BUILD_EXAMPLE "Build examples." OFF)
option(LEGACY_PAPI "Use Vikram's PAPI stuff to do performance monitering." OFF)
option(HIGH_LEVEL_PAPI "Use PAPI high-level monitoring" OFF)
option(VTUNE "Use VTUNE to do performance monitering." OFF)
option(AGGR "Use aggregation hashtable (histogram)" OFF)
option(AGGR "Use aggregation hashtable (histogram)" ON)
option(BQUEUE "Enable bqueue tests" OFF)
option(XORWOW "Xorwow" OFF)
option(BQ_ZIPFIAN "Enable global zipfian distribution generation" ON)
Expand Down
10 changes: 6 additions & 4 deletions include/hashtables/array_kht.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,14 @@ class ArrayHashTable : public BaseHashTable {
#endif

uint64_t hash = this->hash((const char *)data);
size_t idx = hash;

size_t idx = hash & (this->capacity - 1); // modulo
// size_t idx = fastrange32(hash, this->capacity); // modulo

KVQ *elem = const_cast<KVQ *>(reinterpret_cast<const KVQ *>(data));

KV *curr = &this->hashtable[idx];
if (curr->is_empty()) {
PLOGV.printf("inserting key %llu at idx %llu", elem->key, idx);
bool cas_res = curr->insert(elem);
curr->insert(elem);
} else {
curr->update(elem);
}
Expand Down Expand Up @@ -124,6 +124,8 @@ class ArrayHashTable : public BaseHashTable {
KVQ q;
q.idx = this->hash((const char *)&data.key);
q.value = data.value;

PLOG_INFO.printf("key insertion: %d", data.key);
__insert_one(&q, collector);
}
}
Expand Down
37 changes: 18 additions & 19 deletions include/tests/KmerTest.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,30 @@
#include "input_reader/fastq.hpp"
#include "types.hpp"


namespace kmercounter {

class KmerTest {
private:
Kmer packkmer(const char* s, int k);
uint64_t radix_partition( RadixContext* context,
BufferedPartition** local_partitions,
input_reader::FastqReader& reader,
int id, int k);
public:
void count_kmer(Shard *sh, const Configuration &config, BaseHashTable *ht,
std::barrier<VoidFn> *barrier);

void count_kmer_radix_partition_global(Shard* sh, const Configuration& config,
std::barrier<VoidFn>* barrier,
RadixContext* context, BaseHashTable* ht);
private:
Kmer packkmer(const char* s, int k);
uint64_t radix_partition(RadixContext* context,
BufferedPartition** local_partitions,
input_reader::FastqReader& reader, int id, int k);

void count_kmer_baseline(Shard* sh, const Configuration& config,
std::barrier<VoidFn>* barrier,
BaseHashTable* ht);
public:
void count_kmer(Shard* sh, const Configuration& config, BaseHashTable* ht,
std::barrier<VoidFn>* barrier);

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

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

} // namespace kmercounter



#endif // TESTS_KMERTEST_HPP
5 changes: 5 additions & 0 deletions include/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ typedef enum {
HASHJOIN = 13,
FASTQ_WITH_INSERT_RADIX = 14,
BASELINE = 15,
FASTQ_INSERT_PARTITION = 16,
} run_mode_t;

// XXX: If you add/modify a mode, update the `ht_type_strings` in
Expand Down Expand Up @@ -360,6 +361,10 @@ struct Configuration {
uint32_t data_size;
uint32_t workload_size;

//kmer partition
double max_fill_factor;
uint32_t num_ht;

// hashtable configuration
// different hashtable types
uint32_t ht_type;
Expand Down
41 changes: 36 additions & 5 deletions jerry-benchmark.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,46 @@ function command_baseline()
{
sudo ./build/dramhit \
--mode 15 \
--ht-type 3 \
--ht-type 4 \
--numa-split 1 \
--num-threads 1 \
--ht-size $1 \
--datasize $2 \
--workload $3 > logs/baseline_d${2}_ht${1}.log
}

function command_partition()
{
sudo ./build/dramhit \
--mode 16 \
--ht-type 3 \
--numa-split 1 \
--num-threads 32 \
--in-file $FASTA_FILE \
--ht-size $1 \
--num-ht $2 \
--max-fill-factor $3 > logs/partition_sz${1}_num${2}_fill${3}.log
}

function bench_partition()
{
#ht=300
fill=0.6
for (( i=10; i<=10; i+=1 )); do
num=$((1 << i))
size=$(($HT_SIZE/$num/32))
command_partition $size $num $fill
done
}

function bench_baseline()
{
#ht=300
#d=100
w=100000
for (( i=5; i<=25; i+=1 )); do
w=1000000
for (( i=5; i<=15; i+=1 )); do
d=$((1<<i))
ht=$((1*d))
ht=$((2*d))
command_baseline $ht $d $w
done
}
Expand Down Expand Up @@ -75,14 +98,22 @@ function bench_radix()

function debug()
{
sudo gdb --args ./build/dramhit --mode 15 --ht-type 3 --numa-split 1 --num-threads 1 --ht-size 300 --datasize 100 --workload 10000
sudo gdb --args ./build/dramhit \
--mode 15 \
--ht-type 4 \
--numa-split 1 \
--num-threads 1 \
--ht-size 64 \
--datasize 32 \
--workload 1
}


function bench() {
#bench_radix
#command_regular
bench_baseline
# bench_partition
}

function build() {
Expand Down
Binary file added jerry/baseline
Binary file not shown.
21 changes: 21 additions & 0 deletions jerry/baseline.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include <stdio.h>
#include <stdlib.h>
#include <x86intrin.h>
#include <stdint.h>

uint64_t rdtsc() {
uint32_t low, high;
asm volatile ("mfence\n\trdtsc" : "=a" (low), "=d" (high));
return ((uint64_t)high << 32) | low;
}

int main(int argc, char** argv)
{
int workload = atoi(argv[1]);

unsigned long long a = __rdtsc();
// for(int i=0; i < workload; i++);
unsigned long long b = __rdtsc();

printf("Cycle: %llu Workload: %d \n", b-a, workload);
}
File renamed without changes.
Binary file removed prefetch
Binary file not shown.
File renamed without changes.
82 changes: 0 additions & 82 deletions simple_ht.c

This file was deleted.

102 changes: 0 additions & 102 deletions simple_ht.h

This file was deleted.

Loading

0 comments on commit 9f270e8

Please sign in to comment.