mirror of
https://github.com/rui314/mold.git
synced 2024-11-11 16:58:12 +03:00
temporary
This commit is contained in:
parent
69d93fbe66
commit
5dc2ab3905
36
main.cc
36
main.cc
@ -249,6 +249,41 @@ int main(int argc, char **argv) {
|
|||||||
{
|
{
|
||||||
MyTimer t("bin_sections", before_copy);
|
MyTimer t("bin_sections", before_copy);
|
||||||
|
|
||||||
|
#if 1
|
||||||
|
typedef std::vector<std::vector<InputSection *>> T;
|
||||||
|
|
||||||
|
auto fn = [&](const tbb::blocked_range<int> &range, const T &init) {
|
||||||
|
T vec = init;
|
||||||
|
for (int i = range.begin(); i < range.end(); i++) {
|
||||||
|
ObjectFile *file = files[i];
|
||||||
|
for (InputSection *isec : file->sections) {
|
||||||
|
if (!isec)
|
||||||
|
continue;
|
||||||
|
OutputSection *osec = isec->output_section;
|
||||||
|
vec[osec->idx].push_back(isec);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return vec;
|
||||||
|
};
|
||||||
|
|
||||||
|
auto reduce = [](const T &x, const T &y) {
|
||||||
|
T ret(x.size());
|
||||||
|
for (int i = 0; i < x.size(); i++)
|
||||||
|
ret[i] = x[i];
|
||||||
|
for (int i = 0; i < x.size(); i++)
|
||||||
|
ret[i].insert(ret[i].end(), y[i].begin(), y[i].end());
|
||||||
|
return ret;
|
||||||
|
};
|
||||||
|
|
||||||
|
std::vector<std::vector<InputSection *>> vec =
|
||||||
|
tbb::parallel_reduce(tbb::blocked_range<int>(0, files.size()),
|
||||||
|
T(OutputSection::all_instances.size()),
|
||||||
|
fn, reduce);
|
||||||
|
|
||||||
|
for (int i = 0; i < vec.size(); i++)
|
||||||
|
OutputSection::all_instances[i]->chunks = std::move(vec[i]);
|
||||||
|
|
||||||
|
#else
|
||||||
for (ObjectFile *file : files) {
|
for (ObjectFile *file : files) {
|
||||||
for (InputSection *isec : file->sections) {
|
for (InputSection *isec : file->sections) {
|
||||||
if (!isec)
|
if (!isec)
|
||||||
@ -257,6 +292,7 @@ int main(int argc, char **argv) {
|
|||||||
osec->chunks.push_back(isec);
|
osec->chunks.push_back(isec);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
11
mold.h
11
mold.h
@ -17,6 +17,7 @@
|
|||||||
#include "tbb/concurrent_unordered_set.h"
|
#include "tbb/concurrent_unordered_set.h"
|
||||||
#include "tbb/concurrent_vector.h"
|
#include "tbb/concurrent_vector.h"
|
||||||
#include "tbb/parallel_for_each.h"
|
#include "tbb/parallel_for_each.h"
|
||||||
|
#include "tbb/parallel_reduce.h"
|
||||||
#include "tbb/parallel_sort.h"
|
#include "tbb/parallel_sort.h"
|
||||||
#include "tbb/partitioner.h"
|
#include "tbb/partitioner.h"
|
||||||
#include "tbb/task_group.h"
|
#include "tbb/task_group.h"
|
||||||
@ -113,13 +114,6 @@ static void for_each(T &arr, Callable callback) {
|
|||||||
//
|
//
|
||||||
|
|
||||||
namespace tbb {
|
namespace tbb {
|
||||||
template<>
|
|
||||||
struct tbb_hash<StringRef> {
|
|
||||||
size_t operator()(const StringRef& k) const {
|
|
||||||
return llvm::hash_value(k);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
struct tbb_hash_compare<StringRef> {
|
struct tbb_hash_compare<StringRef> {
|
||||||
static size_t hash(const StringRef& k) {
|
static size_t hash(const StringRef& k) {
|
||||||
@ -293,6 +287,7 @@ public:
|
|||||||
this->name = name;
|
this->name = name;
|
||||||
shdr.sh_flags = flags;
|
shdr.sh_flags = flags;
|
||||||
shdr.sh_type = type;
|
shdr.sh_type = type;
|
||||||
|
idx = all_instances.size();
|
||||||
all_instances.push_back(this);
|
all_instances.push_back(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -311,6 +306,8 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<InputSection *> chunks;
|
std::vector<InputSection *> chunks;
|
||||||
|
uint32_t idx;
|
||||||
|
|
||||||
static std::vector<OutputSection *> all_instances;
|
static std::vector<OutputSection *> all_instances;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user