Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/vecenv.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,23 +193,26 @@ void my_init(Env* env, Dict* kwargs);
void my_log(Log* log, Dict* out);


typedef struct StaticOMPArg StaticOMPArg;

struct StaticThreading {
atomic_int* buffer_states;
atomic_int shutdown;
int num_threads;
int num_buffers;
pthread_t* threads;
float* accum; // [num_buffers * NUM_EVAL_PROF] per-buffer timing in ms
StaticOMPArg* thread_args;
};

typedef struct StaticOMPArg {
struct StaticOMPArg {
StaticVec* vec;
int buf;
int horizon;
void* ctx;
net_callback_fn net_callback;
thread_init_fn thread_init;
} StaticOMPArg;
};

// OMP thread manager
static void* static_omp_threadmanager(void* arg) {
Expand Down Expand Up @@ -468,7 +471,8 @@ void create_static_threads(StaticVec* vec, int num_threads, int horizon,
// Streams are now created by pufferlib.cu (PyTorch-managed streams)
// Do NOT create streams here - they've already been set up

StaticOMPArg* args = (StaticOMPArg*)calloc(vec->buffers, sizeof(StaticOMPArg));
vec->threading->thread_args = (StaticOMPArg*)calloc(vec->buffers, sizeof(StaticOMPArg));
StaticOMPArg* args = vec->threading->thread_args;
for (int i = 0; i < vec->buffers; i++) {
args[i].vec = vec;
args[i].buf = i;
Expand Down Expand Up @@ -501,6 +505,7 @@ void static_vec_close(StaticVec* vec) {
free(vec->threading->buffer_states);
free(vec->threading->threads);
free(vec->threading->accum);
free(vec->threading->thread_args);
free(vec->threading);
}
free(vec->buffer_env_starts);
Expand Down