Re: multithreading
Roland Hughes via Foxgui-users <[email protected]>
| Newsgroups | gmane.comp.lib.fox-toolkit.user |
|---|---|
| Message-ID | <[email protected]> |
Logical processor != physical processor.
Once you exceed (physical - 1) you will start running slower. Your OS
and the C/C++ runtime need one for scheduling and other tasks
On 11/20/22 09:59, John Selverian wrote:
> Here is the main part of the code, I left out allocate and deallocation...
>
> It is slower then numTreads=12 than for numTreads = 1
>
> I have 12 logically processors, the more I use the slower it goes.
>
>
>
>
> numThreadsRunning = 0;
>
>
> for (FXint i = 0; i < numTreads; i++)
> {
> FXArray<Material> materialsArray;
>
> for (int list_box_index = firstListBoxIndex[i]; list_box_index < lastListBoxIndex[i] + 1; list_box_index++)
> {
> int j_start = _listBoxDefinition[list_box_index].iStart;
> int j_end = _listBoxDefinition[list_box_index].iEnd;
>
> for (int j = j_start; j < j_end + 1; j++)
> {
> materialsArray.append(_materialsArray.at(j));
> }
> }
>
> // pass data to thread
> checkValuesThreadInitalizedOK[i] = checkValuesThread[i].passData(materialsArray, _lastArrayIndexInMatArrayBeforeUserMats, dt);
>
> if (checkValuesThreadInitalizedOK[i])
> {
> checkValuesThread[i].start();
> hThreadCheckValues[i] = checkValuesThread[i].id();
> numThreadsRunning++;
> }
> }
>
>
> while (true)
> {
> bool anyThreadsRunning = false;
>
> for (FXint i = 0; i < numTreads; i++)
> {
> if (checkValuesThread[i].running())
> {
> anyThreadsRunning = true;
> break;
> }
> }
>
> // if all threads are finished
> if (!anyThreadsRunning)
> {
> break;
> }
>
> // keep UI responsive
> if (getApp()->peekEvent())
> {
> getApp()->runWhileEvents();
> }
> } // while (true)
>
>
>
> for (FXint i = 0; i < numTreads; i++)
> {
> checkValuesThread[i].join();
> }
>
>
>
>
> -----Original Message-----
> From: Enno Rehling <[email protected]>
> Sent: Sunday, November 20, 2022 8:36 AM
> To: [email protected]
> Subject: Re: [Foxgui-users] multithreading
>
> Hi John,
>
> Your question lacks some important details. How is this related to Fox?
> What do you mean by "multithreaded a calculation"? Can you show some example code of what you are doing that would help to reproduce the problem?
>
> Enno.
>
> On 20-Nov-22 00:27, John Selverian wrote:
>> I’m seeing a very strange problem. I just multithreaded a calculation
>> and it takes longer then running with a single thread. I’ve done
>> multithreading in the past with success so I don’t see what could be
>> going wrong. The overhead for each thread is very low so that’s not it.
>> Any ideas?
>>
>> Kind regards,
>>
>> js
>>
>>
>>
>> _______________________________________________
>> Foxgui-users mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/foxgui-users
>
> _______________________________________________
> Foxgui-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/foxgui-users
>
>
>
> _______________________________________________
> Foxgui-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/foxgui-users
--
Roland Hughes, President
Logikal Solutions
(630)-205-1593
http://www.theminimumyouneedtoknow.com
http://www.infiniteexposure.net
http://www.johnsmith-book.com
http://www.logikalblog.com
http://www.interestingauthors.com/blog
_______________________________________________
Foxgui-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/foxgui-users