Skip to content

Commit

Permalink
Merge branch 'main' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
ishmeals authored Apr 15, 2024
2 parents 3f29c66 + b457842 commit 258b54d
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 19 deletions.
4 changes: 4 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
BasedOnStyle: LLVM
UseTab: Always
IndentWidth: 4
TabWidth: 4
10 changes: 10 additions & 0 deletions .github/workflows/clang-format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: clang-format Check
on: [push, pull_request]
jobs:
formatting-check:
name: Formatting Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run clang-format style check for C/C++/Protobuf programs.
uses: jidicula/[email protected]
21 changes: 11 additions & 10 deletions include/digest/data_structure.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <stdint.h>
#include <utility>
#include <vector>
#include <array>

// requirement on all data_structures
// constructor which accepts uint32_t
Expand Down Expand Up @@ -70,7 +71,7 @@ template <int k> struct SegmentTree {

template <uint32_t k> struct Naive {
std::array<uint64_t, k> arr;
uint i = 0;
unsigned int i = 0;

Naive(uint32_t){};
Naive(const Naive &other) = default;
Expand Down Expand Up @@ -103,8 +104,8 @@ template <uint32_t k> struct Naive {
}

void min_syncmer(std::vector<uint32_t> &vec) {
uint j = 0;
for (uint l = 1; l < k; l++) {
unsigned int j = 0;
for (unsigned int l = 1; l < k; l++) {
if (arr[l] > arr[j]) {
j = l;
}
Expand All @@ -116,7 +117,7 @@ template <uint32_t k> struct Naive {
}

void min_syncmer(std::vector<std::pair<uint32_t, uint32_t>> &vec) {
uint j = k - 1;
unsigned int j = k - 1;
for (int l = k - 2; l >= 0; l--) {
if (arr[l] > arr[j]) {
j = l;
Expand All @@ -130,8 +131,8 @@ template <uint32_t k> struct Naive {
};

template <uint32_t k> struct Naive2 {
uint i = 0;
uint last = 0;
unsigned int i = 0;
unsigned int last = 0;
std::vector<uint64_t> arr = std::vector<uint64_t>(k);

Naive2(uint32_t){};
Expand Down Expand Up @@ -245,7 +246,7 @@ struct Adaptive {

void min_syncmer(std::vector<uint32_t> &vec) {
if (k < 16) {
uint j = k - 1;
unsigned int j = k - 1;
for (int l = k - 2; l >= 0; l--) {
if (arr[l] > arr[j]) {
j = l;
Expand All @@ -265,7 +266,7 @@ struct Adaptive {

void min_syncmer(std::vector<std::pair<uint32_t, uint32_t>> &vec) {
if (k < 16) {
uint j = k - 1;
unsigned int j = k - 1;
for (int l = k - 2; l >= 0; l--) {
if (arr[l] > arr[j]) {
j = l;
Expand Down Expand Up @@ -354,7 +355,7 @@ struct Adaptive64 {

void min_syncmer(std::vector<uint32_t> &vec) {
if (k < 16) {
uint j = k - 1;
unsigned int j = k - 1;
for (int l = k - 2; l >= 0; l--) {
if (arr[l] > arr[j]) {
j = l;
Expand All @@ -374,7 +375,7 @@ struct Adaptive64 {

void min_syncmer(std::vector<std::pair<uint32_t, uint64_t>> &vec) {
if (k < 16) {
uint j = k - 1;
unsigned int j = k - 1;
for (int l = k - 2; l >= 0; l--) {
if (arr[l] > arr[j]) {
j = l;
Expand Down
6 changes: 4 additions & 2 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,15 @@ if get_option('buildtype') != 'release'
'tests/test/test.cpp',
dependencies : [catch2, digest_dep],
)

thread_dep = dependency('threads')

### benchmark ###
bench = dependency('benchmark')
executable(
'bench',
'tests/bench/benchmark.cpp',
dependencies : [bench, digest_dep],
dependencies : [bench, digest_dep, thread_dep],
)

### benchmark data structures ###
Expand Down Expand Up @@ -72,7 +74,7 @@ if get_option('buildtype') != 'release'
executable(
'test_thread',
'tests/test/test_thread.cpp',
dependencies : [catch2, digest_dep],
dependencies : [catch2, digest_dep, thread_dep],
)

doxygen = find_program('doxygen', required: false)
Expand Down
14 changes: 7 additions & 7 deletions tests/data_structure/bench_ds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,13 @@ template <int k, class T, int out> static void BM(benchmark::State &state) {
BENCHMARK_TEMPLATE(BM, 512, name, out); \
BENCHMARK_TEMPLATE(BM, 1024, name, out);

test(digest::ds::Naive, 0);
test(digest::ds::Naive2, 1);
test(digest::ds::MonoQueue, 2);
test(digest::ds::SegmentTree, 3);
test(digest::ds::Set, 4);
test2(digest::ds::Adaptive, 5);
test2(digest::ds::Adaptive64, 6);
test(digest::ds::Naive, 0)
test(digest::ds::Naive2, 1)
test(digest::ds::MonoQueue, 2)
test(digest::ds::SegmentTree, 3)
test(digest::ds::Set, 4)
test2(digest::ds::Adaptive, 5)
test2(digest::ds::Adaptive64, 6)

int main(int argc, char **argv) {
setupInput();
Expand Down

0 comments on commit 258b54d

Please sign in to comment.