Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions module/common/include/oops/format.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include <cstdint>
#include <iomanip>
#include <sstream>
#include <string>
Expand All @@ -12,18 +13,18 @@ namespace oops {
template <typename F>
class FFloatPoint {
static_assert(::std::is_floating_point_v<F>);
enum Format : uint8_t { FIXED, SCI };
enum Format : std::uint8_t { FIXED, SCI };

public:
explicit FFloatPoint(F f) : f_{f} {}
FFloatPoint &Sci();
FFloatPoint &Fixed();
FFloatPoint &SetPrecision(uint8_t precision);
void Output(::std::ostream &out) const;
FFloatPoint &SetPrecision(std::uint8_t precision);
void Output(std::ostream &out) const;

private:
Format format_{FIXED};
uint8_t precision_{2};
std::uint8_t precision_{2};
F f_;
};

Expand All @@ -32,18 +33,18 @@ using FDouble = FFloatPoint<double>;

class FTable {
public:
enum Align : uint8_t { LEFT, CENTER, RIGHT };
enum Align : std::uint8_t { LEFT, CENTER, RIGHT };

struct Prop {
Align align{LEFT};
size_t left_margin{0};
size_t right_margin{0};
size_t min_width{0};
std::size_t left_margin{0};
std::size_t right_margin{0};
std::size_t min_width{0};
};

FTable &SetDelim(const ::std::string &delim);
FTable &SetProp(const Prop &prop);
FTable &SetProp(size_t j, const Prop &prop);
FTable &SetProp(std::size_t j, const Prop &prop);

template <typename... Args>
FTable &AppendRow(const Args &...args) {
Expand All @@ -63,7 +64,7 @@ class FTable {
void Output(::std::ostream &out) const;

private:
const Prop &GetProp(size_t j) const;
const Prop &GetProp(std::size_t j) const;

::std::string delim_{" "};
::std::vector<::std::vector<::std::string>> table_{{}};
Expand Down
8 changes: 4 additions & 4 deletions module/common/include/oops/once.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@

namespace oops {
namespace detail {
template <size_t N>
template <std::size_t N>
struct Only {
template <typename Lambda>
static bool F(Lambda &&) {
static size_t count{0};
static std::size_t count{0};
if (count < N) {
++count;
return true;
Expand Down Expand Up @@ -58,12 +58,12 @@ struct Only<0> {
}
};

template <size_t N>
template <std::size_t N>
struct Every {
static_assert(N > 0);
template <typename Lambda>
static bool F(Lambda &&) {
static size_t count{0};
static std::size_t count{0};
if (count >= N) {
count = 0;
}
Expand Down
24 changes: 12 additions & 12 deletions module/common/src/format.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ FFloatPoint<F> &FFloatPoint<F>::Fixed() {
}

template <typename F>
FFloatPoint<F> &FFloatPoint<F>::SetPrecision(uint8_t precision) {
FFloatPoint<F> &FFloatPoint<F>::SetPrecision(std::uint8_t precision) {
precision_ = precision;
return *this;
}
Expand Down Expand Up @@ -48,7 +48,7 @@ FTable &FTable::SetProp(const Prop &prop) {
return *this;
}

FTable &FTable::SetProp(size_t j, const Prop &prop) {
FTable &FTable::SetProp(std::size_t j, const Prop &prop) {
if (j > col_prop_vec_.size()) {
col_prop_vec_.resize(j + 1);
}
Expand All @@ -57,25 +57,25 @@ FTable &FTable::SetProp(size_t j, const Prop &prop) {
}

void FTable::Output(std::ostream &out) const {
std::vector<size_t> col_width_vec;
for (size_t i{0}; i < table_.size() - 1; ++i) {
std::vector<std::size_t> col_width_vec;
for (std::size_t i{0}; i < table_.size() - 1; ++i) {
auto &row{table_[i]};
for (size_t j{0}; j < row.size(); ++j) {
for (size_t n{col_width_vec.size()}; n < j + 1; ++n) {
for (std::size_t j{0}; j < row.size(); ++j) {
for (std::size_t n{col_width_vec.size()}; n < j + 1; ++n) {
const Prop &prop{GetProp(n)};
size_t default_width{std::max(prop.left_margin + prop.right_margin, prop.min_width)};
std::size_t default_width{std::max(prop.left_margin + prop.right_margin, prop.min_width)};
col_width_vec.push_back(default_width);
}
const Prop &prop{GetProp(j)};
col_width_vec[j] = std::max(col_width_vec[j], row[j].size() + prop.left_margin + prop.right_margin);
}
}
for (size_t i{0}; i < table_.size() - 1; ++i) {
for (std::size_t i{0}; i < table_.size() - 1; ++i) {
auto &row{table_[i]};
for (size_t j{0}; j < row.size(); ++j) {
for (std::size_t j{0}; j < row.size(); ++j) {
const Prop &prop{GetProp(j)};
size_t space_num{col_width_vec[j] - row[j].size()};
size_t left_space_num{0};
std::size_t space_num{col_width_vec[j] - row[j].size()};
std::size_t left_space_num{0};
switch (prop.align) {
case Align::LEFT: {
left_space_num = prop.left_margin;
Expand All @@ -99,7 +99,7 @@ void FTable::Output(std::ostream &out) const {
}
}

const FTable::Prop &FTable::GetProp(size_t j) const {
const FTable::Prop &FTable::GetProp(std::size_t j) const {
if (j < col_prop_vec_.size()) {
return col_prop_vec_[j];
}
Expand Down
4 changes: 2 additions & 2 deletions module/matrix/include/oops/coo.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ class CooIterator {
using iterator_category = std::bidirectional_iterator_tag;
using difference_type = std::ptrdiff_t;
using value_type = TripletProxy;
using pointer = value_type *;
using reference = value_type &;
using pointer = TripletProxy *;
using reference = TripletProxy &;

CooIterator() = default;
CooIterator(StoreType &store, std::size_t i) : store_{store}, i_{i} {}
Expand Down
6 changes: 3 additions & 3 deletions module/matrix/include/oops/matrix_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

#include "oops/type_list.h"
namespace oops {
enum class MatrixFormat : uint8_t { SPARSE_COO, SPARSE_CSR, SPARSE_CSC, DENSE_ROW_MAJOR, DENSE_COL_MAJOR };
enum class MatrixNumeric : uint8_t { REAL, COMPLEX, INTEGER, PATTERN, OTHER };
enum class MatrixSymmetric : uint8_t {
enum class MatrixFormat : std::uint8_t { SPARSE_COO, SPARSE_CSR, SPARSE_CSC, DENSE_ROW_MAJOR, DENSE_COL_MAJOR };
enum class MatrixNumeric : std::uint8_t { REAL, COMPLEX, INTEGER, PATTERN, OTHER };
enum class MatrixSymmetric : std::uint8_t {
GENERAL,
SYMMETRIC_LOWER,
SYMMETRIC_UPPER,
Expand Down
8 changes: 4 additions & 4 deletions module/matrix/test/test_matrix_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ struct A {
other_moved = 0;
}

inline static size_t self_copied{};
inline static size_t self_moved{};
inline static size_t other_copied{};
inline static size_t other_moved{};
inline static std::size_t self_copied{};
inline static std::size_t self_moved{};
inline static std::size_t other_copied{};
inline static std::size_t other_moved{};
};
} // namespace

Expand Down
40 changes: 20 additions & 20 deletions module/profiling/include/oops/system_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,21 @@ using oops::operator|; // 支持Field和FieldMask或运算ADL

// 当前只解析内存部分
struct Info {
std::optional<size_t> vm_peak;
std::optional<size_t> vm_size;
std::optional<size_t> vm_lck;
std::optional<size_t> vm_pin;
std::optional<size_t> vm_hwm;
std::optional<size_t> vm_rss;
std::optional<size_t> rss_anon;
std::optional<size_t> rss_file;
std::optional<size_t> rss_shmem;
std::optional<size_t> vm_data;
std::optional<size_t> vm_stk;
std::optional<size_t> vm_exe;
std::optional<size_t> vm_lib;
std::optional<size_t> vm_pte;
std::optional<size_t> vm_swap;
std::optional<std::size_t> vm_peak;
std::optional<std::size_t> vm_size;
std::optional<std::size_t> vm_lck;
std::optional<std::size_t> vm_pin;
std::optional<std::size_t> vm_hwm;
std::optional<std::size_t> vm_rss;
std::optional<std::size_t> rss_anon;
std::optional<std::size_t> rss_file;
std::optional<std::size_t> rss_shmem;
std::optional<std::size_t> vm_data;
std::optional<std::size_t> vm_stk;
std::optional<std::size_t> vm_exe;
std::optional<std::size_t> vm_lib;
std::optional<std::size_t> vm_pte;
std::optional<std::size_t> vm_swap;
};

[[nodiscard]] Info Get();
Expand Down Expand Up @@ -102,11 +102,11 @@ using oops::operator|; // 支持Field和FieldMask或运算ADL

struct Info {
std::optional<std::string> architecture;
std::optional<size_t> cpus;
std::optional<size_t> threads_per_core;
std::optional<size_t> cores_per_socket;
std::optional<size_t> sockets;
std::optional<size_t> numa_nodes;
std::optional<std::size_t> cpus;
std::optional<std::size_t> threads_per_core;
std::optional<std::size_t> cores_per_socket;
std::optional<std::size_t> sockets;
std::optional<std::size_t> numa_nodes;
std::optional<std::string> model_name;
std::optional<double> cpu_mhz;
};
Expand Down
28 changes: 14 additions & 14 deletions module/profiling/include/oops/trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@

namespace oops {
// TARCE mask参数配置
constexpr size_t MEM = 1;
constexpr size_t MEM_ONCE = 1ul << 1;
constexpr std::size_t MEM = 1;
constexpr std::size_t MEM_ONCE = 1ul << 1;

// 全局配置
class TraceConfig {
Expand Down Expand Up @@ -154,17 +154,17 @@ struct Memory {
double GetHwmGiB() const { return 1.0 * hwm / 1024 / 1024; }
double GetSwapGiB() const { return 1.0 * swap / 1024 / 1024; }

size_t rss{};
size_t hwm{};
size_t swap{};
std::size_t rss{};
std::size_t hwm{};
std::size_t swap{};
};

struct Sample : public Location, TimeInterval, Memory {};
std::ostream &operator<<(std::ostream &out, const Sample &sample);

struct Record : public Sample {
size_t count{}; // Node中获取
size_t depth{}; // 递归时获取
std::size_t count{}; // Node中获取
std::size_t depth{}; // 递归时获取
};

struct RecordTable {
Expand Down Expand Up @@ -196,7 +196,7 @@ class TraceStore {

private:
const void *location_id_{};
size_t count_{};
std::size_t count_{};

// 统计数据成员
TimeInterval time_inverval_;
Expand All @@ -220,7 +220,7 @@ class TraceStore {
void TraceScopeBegin(const void *location_id);
void TraceScopeEnd();

void Trace(const void *location_id, size_t mask);
void Trace(const void *location_id, std::size_t mask);
void Trace(const void *location_id, const detail::TraceVaArgs &va_args);

RecordTable GetRecordTable(const char *label) const;
Expand All @@ -232,9 +232,9 @@ class TraceStore {
void SetupSameLevelNode(const void *location_id);

TimeInterval GetRootItv() const;
TimeInterval GetRecordTableImpl(int node_i, size_t depth, RecordTable &record_table) const;
Record GetRecord(const Node &node, size_t depth) const;
Record GetRecord(const TimeInterval &itv, size_t depth) const;
TimeInterval GetRecordTableImpl(int node_i, std::size_t depth, RecordTable &record_table) const;
Record GetRecord(const Node &node, std::size_t depth) const;
Record GetRecord(const TimeInterval &itv, std::size_t depth) const;

std::thread::id thread_id_{std::this_thread::get_id()};
std::vector<Node> nodes_{Node{nullptr}};
Expand Down Expand Up @@ -267,7 +267,7 @@ class ParallelTraceStore {
void TraceScopeBegin(const void *location_id) { GetLocalImpl().TraceScopeBegin(location_id); }
void TraceScopeEnd() { GetLocalImpl().TraceScopeEnd(); }

void Trace(const void *location_id, size_t mask) { GetLocalImpl().Trace(location_id, mask); }
void Trace(const void *location_id, std::size_t mask) { GetLocalImpl().Trace(location_id, mask); }
void Trace(const void *location_id, const detail::TraceVaArgs &va_args) {
GetLocalImpl().Trace(location_id, va_args);
}
Expand Down Expand Up @@ -314,7 +314,7 @@ class TraceScope : public TraceScopeBase {

// 做成类成员函数以便在编译器找到部分SCOPE和TRACE不匹配的问题
template <typename Lambda>
void Trace(Lambda &&, const char *label, const char *file, int line, size_t mask) {
void Trace(Lambda &&, const char *label, const char *file, int line, std::size_t mask) {
static unsigned char location{};
thread_local unsigned char count{0};
if (is_active_) {
Expand Down
6 changes: 3 additions & 3 deletions module/profiling/src/system_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
namespace oops {
// 获取命令输出
std::string GetCmdOutput(const std::string &cmd) {
std::unique_ptr<FILE, decltype(&pclose)> p{popen(cmd.c_str(), "r"), &pclose};
std::unique_ptr<FILE, int (*)(FILE *)> p{popen(cmd.c_str(), "r"), &pclose};
std::string output;
if (!p) {
return output;
Expand Down Expand Up @@ -162,7 +162,7 @@ void OutputPairedInfo(

namespace proc {
namespace status {
using MemberPtrVar = std::variant<std::optional<size_t> Info::*>; // 定义所有类型的成员变量指针
using MemberPtrVar = std::variant<std::optional<std::size_t> Info::*>; // 定义所有类型的成员变量指针
constexpr auto PARSE{oops::Parse<Info, MemberPtrVar>};
constexpr auto FORMAT{oops::Format<Info, MemberPtrVar>};

Expand Down Expand Up @@ -204,7 +204,7 @@ namespace numa_maps {

namespace lscpu {
using MemberPtrVar = std::variant<
std::optional<size_t> Info::*, std::optional<std::string> Info::*,
std::optional<std::size_t> Info::*, std::optional<std::string> Info::*,
std::optional<double> Info::*>; // 定义所有类型的成员变量指针
constexpr auto PARSE{oops::Parse<Info, MemberPtrVar>};
constexpr auto FORMAT{oops::Format<Info, MemberPtrVar>};
Expand Down
Loading
Loading