Re: [Kicad-developers] Zone filling (was: MacOS + OpenMP)

2018-03-03 Thread Jeff Young
> you implemented multiple workers yourself now?

Yes.  We’re pulling zones from a list anyway, so it was easy enough to use the 
list as a work queue.  I just added a std::atomic index into the list; each 
worker grabs the next index when it’s looking for more to do.

Cheers,
Jeff.


> On 3 Mar 2018, at 18:34, Bernhard Stegmaier  wrote:
> 
> Hi,
> 
> you implemented multiple workers yourself now?
> I’ll have to check in detail.
> 
> I thought of just using OpenMP for the for loop again like this.
> <<<
> diff --git a/pcbnew/zone_filler.cpp b/pcbnew/zone_filler.cpp
> index 6fe40555a..408c5e7aa 100644
> --- a/pcbnew/zone_filler.cpp
> +++ b/pcbnew/zone_filler.cpp
> @@ -118,6 +118,9 @@ void ZONE_FILLER::Fill( std::vector 
> aZones )
>  m_count_done = 0;
>  std::thread fillWorker( [ this, toFill ]()
>  {
> +#ifdef USE_OPENMP
> +#pragma omp for schedule(dynamic)
> +#endif
>  for( unsigned i = 0; i < toFill.size(); i++ )
>  {
>  SHAPE_POLY_SET rawPolys, finalPolys;
> >>>
> 
> Currently compiling, but my (test) clang with OpenMP is pretty picky about 
> other OpenMP stuff… :(
> 
> 
> Regards,
> Bernhard
> 
>> On 3. Mar 2018, at 18:50, Jeff Young > > wrote:
>> 
>> Hi Tomasz & Bernhard,
>> 
>> If you have a chance could you guys please take a look at 
>> https://git.launchpad.net/kicad/commit/?id=c77d13292b63a3ef7c28f004ee93f3ed93cca9f3
>>  
>> 
>>  ?
>> 
>> It reinstates multi-threading (with thread pooling) to the zone filler.
>> 
>> Bernard is still looking for ways to make this a bit more elegant; this 
>> version just uses brute force for now.
>> 
>> Cheers,
>> Jeff.
>> 
>> 
>>> On 1 Mar 2018, at 14:58, Tomasz Wlostowski >> > wrote:
>>> 
>>> On 01/03/18 15:43, Jeff Young wrote:
 The purpose is it works on Mac.
 
 But it does appear I misread the std::max( omp_get_num_procs(), 2 ) part.
 
>>> 
>>> Thanks Jeff!
>>> 
>>> Be aware that neither std::thread nor std::async have any concept of
>>> thread pooling - we need to look for a suitable library or write or own.
>>> 
>>> Cheers,
>>> Tom
>> 
>> ___
>> Mailing list: https://launchpad.net/~kicad-developers 
>> 
>> Post to : kicad-developers@lists.launchpad.net 
>> 
>> Unsubscribe : https://launchpad.net/~kicad-developers 
>> 
>> More help   : https://help.launchpad.net/ListHelp 
>> 
> 

___
Mailing list: https://launchpad.net/~kicad-developers
Post to : kicad-developers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~kicad-developers
More help   : https://help.launchpad.net/ListHelp


Re: [Kicad-developers] Zone filling (was: MacOS + OpenMP)

2018-03-03 Thread Bernhard Stegmaier
Hi,

you implemented multiple workers yourself now?
I’ll have to check in detail.

I thought of just using OpenMP for the for loop again like this.
<<<
diff --git a/pcbnew/zone_filler.cpp b/pcbnew/zone_filler.cpp
index 6fe40555a..408c5e7aa 100644
--- a/pcbnew/zone_filler.cpp
+++ b/pcbnew/zone_filler.cpp
@@ -118,6 +118,9 @@ void ZONE_FILLER::Fill( std::vector aZones 
)
 m_count_done = 0;
 std::thread fillWorker( [ this, toFill ]()
 {
+#ifdef USE_OPENMP
+#pragma omp for schedule(dynamic)
+#endif
 for( unsigned i = 0; i < toFill.size(); i++ )
 {
 SHAPE_POLY_SET rawPolys, finalPolys;
>>>

Currently compiling, but my (test) clang with OpenMP is pretty picky about 
other OpenMP stuff… :(


Regards,
Bernhard

> On 3. Mar 2018, at 18:50, Jeff Young  wrote:
> 
> Hi Tomasz & Bernhard,
> 
> If you have a chance could you guys please take a look at 
> https://git.launchpad.net/kicad/commit/?id=c77d13292b63a3ef7c28f004ee93f3ed93cca9f3
>  
> 
>  ?
> 
> It reinstates multi-threading (with thread pooling) to the zone filler.
> 
> Bernard is still looking for ways to make this a bit more elegant; this 
> version just uses brute force for now.
> 
> Cheers,
> Jeff.
> 
> 
>> On 1 Mar 2018, at 14:58, Tomasz Wlostowski > > wrote:
>> 
>> On 01/03/18 15:43, Jeff Young wrote:
>>> The purpose is it works on Mac.
>>> 
>>> But it does appear I misread the std::max( omp_get_num_procs(), 2 ) part.
>>> 
>> 
>> Thanks Jeff!
>> 
>> Be aware that neither std::thread nor std::async have any concept of
>> thread pooling - we need to look for a suitable library or write or own.
>> 
>> Cheers,
>> Tom
> 
> ___
> Mailing list: https://launchpad.net/~kicad-developers
> Post to : kicad-developers@lists.launchpad.net
> Unsubscribe : https://launchpad.net/~kicad-developers
> More help   : https://help.launchpad.net/ListHelp

___
Mailing list: https://launchpad.net/~kicad-developers
Post to : kicad-developers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~kicad-developers
More help   : https://help.launchpad.net/ListHelp