initial commit, 4.5 stable
Some checks failed
🔗 GHA / 📊 Static checks (push) Has been cancelled
🔗 GHA / 🤖 Android (push) Has been cancelled
🔗 GHA / 🍏 iOS (push) Has been cancelled
🔗 GHA / 🐧 Linux (push) Has been cancelled
🔗 GHA / 🍎 macOS (push) Has been cancelled
🔗 GHA / 🏁 Windows (push) Has been cancelled
🔗 GHA / 🌐 Web (push) Has been cancelled
Some checks failed
🔗 GHA / 📊 Static checks (push) Has been cancelled
🔗 GHA / 🤖 Android (push) Has been cancelled
🔗 GHA / 🍏 iOS (push) Has been cancelled
🔗 GHA / 🐧 Linux (push) Has been cancelled
🔗 GHA / 🍎 macOS (push) Has been cancelled
🔗 GHA / 🏁 Windows (push) Has been cancelled
🔗 GHA / 🌐 Web (push) Has been cancelled
This commit is contained in:
52
thirdparty/embree/common/algorithms/parallel_set.h
vendored
Normal file
52
thirdparty/embree/common/algorithms/parallel_set.h
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
// Copyright 2009-2021 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "parallel_sort.h"
|
||||
|
||||
namespace embree
|
||||
{
|
||||
/* implementation of a set of values with parallel construction */
|
||||
template<typename T>
|
||||
class parallel_set
|
||||
{
|
||||
public:
|
||||
|
||||
/*! default constructor for the parallel set */
|
||||
parallel_set () {}
|
||||
|
||||
/*! construction from vector */
|
||||
template<typename Vector>
|
||||
parallel_set (const Vector& in) { init(in); }
|
||||
|
||||
/*! initialized the parallel set from a vector */
|
||||
template<typename Vector>
|
||||
void init(const Vector& in)
|
||||
{
|
||||
/* copy data to internal vector */
|
||||
vec.resize(in.size());
|
||||
parallel_for( size_t(0), in.size(), size_t(4*4096), [&](const range<size_t>& r) {
|
||||
for (size_t i=r.begin(); i<r.end(); i++)
|
||||
vec[i] = in[i];
|
||||
});
|
||||
|
||||
/* sort the data */
|
||||
std::vector<T> temp(in.size());
|
||||
radix_sort<T>(vec.data(),temp.data(),vec.size());
|
||||
}
|
||||
|
||||
/*! tests if some element is in the set */
|
||||
__forceinline bool lookup(const T& elt) const {
|
||||
return std::binary_search(vec.begin(), vec.end(), elt);
|
||||
}
|
||||
|
||||
/*! clears all state */
|
||||
void clear() {
|
||||
vec.clear();
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<T> vec; //!< vector containing sorted elements
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user