←  [EN] Third-Party Development

Forums

»

OpenMP Pragma's

Speedy1985's Photo Speedy1985 24 Feb 2013

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.
Quote

MiLo's Photo MiLo 24 Feb 2013

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...
Quote

Speedy1985's Photo Speedy1985 24 Feb 2013

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.
Quote