Jump to content


Photo

OpenMP Pragma's


  • Please log in to reply
2 replies to this topic

#1 Speedy1985

  • Senior Member
  • 120 posts

+18
Neutral

Posted 24 February 2013 - 20:06

Hi pli developers..

I have some questions for you.

I have seen that use use openMP for aio-grab, thatś super.
I have tested and i see that itś faster on a dualcore.

So i have build me own compiler with OpenMP Support.
And added some openmp pragma's to my code,

itś working but there is another function that needed a pragma, but it won't work.
I get sigmentation faults at that point when i add #pragma omp parallel for,

This is the code that will send all color values to the daemon.

int SendRGB(int sync, int* outputused)
{
  string data;

  int i;
  //#pragma omp parallel for
  for (i = 0; i < m_lights.size(); i++)
  {
	float rgb[3];
	m_lights[i].GetRGB(rgb);
	data += "set light " + m_lights[i].m_name + " rgb " + ToString(rgb[0]) + " " + ToString(rgb[1]) + " " + ToString(rgb[2]) + "\n";
	if (m_lights[i].m_autospeed > 0.0 && m_lights[i].m_singlechange > 0.0)
	  data += "set light " + m_lights[i].m_name + " singlechange " + ToString(m_lights[i].m_singlechange) + "\n";
  }

  //send a message that we want devices to sync to our input
  if (sync)
	data += "sync\n";
  //if we want to check if our output is used, send a ping message
  if (outputused)
	data += "ping\n";
  if (!WriteDataToSocket(data))
	return 0;
  if (outputused)
	return Ping(outputused, false);
  else
	return 1;

}

I have tested with private and shared but no luck.
I hope some developer can help me.
Thanks!

Gr Speedy1985

Edited by Speedy1985, 24 February 2013 - 20:07.

 
Support: webchat.freenode.net #boblight-enigma2

Re: OpenMP Pragma's #2 MiLo

  • PLi® Core member
  • 14,045 posts

+298
Excellent

Posted 24 February 2013 - 20:26

The problem is in the "data += ..." statements. They cannot be run on multiple cores. Read the openMP manual, there's more to it than bluntly putting a pragma on each and every for loop...
Real musicians never die - they just decompose

Re: OpenMP Pragma's #3 Speedy1985

  • Senior Member
  • 120 posts

+18
Neutral

Posted 24 February 2013 - 20:41

The problem is in the "data += ..." statements. They cannot be run on multiple cores. Read the openMP manual, there's more to it than bluntly putting a pragma on each and every for loop...


i no that i can not add blunlty a pragma on every loop. ;)

Edited by Speedy1985, 24 February 2013 - 20:42.

 
Support: webchat.freenode.net #boblight-enigma2


2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users