wip: removed tbb use

This commit is contained in:
Farid Zakaria 2023-06-27 18:12:06 +00:00
parent 474350c602
commit a5ab4fa2cb
7 changed files with 37 additions and 19 deletions

View file

@ -16,3 +16,9 @@ SOURCE
Date: Mon Jun 19 12:35:20 2023 +0900
Format
CHANGES
* removed tbb by including a fake implementation
* made the parallel_for effectively single-threaded
* changed tbb:enumerable_thread_specific to thread_local
* removed rust demangle support

View file

@ -10,6 +10,7 @@
#include "third_party/libcxx/cassert"
#include "third_party/libcxx/cstdio"
#include "third_party/libcxx/cstring"
#include "third_party/libcxx/unordered_map"
#include "libc/calls/calls.h"
#include "libc/calls/struct/flock.h"
#include "libc/calls/weirdtypes.h"
@ -44,8 +45,6 @@
#include "libc/intrin/newbie.h"
#include "libc/sock/select.h"
#include "libc/sysv/consts/endian.h"
// MISSING #include <tbb/concurrent_vector.h>
// MISSING #include <tbb/enumerable_thread_specific.h>
#include "third_party/libcxx/vector"
#ifdef _WIN32
@ -758,21 +757,22 @@ private:
// Counter is used to collect statistics numbers.
class Counter {
public:
Counter(std::string_view name, i64 value = 0) : name(name), values(value) {
Counter(std::string_view name, i64 value = 0) : name(name) {
static std::mutex mu;
std::scoped_lock lock(mu);
instances.push_back(this);
values[this] = value;
}
Counter &operator++(int) {
if (enabled) [[unlikely]]
values.local()++;
values[this]++;
return *this;
}
Counter &operator+=(int delta) {
if (enabled) [[unlikely]]
values.local() += delta;
values[this] += delta;
return *this;
}
@ -784,7 +784,7 @@ private:
i64 get_value();
std::string_view name;
tbb::enumerable_thread_specific<i64> values;
static thread_local std::unordered_map<Counter*, i64> values;
static inline std::vector<Counter *> instances;
};
@ -797,7 +797,7 @@ struct TimerRecord {
std::string name;
TimerRecord *parent;
tbb::concurrent_vector<TimerRecord *> children;
std::vector<TimerRecord *> children;
i64 start;
i64 end;
i64 user;
@ -806,7 +806,7 @@ struct TimerRecord {
};
void
print_timer_records(tbb::concurrent_vector<std::unique_ptr<TimerRecord>> &);
print_timer_records(std::vector<std::unique_ptr<TimerRecord>> &);
template <typename Context>
class Timer {

View file

@ -17,9 +17,9 @@
#include "third_party/mold/common.h"
// MISSING #include <tbb/parallel_for_each.h>
// MISSING #include <zlib.h>
// MISSING #include <zstd.h>
#include "third_party/mold/fake_tbb.h"
#include "third_party/zlib/zlib.h"
#include "third_party/zstd/zstd.h"
#define CHECK(fn) \
do { \

View file

@ -19,9 +19,9 @@ std::string_view demangle(std::string_view name) {
// Try to demangle as a Rust symbol. Since legacy-style Rust symbols
// are also valid as a C++ mangled name, we need to call this before
// cpp_demangle.
p = rust_demangle(std::string(name).c_str(), 0);
if (p)
return p;
// p = rust_demangle(std::string(name).c_str(), 0);
// if (p)
// return p;
// Try to demangle as a C++ symbol.
if (std::optional<std::string_view> s = cpp_demangle(name))

View file

@ -2,8 +2,8 @@
#include "third_party/mold/elf/mold.h"
#include "third_party/libcxx/limits"
// MISSING #include <zlib.h>
// MISSING #include <zstd.h>
#include "third_party/zlib/zlib.h"
#include "third_party/zstd/zstd.h"
namespace mold::elf {

View file

@ -11,5 +11,13 @@ namespace tbb {
void parallel_for_each(Range& rng, const Body& body) {
}
template<typename Range, typename Body>
void parallel_for( const Range& range, const Body& body ) {
}
template <typename Index, typename Function>
void parallel_for(Index first, Index last, const Function& f) {
}
}
#endif

View file

@ -3,8 +3,6 @@
PKGS += THIRD_PARTY_MOLD
private CPPFLAGS += -std=c++20
THIRD_PARTY_MOLD_ARTIFACTS += THIRD_PARTY_MOLD_A
THIRD_PARTY_MOLD = $(THIRD_PARTY_MOLD_A_DEPS) $(THIRD_PARTY_MOLD_A)
THIRD_PARTY_MOLD_A = o/$(MODE)/third_party/mold/mold.a
@ -15,7 +13,9 @@ THIRD_PARTY_MOLD_OBJS = $(THIRD_PARTY_MOLD_SRCS:%.cc=o/$(MODE)/%.o)
THIRD_PARTY_MOLD_A_DIRECTDEPS = \
THIRD_PARTY_LIBCXX \
THIRD_PARTY_XXHASH
THIRD_PARTY_ZSTD \
THIRD_PARTY_XXHASH \
THIRD_PARTY_ZLIB
THIRD_PARTY_MOLD_A_DEPS := \
$(call uniq,$(foreach x,$(THIRD_PARTY_MOLD_A_DIRECTDEPS),$($(x))))
@ -43,6 +43,10 @@ $(THIRD_PARTY_MOLD_A).pkg: \
$(THIRD_PARTY_MOLD_OBJS) \
$(foreach x,$(THIRD_PARTY_MOLD_A_DIRECTDEPS),$($(x)_A).pkg)
$(THIRD_PARTY_MOLD_A_OBJS): private \
CPPFLAGS += \
-std=c++20
o/$(MODE)/third_party/mold/mold.com.dbg: \
$(THIRD_PARTY_MOLD) \
o/$(MODE)/third_party/awk/main.o \