Skip to content

Commit

Permalink
Clang format fix
Browse files Browse the repository at this point in the history
  • Loading branch information
suyashmahar committed Jan 17, 2024
1 parent 31d3e76 commit 1718b83
Show file tree
Hide file tree
Showing 11 changed files with 104 additions and 79 deletions.
3 changes: 1 addition & 2 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ Language: Cpp
ColumnLimit: 80

AllowShortFunctionsOnASingleLine: Inline
IndentPPDirectives: BeforeHash

AlignEscapedNewlines: Left
AllowShortIfStatementsOnASingleLine: WithoutElse
Expand All @@ -24,4 +23,4 @@ AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false

# Do not indent preprocessing directives
IndentPPDirectives: None
IndentPPDirectives: None
38 changes: 19 additions & 19 deletions include/nvsl/clock.hh
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ namespace nvsl {
const size_t s = ns_total / (1000000000);
const size_t ms = (ns_total - s * 1000000000) / (1000000);
const size_t us = (ns_total - s * 1000000000 - ms * 1000000) / (1000);
const size_t ns =
(ns_total - s * 1000000000 - ms * 1000000 - us * 1000);
const size_t ns = (ns_total - s * 1000000000 - ms * 1000000 - us * 1000);

ss << s << "s " << ms << "ms " << us << "us " << ns << "ns";

Expand All @@ -46,12 +45,11 @@ namespace nvsl {
size_t events = 0;

/**< Total number of values to store */
static constexpr size_t RAW_VAL_CNT = 1024*1024*100;
static constexpr size_t RAW_VAL_CNT = 1024 * 1024 * 100;

public:
Clock() {
raw_values.reserve(RAW_VAL_CNT);
}

Clock() { raw_values.reserve(RAW_VAL_CNT); }

/** @brief Start the timer */
void tick() {
running = true;
Expand All @@ -73,12 +71,14 @@ namespace nvsl {
}

running = false;
const auto elapsed = duration_cast<nanoseconds>(end_clk - start_clk).count();
const auto elapsed =
duration_cast<nanoseconds>(end_clk - start_clk).count();
this->total_ns += elapsed;

#define OVERFLOW_MSG "Raw values buffer overflow, increase array size or " \
"operations/loop"
#if defined(NVSL_ASSERT) && defined(DBGE)
#define OVERFLOW_MSG \
"Raw values buffer overflow, increase array size or " \
"operations/loop"
#if defined(NVSL_ASSERT) && defined(DBGE)
NVSL_ASSERT(this->raw_values.size() < RAW_VAL_CNT, OVERFLOW_MSG);
#else
if (this->raw_values.size() > RAW_VAL_CNT) {
Expand Down Expand Up @@ -136,10 +136,10 @@ namespace nvsl {
assert(0 && "Clock not reconciled. Call reconcile()");
#endif
}

const auto sz = sorted_raw_values.size();
const auto idx = std::max(0UL, (size_t)((sz*pc)/100.0)-1);
const auto idx = std::max(0UL, (size_t)((sz * pc) / 100.0) - 1);

return sorted_raw_values[idx];
}

Expand All @@ -156,20 +156,20 @@ namespace nvsl {
#else
assert(total_ops != 0 && "Total ops cannot be zero");
#endif
size_t ops_per_iter = total_ops/raw_values.size();

size_t ops_per_iter = total_ops / raw_values.size();
ss << this->summarize()
<< "ops/s: " << (total_ops * (1000000000)) / ((double)this->ns())
<< "\ntime/op: "
<< ns_to_hr_clk((size_t)(this->ns() / (double)total_ops))
<< "\nns/op: " << (this->ns() / (double)total_ops);
if (distribution) {
ss << "\np50/op: "
<< ns_to_hr_clk((size_t)(this->percentile(50))/ops_per_iter)
<< ns_to_hr_clk((size_t)(this->percentile(50)) / ops_per_iter)
<< "\np90/op: "
<< ns_to_hr_clk((size_t)(this->percentile(90))/ops_per_iter)
<< ns_to_hr_clk((size_t)(this->percentile(90)) / ops_per_iter)
<< "\np99/op: "
<< ns_to_hr_clk((size_t)(this->percentile(99))/ops_per_iter)
<< ns_to_hr_clk((size_t)(this->percentile(99)) / ops_per_iter)
<< "\ntime/op: "
<< ns_to_hr_clk((size_t)(this->ns() / (double)total_ops));
}
Expand Down
18 changes: 9 additions & 9 deletions include/nvsl/common.hh
Original file line number Diff line number Diff line change
Expand Up @@ -167,17 +167,17 @@ struct DBGH {
std::ostream &(*f)(std::ios_base &));
};

template <typename T>
inline const DBGH &operator<<(const DBGH &dbgh, const T &obj) {
if (dbgh.enabled) {
DBG << obj;
}

return dbgh;
template <typename T>
inline const DBGH &operator<<(const DBGH &dbgh, const T &obj) {
if (dbgh.enabled) {
DBG << obj;
}

inline const DBGH &operator<<(const DBGH &s,
std::ostream &(*f)(std::ostream &)) {
return dbgh;
}

inline const DBGH &operator<<(const DBGH &s,
std::ostream &(*f)(std::ostream &)) {
#ifndef RELEASE
if (s.enabled) f(DBG);
#endif
Expand Down
5 changes: 2 additions & 3 deletions include/nvsl/pmemops.hh
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,19 @@
* @brief Common abstraction for PMEM operations (clwb, fence, clflush...)
*/

#pragma once
#pragma once

#include <cassert>
#include <cstdint>
#include <stddef.h>


#undef NVSL_PMEMOPS_MASTER_FILE
#define NVSL_PMEMOPS_MASTER_FILE

#include "nvsl/pmemops/declarations.hh"
#include "nvsl/pmemops/pmemops_clflushopt.hh"
#include "nvsl/pmemops/pmemops_clwb.hh"
#include "nvsl/pmemops/pmemops_nopersist.hh"
#include "nvsl/pmemops/pmemops_msync.hh"
#include "nvsl/pmemops/pmemops_nopersist.hh"

#undef NVSL_PMEMOPS_MASTER_FILE
2 changes: 1 addition & 1 deletion include/nvsl/pmemops/declarations.hh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* @file definitions.hh
* @date mars 29, 2022
* @brief All declarations for the pmemops class
* @brief All declarations for the pmemops class
*/

#pragma once
Expand Down
18 changes: 9 additions & 9 deletions include/nvsl/pmemops/pmemops_clflushopt.hh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
#include <sys/mman.h>
#include <xmmintrin.h>

#include "nvsl/pmemops/declarations.hh"
#include "nvsl/error.hh"
#include "nvsl/pmemops/declarations.hh"

inline void nvsl::PMemOpsClflushOpt::persist(void *base, size_t size) const {
DBGH(4) << "Persisting " << (base) << "of size " << (void *)(size)
Expand All @@ -38,7 +38,7 @@ inline void nvsl::PMemOpsClflushOpt::flush(void *base, size_t size) const {
this->clflush_opt((void *)uptr);
#else
NVSL_ERROR("This version of libpuddles was built on a platform "
"that doesn't support clflushopt");
"that doesn't support clflushopt");
#endif
}
}
Expand All @@ -48,28 +48,28 @@ inline void nvsl::PMemOpsClflushOpt::drain() const {
_mm_sfence();
#else
NVSL_ERROR("This version of libpuddles was built on a platform "
"that doesn't support sfence");
"that doesn't support sfence");
#endif
}

inline void nvsl::PMemOpsClflushOpt::memcpy(void *dest, void *src, size_t size)
const {
inline void nvsl::PMemOpsClflushOpt::memcpy(void *dest, void *src,
size_t size) const {
DBGH(4) << "MEMCPY :: pmemdest " << (void *)(dest) << " src " << (void *)(src)
<< " len " << size << std::endl;

this->memmove(dest, src, size);
}

inline void nvsl::PMemOpsClflushOpt::memmove(void *dest, void *src, size_t size)
const {
inline void nvsl::PMemOpsClflushOpt::memmove(void *dest, void *src,
size_t size) const {
std::memmove(dest, src, size);

this->flush(dest, size);
this->drain();
}

inline void nvsl::PMemOpsClflushOpt::memset(void *base, char c, size_t size)
const {
inline void nvsl::PMemOpsClflushOpt::memset(void *base, char c,
size_t size) const {
DBGH(4) << "MEMSET :: start " << (void *)(base) << " size " << (void *)(size)
<< " char " << c << std::endl;

Expand Down
10 changes: 6 additions & 4 deletions include/nvsl/pmemops/pmemops_clwb.hh
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ inline void nvsl::PMemOpsClwb::flush(void *base, size_t size) const {
this->clwb((void *)uptr);
#else
NVSL_ERROR("This version of libpuddles was built on a platform "
"that doesn't support clwb");
"that doesn't support clwb");
#endif
}
}
Expand All @@ -175,18 +175,20 @@ inline void nvsl::PMemOpsClwb::drain() const {
_mm_sfence();
#else
NVSL_ERROR("This version of libpuddles was built on a platform "
"that doesn't support sfence");
"that doesn't support sfence");
#endif
}

inline void nvsl::PMemOpsClwb::memcpy(void *dest, void *src, size_t size) const {
inline void nvsl::PMemOpsClwb::memcpy(void *dest, void *src,
size_t size) const {
DBGH(4) << "MEMCPY :: pmemdest " << (void *)(dest) << " src " << (void *)(src)
<< " len " << size << std::endl;

this->memmove(dest, src, size);
}

inline void nvsl::PMemOpsClwb::memmove(void *dest, void *src, size_t size) const {
inline void nvsl::PMemOpsClwb::memmove(void *dest, void *src,
size_t size) const {
std::memmove(dest, src, size);

flush(dest, size);
Expand Down
6 changes: 4 additions & 2 deletions include/nvsl/pmemops/pmemops_msync.hh
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,16 @@ inline void nvsl::PMemOpsMsync::drain() const {
/* Do nothing */
}

inline void nvsl::PMemOpsMsync::memcpy(void *dest, void *src, size_t size) const {
inline void nvsl::PMemOpsMsync::memcpy(void *dest, void *src,
size_t size) const {
DBGH(4) << "MEMCPY :: pmemdest " << (void *)(dest) << " src " << (void *)(src)
<< " len " << size << std::endl;

this->memmove(dest, src, size);
}

inline void nvsl::PMemOpsMsync::memmove(void *dest, void *src, size_t size) const {
inline void nvsl::PMemOpsMsync::memmove(void *dest, void *src,
size_t size) const {
std::memmove(dest, src, size);

this->flush(dest, size);
Expand Down
12 changes: 6 additions & 6 deletions include/nvsl/pmemops/pmemops_nopersist.hh
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,21 @@ inline void nvsl::PMemOpsNoPersist::flush(void *base, size_t size) const {

inline void nvsl::PMemOpsNoPersist::drain() const {}

inline void nvsl::PMemOpsNoPersist::memcpy(void *dest, void *src, size_t size)
const {
inline void nvsl::PMemOpsNoPersist::memcpy(void *dest, void *src,
size_t size) const {
DBGH(4) << "MEMCPY :: pmemdest " << (void *)(dest) << " src " << (void *)(src)
<< " len " << size << std::endl;

this->memmove(dest, src, size);
}

inline void nvsl::PMemOpsNoPersist::memmove(void *dest, void *src, size_t size)
const {
inline void nvsl::PMemOpsNoPersist::memmove(void *dest, void *src,
size_t size) const {
std::memmove(dest, src, size);
}

inline void nvsl::PMemOpsNoPersist::memset(void *base, char c, size_t size)
const {
inline void nvsl::PMemOpsNoPersist::memset(void *base, char c,
size_t size) const {
DBGH(4) << "MEMSET :: start " << (void *)(base) << " size " << (void *)(size)
<< " char " << c << std::endl;

Expand Down
Loading

0 comments on commit 1718b83

Please sign in to comment.