no differnce in the execution time between seq. and parallel programs

Hi all
please can any one help me to find the reason??

i am using LLVM to execute two programs both of them was exactly similar but the difference was the first one is a sequential program has three functions. In the second program i am trying to execute it by giving each function to thread (three thread work in parallel way) ,but when i am trying to calculate the execution time i found the execution time for parallel one larger than sequential one ???

note
I execute both of these program in gcc compiler and i found there is a difference in the execution time between these programs.The parallel one was faster than the sequential one.

i will be thankful if any one can help me
Regards
esraa

Hi esraa,

i am using LLVM to execute two programs both of them was exactly
similar but the difference was the first one is a sequential program
has three functions. In the second program i am trying to execute it
by giving each function to thread (three thread work in parallel way)
,but when i am trying to calculate the execution time i found the
execution time for parallel one larger than sequential one ???

this is a very vague description and it's hard to understand what you mean
here. Maybe you mean that you used clang to compile a program containing
openmp macros. If so you have discovered that clang does not support openmp:
use the dragonegg LLVM front-end instead.

Ciao, Duncan.

Duncan Sands <baldrick <at> free.fr> writes:

Hi esraa,

> i am using LLVM to execute two programs both of them was exactly
> similar but the difference was the first one is a sequential program
> has three functions. In the second program i am trying to execute it
> by giving each function to thread (three thread work in parallel way)
> ,but when i am trying to calculate the execution time i found the
> execution time for parallel one larger than sequential one ???

this is a very vague description and it's hard to understand what you mean
here. Maybe you mean that you used clang to compile a program containing
openmp macros. If so you have discovered that clang does not support openmp:
use the dragonegg LLVM front-end instead.

Ciao, Duncan.

>
> note
> I execute both of these program in gcc compiler and i found there is a
> difference in the execution time between these programs.The parallel
> one was faster than the sequential one.
>
> i will be thankful if any one can help me
> Regards
> esraa
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev <at> cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

Hi Ciao
Thank you very much for the quick reply and sorry for misunderstanding me.
I am working with some optimizing techniques to transform the sequential program
to parallel program and after I finish this transformation I need to make
comparison between the execution time for seq. and optimized one(parallel ).
Before I automated this method using the llvm , I did this work manually.

In the first time I used the gcc to compile two versions of program seq. and
parallel( three threads work together using POSIX Pthread libraries). I
found that there was difference in the execution time between these two programs
(parallel one was faster than the seq. program).

Now I have repeating the same comparison (same two version of program that I
wrote before using c language ) by using llvm-gcc to get llvm byte code and
then llvm-ld to get executable program and made the comparison between them.

I was surprised when I found the result for my gcc experiments was different
from the result of llvm experiment.

I would be happy if you give me an insight into what could have caused the
difference.
Many thanks
Esraa

I would be happy if you give me an insight into what could have caused the
difference.

No idea. Maybe you forgot to turn optimizations on when compiling? Otherwise
you are going to have to send in your programs along with an explanation of how
you compiled them exactly (exact sequence of commands) both for gcc and LLVM.

Ciao, Duncan.

Duncan Sands <baldrick <at> free.fr> writes:

> I would be happy if you give me an insight into what could have caused the
> difference.

No idea. Maybe you forgot to turn optimizations on when compiling? Otherwise
you are going to have to send in your programs along with an explanation of how
you compiled them exactly (exact sequence of commands) both for gcc and LLVM.

Ciao, Duncan.

Hi Ciao
Thank you very much for your help and patience

I want to check with you the compilation steps witout turn on any optimazation
in both gcc and llvm :

Fft_x.c The first program before the transformation
Fft_dswp.c The second program after the transformation

In gcc compiler I used the following steps
--Before the transformation
gcc –Wall fft_x.c –o samp -lm
Time ./samp
    0.544 the execution time before transformation

--After the transformation
Gcc –Wall fftx_dswp.c –o samp -lm -lpthread
Time ./samp
0.319 the execution time after transformation

Hi Esraa,

I want to check with you the compilation steps witout turn on any optimazation
in both gcc and llvm :

Fft_x.c The first program before the transformation
Fft_dswp.c The second program after the transformation

In gcc compiler I used the following steps
--Before the transformation
gcc –Wall fft_x.c –o samp -lm
Time ./samp
     0.544 the execution time before transformation

--After the transformation
Gcc –Wall fftx_dswp.c –o samp -lm -lpthread
Time ./samp
0.319 the execution time after transformation
-------------------------------------------------------

Then I repeat the same Pervious steps with the llvm

In llvm compiler I used the following steps

--Before the transformation

Llvm-gcc -c -emit-llvm fft_x.c -o sam.o
Llvm-ld sam.o -lm
Time ./a.out
     0.320 the execution time before transformation

--After the transformation
Llvm-gcc -c -emit-llvm fft_dswp.c -o sam.o
Llvm-ld sam.o -lm
Time ./a.out
     0.350 the execution time after transformation
------------------------------------------------------

Realy I don’t care which one is faster llvm or gcc , but the thing that I care
about is
In gcc there was difference in the execution time before and after the
transformation, but in llvm I didn’t see any difference in llvm.

By default llvm-ld produces bitcode and a.out is a script that runs it in the
interpreter. This is not what you want. You should just do exactly the same
as with gcc, only replacing "gcc" with "llvm-gcc" everywhere, and not bother
with llvm-ld. Alternatively, pass -native to llvm-ld.

  In llvm the execution time after the transformation became worse .

if evey thing is ok and no error

My question is
Are there any strategies that llvm use it to treat with threads that make the
performance worse.

No. And since you didn't do any optimization, even if it did have such
strategies they wouldn't be applied. The difference is probably due to
your accidental use of the interpreter.

Best wishes, Duncan.

Parallel execution incurs an overhead penalty compared to sequential execution, which eventually is overcomed by more computing resources. That is, you don't always benefit from running in parallel.

In this case, I think it is very hard to say more without the details of your programs. I would say that your figures look "normal" given the information you provided. Just as the sequential execution times differ between compilers in "random" ways, the parallel may differ too.

/Patrik Hägglund