Add maxuse_threadstack to mjData

PiperOrigin-RevId: 567334177
Change-Id: Ifd772350042e548a63ab269fd68fb5e5fef55831
This commit is contained in:
Matthew Bennice
2023-09-21 09:40:14 -07:00
committed by Copybara-Service
parent be75dda8d1
commit 4f34cacf35
13 changed files with 223 additions and 65 deletions
+1
View File
@@ -1420,6 +1420,7 @@ static void _resetData(const mjModel* m, mjData* d, unsigned char debug_value) {
// clear memory utilization stats
d->maxuse_stack = 0;
mju_zeroSizeT(d->maxuse_threadstack, mjMAXTHREADS);
d->maxuse_arena = 0;
d->maxuse_con = 0;
d->maxuse_efc = 0;
+4
View File
@@ -1213,6 +1213,10 @@ void mju_zeroInt(int* res, int n) {
}
void mju_zeroSizeT(size_t* res, size_t n) {
memset(res, 0, n*sizeof(size_t));
}
// copy int vector vec into res
void mju_copyInt(int* res, const int* vec, int n) {
+3
View File
@@ -122,6 +122,9 @@ MJAPI int mju_isZero(mjtNum* vec, int n);
// set integer vector to 0
MJAPI void mju_zeroInt(int* res, int n);
// set size_t vector to 0
MJAPI void mju_zeroSizeT(size_t* res, size_t n);
// copy int vector vec into res
MJAPI void mju_copyInt(int* res, const int* vec, int n);
+2 -1
View File
@@ -14,6 +14,7 @@
#include "thread/thread_pool.h"
#include <algorithm>
#include <atomic>
#include <cstddef>
#include <memory>
@@ -55,7 +56,7 @@ class ThreadPoolImpl : public mjThreadPool {
public:
ThreadPoolImpl(int num_worker) : mjThreadPool{num_worker} {
// initialize worker threads
for (int i = 0; i < num_worker; ++i) {
for (int i = 0; i < std::min(num_worker, mjMAXTHREADS); ++i) {
WorkerThread worker{
std::make_unique<std::thread>(ThreadPoolWorker, this)};
workers_.push_back(std::move(worker));