Re: multithreading

"John Selverian" <[email protected]>
Newsgroups gmane.comp.lib.fox-toolkit.user
Organization JAHM Software
Message-ID <[email protected]>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.