Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #130454

Re: OpenMP and AVX2 Problem

Newsgroups comp.lang.c
From Melzzzzz <Melzzzzz@zzzzz.com>
Subject Re: OpenMP and AVX2 Problem
References <pd703u02761@news2.newsguy.com>
Message-ID <BhEJC.101707$ta2.49032@fx03.am4> (permalink)
Organization usenet-news.net
Date 2018-05-12 16:05 +0000

Show all headers | View raw


On 2018-05-12, F. Russell <fr@random.info> wrote:
> I am using AVX2 intrinsics to speed up math calculations.
> For example, using AVX2 can speed up the vector cross product,
> C = A X B, by a factor of 4, which for large arrays of vectors
> is a huge boost to performance.
>
> I am now thinking of using openmp to create multi-threaded
> routines where each processor, or thread, can execute the
> same AVX2 instructions on a part of the array.  This should
> speed thing up by at least another factor of four.
>
> However, my initial attempts do not work.  In fact, using
> openmp slows the calculations down by a factor of 5.
> I must be doing something wrong but I don't know what.
>
> Before I hit the references for some deep research on openmp
> I thought I would first post my code example here.
>
> The code is quite simple.  There is just a for loop
> over an array of vectors using AVX2 intrinsics.  The
> sample code is posted at the end.
>
> Since AVX2 operates on 4 double FP values, the array
> is an array of struct with each struct containing 4
> double components.  The fourth component is not used
> but needs to be there because the values must be 32-byte
> aligned.
>
> Using an array of size N=1,000,000 here are my results:
>
> Run Time Single-Thread: 0.010427 seconds
> Run Time Multi-Thread: 0.05072 seconds
>
>
> end = clock();
> seconds = (double)(end - start)/CLOCKS_PER_SEC;
> printf("\n\nRun Time Single-Thread: %g seconds\n\n", seconds);
>
Hey, you are measuring clocks not time.
Replace that with clock_gettime or gettimofday or Windows equialent
and youl get:
~/News >>> ./a.out


Run Time Single-Thread: 151.231 milliseconds

-2 13 -8 0


Run Time Multi-Thread: 46.348 milliseconds

-2 13 -8 0

-- 
press any key to continue or any other to quit...

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

OpenMP and AVX2 Problem "F. Russell" <fr@random.info> - 2018-05-12 15:09 +0000
  Re: OpenMP and AVX2 Problem Tim Prince <tprince@intelretiree.com> - 2018-05-12 11:33 -0400
  Re: OpenMP and AVX2 Problem Melzzzzz <Melzzzzz@zzzzz.com> - 2018-05-12 16:05 +0000
    Re: OpenMP and AVX2 Problem "F. Russell" <fr@random.info> - 2018-05-12 17:46 +0000
    Re: OpenMP and AVX2 Problem "F. Russell" <fr@random.info> - 2018-05-12 19:10 +0000
  Re: OpenMP and AVX2 Problem [SOLVED] "F. Russell" <fr@random.info> - 2018-05-12 19:42 +0000
    Re: OpenMP and AVX2 Problem [SOLVED] Keith Thompson <kst-u@mib.org> - 2018-05-12 14:04 -0700
  Re: OpenMP and AVX2 Problem scott@slp53.sl.home (Scott Lurndal) - 2018-05-13 17:47 +0000
  Re: OpenMP and AVX2 Problem Wouter Verhelst <w@uter.be> - 2018-05-13 09:57 +0200

csiph-web