Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Mon, 27 May 2013 23:27:28 +0200
From: magnum <john.magnum@...hmail.com>
To: john-dev@...ts.openwall.com
Subject: Re: OMP for raw formats

On 27 May, 2013, at 23:08 , <jfoug@....net> wrote:
> I think we can work around AMD's slow thread switching, by making the OMP code never to have to task switch.  This was done in dynamic, and I think we can do this in fast raw formats also.  This likely will get little to no gain on slow formats.
> 
> To do this, we need to change the for loop from:
> 
> #pragma omp parallel for
> for (i = 0 ; i <  count; += MAX_KEYS_PER_CRYPT)
> 
> to:
> 
> int inc = (count / omp_t) + 1;
> #pragma omp parallel for
> for (i = 0; i < count; i += inc) {
>  /* inside the threads workload */
>  for (j = 0; j < inc; ++j)
>     process_item(i*cnt+j)
> }
> 
> So if we 8 threads, and 1024 items, it will start 8 threads, and give each thread 129 items to work on (last thread will only get 121 items).  Thus, there is no thread switching.  That should help.

I always assumed OMP would do this transparently (eg. having thread 0 do the first n of the loop sequentially as opposed to some kind of leap frogging) but that would of course be depending on what compiler you run.

> NOTE, this is if I understand what OMP is doing under the hood, which may not be correct.
> 
> I am going to give this a shot on raw-MD5 and see what it does (core i7).  But if there is no slowdown on intel, and it gets things working on AMD, then it is a win/win.

I just tried dynamic_0 on Bull, non-OMP and OMP. Pretty mediocre results with multiple cores *but* there is not a lot of regression for 1x, which is most important. So hopefully you are right. I also tried bumping BLOCK_LOOPS by 10 just to see what happens but that was worse.

I hate it when we need to optimize differently for intel and AMD.

magnum

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.