Now I am confused again. I know new returns a pointer to some object like a simple int or an array or a struct or class, whatever. But does it also create a dynamic array of pointers and at the same time set aside a block of n structs? Does new guarantee all the structs will be contiguous in memory? Okay that seems like a silly question. So thread[1] is thread + sizeof Thread and thread[2] is thread + sizeof Thread * 2 etc. My way would be thread[2] = thread + sizeof pointer * 2. Thread can be extremely large and allocating a complete block of maxThreads might more easily fail. Allocating one Thread at a time might be less likely to fail. If someone wants 128 Threads and they do not have enough memory then one at a time allocation can be stopped at a lesser number of threads and reported to the user. Am I finally getting a handle on things??? Let me say a little prayer before you answer.Mergi wrote: ↑Fri Mar 04, 2022 2:02 amYea, this seems correct. But i'd still suggest getting rid of the extra indirection ... why do you need it? It will only make deallocation and memory management harder later on.Mike Sherwin wrote: ↑Fri Mar 04, 2022 1:59 am I just came up with this before seeing your reply.This looks logically correct to me.Code: Select all
thread = new Thread*[maxThreads]; for (s32 i = 0; i < maxThreads; i++) { thread[i] = new Thread; } t = thread[0];


 Yes by large I mean kind of humongous as besides there being a global TT each thread will have its own TT with about a million entries. Rommie will be able to run in several search modes. A traditional multithreaded engine or in RT RL mode playing maxThreads different games using a more shallow max depth or in a special UI mode where maxThread different games are played in RL mode starting from user supplied positions. Imagine a chess player preparing for a tournament using a 64 core Threadripper searching 128 positions of interest from various openings all playing game after game in RL mode for as long as they want then being able to save any position in a file with all of its learning intact, stopped and restarted where it left off anytime they want. That is what I want to create!
  Yes by large I mean kind of humongous as besides there being a global TT each thread will have its own TT with about a million entries. Rommie will be able to run in several search modes. A traditional multithreaded engine or in RT RL mode playing maxThreads different games using a more shallow max depth or in a special UI mode where maxThread different games are played in RL mode starting from user supplied positions. Imagine a chess player preparing for a tournament using a 64 core Threadripper searching 128 positions of interest from various openings all playing game after game in RL mode for as long as they want then being able to save any position in a file with all of its learning intact, stopped and restarted where it left off anytime they want. That is what I want to create!