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


Groups > comp.lang.c > #130463

Re: OpenMP and AVX2 Problem [SOLVED]

From "F. Russell" <fr@random.info>
Newsgroups comp.lang.c
Subject Re: OpenMP and AVX2 Problem [SOLVED]
Date 2018-05-12 19:42 +0000
Organization NewsGuy.com
Message-ID <pd7g3301c99@news4.newsguy.com> (permalink)
References <pd703u02761@news2.newsguy.com>

Show all headers | View raw


On Sat, 12 May 2018 15:09:50 +0000, F. Russell wrote:

> 
> Run Time Single-Thread: 0.010427 seconds
> Run Time Multi-Thread: 0.05072 seconds
> 

I believe that I have found the reason for the discrepancy.

The functions clock(), clock_gettime(CLOCK_PROCESS_CPUTIME_ID),
and rusage(RUSAGE_SELF) are indeed the correct functions to
measure the CPU time.

But for a multi-threaded process these functions will return
the SUM of the CPU time used by all threads:

https://en.wikipedia.org/wiki/CPU_time

Thus, the time returned should be divided by the number of threads
to give a rough final value.

The number of threads can be specified with the command:

OMP_NUM_THREADS=N ./vectprod-parallel

The results are consistent:

OMP_NUM_THREADS=2 ./vectprod-parallel
Run Time Multi-Thread: 10 msec

OMP_NUM_THREADS=4 ./vectprod-parallel
Run Time Multi-Thread: 20 msec

OMP_NUM_THREADS=8 ./vectprod-parallel
Run Time Multi-Thread: 42 msec
(this value varies  a lot from 32 - 52) 

I believe that this is the correct explanation.  If anyone knows
better please enlighten us.

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