test: update threading benchmark
This commit is contained in:
@@ -97,7 +97,7 @@ add_executable(${BenchExec}
|
|||||||
src/Engine/Operator/GeometryConnection.cpp
|
src/Engine/Operator/GeometryConnection.cpp
|
||||||
src/Engine/Operator/GeometryOpDef.cpp
|
src/Engine/Operator/GeometryOpDef.cpp
|
||||||
)
|
)
|
||||||
target_link_libraries(${BenchExec} PRIVATE Catch2::Catch2WithMain Eigen3::Eigen Qt6::Core )
|
target_link_libraries(${BenchExec} PRIVATE Catch2::Catch2WithMain Eigen3::Eigen Qt6::Core TBB::tbb)
|
||||||
target_compile_definitions(${BenchExec} PRIVATE UNIT_TEST)
|
target_compile_definitions(${BenchExec} PRIVATE UNIT_TEST)
|
||||||
target_include_directories(${BenchExec} PUBLIC src)
|
target_include_directories(${BenchExec} PUBLIC src)
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
|
#include <oneapi/tbb/parallel_for.h>
|
||||||
#include "Engine/Operator/GeometryOpDef.h"
|
#include "Engine/Operator/GeometryOpDef.h"
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "Engine/Network/NetworkManager.h"
|
|
||||||
#include "Engine/Operator/GeometryOperator.h"
|
#include "Engine/Operator/GeometryOperator.h"
|
||||||
#include "Engine/Types.h"
|
#include "Engine/Types.h"
|
||||||
#include "Engine/Operator/AttributeHandle.h"
|
#include "Engine/Operator/AttributeHandle.h"
|
||||||
|
#include "Engine/Network/NetworkManager.h"
|
||||||
|
|
||||||
bool enzo::nt::GeometryOpDef::outputRequested(unsigned int outputIndex)
|
bool enzo::nt::GeometryOpDef::outputRequested(unsigned int outputIndex)
|
||||||
{
|
{
|
||||||
@@ -64,7 +65,7 @@ enzo::geo::Geometry& enzo::nt::GeometryOpDef::getOutputGeo(unsigned outputIndex)
|
|||||||
void enzo::nt::GeometryOpDef::cookOp()
|
void enzo::nt::GeometryOpDef::cookOp()
|
||||||
{
|
{
|
||||||
using namespace enzo;
|
using namespace enzo;
|
||||||
std::cout << "COOKING\n";
|
// std::cout << "COOKING\n";
|
||||||
|
|
||||||
if(outputRequested(0))
|
if(outputRequested(0))
|
||||||
{
|
{
|
||||||
@@ -104,6 +105,18 @@ void enzo::nt::GeometryOpDef::cookOp()
|
|||||||
vector.x()+=2.5;
|
vector.x()+=2.5;
|
||||||
PAttrHandle.setValue(i, vector);
|
PAttrHandle.setValue(i, vector);
|
||||||
}
|
}
|
||||||
|
// ----
|
||||||
|
|
||||||
|
constexpr int N = 10000;
|
||||||
|
std::vector<double> results(N);
|
||||||
|
|
||||||
|
oneapi::tbb::parallel_for(0, N, [&](int i) {
|
||||||
|
double val = 0;
|
||||||
|
for (int j = 0; j < 100; ++j) {
|
||||||
|
val += std::sin(i + j);
|
||||||
|
}
|
||||||
|
results[i] = val;
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
// set output geometry
|
// set output geometry
|
||||||
|
|||||||
@@ -58,7 +58,6 @@ void nt::GeometryOperator::addOutputConnection(std::shared_ptr<nt::GeometryConne
|
|||||||
std::vector<std::shared_ptr<const nt::GeometryConnection>> nt::GeometryOperator::getInputConnections() const
|
std::vector<std::shared_ptr<const nt::GeometryConnection>> nt::GeometryOperator::getInputConnections() const
|
||||||
{
|
{
|
||||||
std::vector<std::shared_ptr<const nt::GeometryConnection>> inputConnections;
|
std::vector<std::shared_ptr<const nt::GeometryConnection>> inputConnections;
|
||||||
std::cout << "input connections size: " << inputConnections_.size() <<"\n";
|
|
||||||
for(std::shared_ptr<nt::GeometryConnection> connection : inputConnections_)
|
for(std::shared_ptr<nt::GeometryConnection> connection : inputConnections_)
|
||||||
{
|
{
|
||||||
inputConnections.push_back(connection);
|
inputConnections.push_back(connection);
|
||||||
|
|||||||
@@ -22,21 +22,37 @@ struct NMReset
|
|||||||
TEST_CASE_METHOD(NMReset, "Network Manager")
|
TEST_CASE_METHOD(NMReset, "Network Manager")
|
||||||
{
|
{
|
||||||
using namespace enzo;
|
using namespace enzo;
|
||||||
nt::OpId prevOp = 0;
|
nt::OpId startOp = nt::NetworkManager::addOperator();
|
||||||
for(int i=0; i<100; ++i){
|
nt::OpId prevOp = startOp;
|
||||||
nt::OpId newOp = nt::NetworkManager::addOperator();
|
std::vector<nt::OpId> prevOps;
|
||||||
if(prevOp!=0)
|
|
||||||
{
|
|
||||||
nt::connectOperators(newOp, 0, prevOp, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
prevOp = newOp;
|
for(int k=0; k<10; k++)
|
||||||
|
{
|
||||||
|
for(int i=0; i<4; ++i)
|
||||||
|
{
|
||||||
|
nt::OpId newOp = nt::NetworkManager::addOperator();
|
||||||
|
prevOps.push_back(newOp);
|
||||||
|
nt::connectOperators(newOp, i, prevOp, 0);
|
||||||
|
}
|
||||||
|
for(int j=0; j<10; j++)
|
||||||
|
{
|
||||||
|
std::vector<nt::OpId> prevOpsBuffer = prevOps;
|
||||||
|
for(int i=0; i<size(prevOpsBuffer); ++i)
|
||||||
|
{
|
||||||
|
prevOps.clear();
|
||||||
|
nt::OpId newOp = nt::NetworkManager::addOperator();
|
||||||
|
prevOps.push_back(newOp);
|
||||||
|
nt::connectOperators(newOp, 0, prevOpsBuffer[i], 0);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nt::NetworkManager* nm = nt::NetworkManager::getInstance();
|
nt::NetworkManager* nm = nt::NetworkManager::getInstance();
|
||||||
BENCHMARK("Cook 100 Ops")
|
BENCHMARK("Cook 100 Ops")
|
||||||
{
|
{
|
||||||
nm->setDisplayOp(prevOp);
|
nm->setDisplayOp(startOp);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user