Author: Robert Hyatt
Date: 17:18:17 11/18/04
Go up one level in this thread
On November 18, 2004 at 01:07:57, Daniel Shawul wrote:
>On November 17, 2004 at 13:39:20, Robert Hyatt wrote:
>
>>On November 17, 2004 at 07:50:29, Daniel Shawul wrote:
>>
>>>I have some programming difficulties on multi threaded search.
>>>
>>>One problem is that allocating memory in search is a problem
>>>
>>>search(alpha,beta,...)
>>>{
>>> SPLIT* p_split;
>>> p_split = new SPLIT;
>>>
>>> if(search in parallel)
>>> searchInparallel(...)
>>> else
>>> search()
>>>
>>> delete p_split; //here it crashes
>>>}
>>>
>>>The error message says "you can only delete memory from *local* heap".
>>>Do threads have their own heap memory?
>>
>>Nope. Each thread does have it's own stack memory, although any thread can
>>see any other thread's stack if it tries hard enough since all memory is
>>shared among threads...
>>
>>
>>>When i change in to using a split object than using a pointer it works fine.
>>>but i am thinking this is slower than allocating memory when only i need to
>>>split search. what do you suggest?
>>
>>Forget allocating memory. It is slow because it requires synchronization
>>between the threads since they share the same virtual address space. The
>>threads have to synchronize if two or more try to allocate something at the same
>>time. No dynamic allocation inside the engine.... too slow...
>>
>>
>>>
>>>Another question is do i need to lock/unlock common data for threads
>>>which is a read only type?
>>
>>Nope. Only if it is modified.
>
>>
>>
>>>
>>>Do you block the main(parent) thread when search is split? i have read ('m not
>>>sure though) this may cause a problem but it seems to work fine for me.
>>
>>I don't. that way I just have four threads at all times, never blocked threads
>>waiting on busy threads. That is a performance reducer... It is easier to use
>>your idea, but a little less efficient.
>
> I am not sure if i understnt this part. Blocking the main thread means one
>less worker,so it can't be more efficient. but it may help for communication,for
>example when a fail high is reported by a thread.
>
>daniel
I don't block _any_ thread. The other approach is to choose a split point, and
then create threads to search that split point. The parent thread waits for all
of the child threads to complete before using the returned results and backing
up in the tree.
I use the concept of "thread pool", I start 3 threads up front, put them into an
"idle pool" where they spin waiting on a task. Once they complete their task
they go right back into the pool to wait for more work...
You really need to do as Anthony has said. Design _first_. Code third
Between design and coding, do a _lot_ of thinking. Otherwise this will be a
debugging project like nothing you have ever seen...
>
>>
>>
>>
>>>
>>>thanks in advance
>>>daniel
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.