Turning on/off instruction extensions

Hi everybody,

I'm trying to run some examples with different backend options (turning
on/off SSE, 3dnow, or MMX instructions). However, I don't see any
difference in terms of execution time. Does anybody know which language
constructs (in C/C++ preferably) should I try to make these instructions
generated (and thus make a difference between a backend that enables
them or not) ?

I tried generating vector instructions with loops but it's not
happening. Perhaps Polly can generate vector instructions?

Thanks ahead,

Pablo
DIE-UPM
Madrid

Hi everybody,

I'm trying to run some examples with different backend options (turning
on/off SSE, 3dnow, or MMX instructions). However, I don't see any
difference in terms of execution time. Does anybody know which language
constructs (in C/C++ preferably) should I try to make these instructions
generated (and thus make a difference between a backend that enables
them or not) ?

I tried generating vector instructions with loops but it's not
happening. Perhaps Polly can generate vector instructions?

You can also try my basic-block autovectorization patch.

http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20111121/132206.html

After applying the patch (I recommend applying it to the current trunk),
then run clang with the flags:
-mllvm -vectorize -mllvm -unroll-allow-partial
(the -unroll-allow-partial is not necessary for the vectorization, but
tends to expose additional vectorization opportunities). The basic-block
vectorizer has a number of flags that can be used to customize its
behavior, so if it is not vectorizing something that you think it should
be (or is doing something performance detrimental), please let me know
and I'll be happy to help.

-Hal

Hi Pablo, if you use the dragonegg front-end and compile at -O3 with the
option -fplugin-arg-dragonegg-enable-gcc-optzns then you should get
vectorized code passed to the LLVM backend (that option turns on the gcc
optimizers, in particular its auto-vectorizer). If you want to produce
vector code by hand, check out the gcc docs where they explain about their
vector extensions to the C language. These also work with clang.

Ciao, Duncan.

How can I install the patch? Any step-by-step guide?

Thanks,
Pablo

How can I install the patch? Any step-by-step guide?

First, grab the trunk versions of llvm and clang. This is detailed on
http://clang.llvm.org/get_started.html

Then you apply the patch. On a Unix-like system, this is something like:
cd llvm
patch -p1 < /path/to/the-patch-file.diff

Then you rebuild.

If you have any further questions, or need a more-detailed answer,
please let me know.

-Hal

How can I install the patch? Any step-by-step guide?

First, grab the trunk versions of llvm and clang. This is detailed on
Clang - Getting Started

Then you apply the patch. On a Unix-like system, this is something like:
cd llvm
patch -p1 < /path/to/the-patch-file.diff

I tried to apply the patch to llvm 2.9 (not the trunk) but it shows a lot of "... hunk FAILED -- saving rejects to file ...". Is it safe to ignore these errors? Is it impossible to apply this patch to LLVM 2.9? Do you have a version of the patch compatible with 2.9?

Right now I cannot switch to the trunk version.

Thanks in advance,
Pablo

Sorry, the previous mail was unreadable:

>> How can I install the patch? Any step-by-step guide?
>
> First, grab the trunk versions of llvm and clang. This is detailed on
> Clang - Getting Started
>
> Then you apply the patch. On a Unix-like system, this is something like:
> cd llvm
> patch -p1 < /path/to/the-patch-file.diff
>

I tried to apply the patch to llvm 2.9 (not the trunk) but it shows a lot of "... hunk FAILED -- saving rejects to file ...". Is it safe to ignore these errors? Is it impossible to apply this patch to LLVM 2.9? Do you have a version of the patch compatible with 2.9?

Unfortunately, I don't have a version for 2.9.

-Hal

Hi,

There are a *lot* of changes (around 15000 commits if I recall Chris'
keynote) between 2.9 and 3.0/trunk. It does sound like you're on a lost
cause at the moment - you can't ignore those patching errors.

Cheers,

James

Ok you convinced me, I'll switch to 3.0 as soon as it comes out. This vectorizer seems like the kind of thing I'm looking for.

I applied the patch to the trunk version successfully, although I get an error in between:

1 out of 1 hunk FAILED -- saving rejects to file lib/Transforms/IPO/CMakeLists.txt.rej

Can I ignore the error? The patch exits normally except for that error.

Also, I tried to apply the patch to the LLVM 3.0 but does not work at all. Is the trunk version the only one where the patch can be applied?

Thanks ahead,
Pablo

I applied the patch to the trunk version successfully, although I get an error in between:

1 out of 1 hunk FAILED -- saving rejects to file lib/Transforms/IPO/CMakeLists.txt.rej

Can I ignore the error? The patch exits normally except for that error.

If you're using the default unix configure script and makefiles, then
you can ignore this error. Regardless, I'll rebase the patch and post an
updated version.

-Hal

I applied the patch to the trunk version successfully, although I get an error in between:

1 out of 1 hunk FAILED -- saving rejects to file lib/Transforms/IPO/CMakeLists.txt.rej

Can I ignore the error? The patch exits normally except for that error.

The attached patch should apply cleanly.

Thanks for the feedback,
Hal

llvm_bb_vectorize-20111202.diff (96.3 KB)

Hi Hal,

Hi Hal,

>> I applied the patch to the trunk version successfully, although I get an error in between:
>>
>> 1 out of 1 hunk FAILED -- saving rejects to file lib/Transforms/IPO/CMakeLists.txt.rej
>>
>> Can I ignore the error? The patch exits normally except for that error.
> The attached patch should apply cleanly.
>
> Thanks for the feedback,
> Hal

I'm still getting the following error:

---
1 out of 3 hunks FAILED -- saving rejects to file
lib/Transforms/IPO/PassManagerBuilder.cpp.rej
---

I'm using LLVM rev. 146369 (current trunk). Is it the same as you? If
not, tell me your revision and I'll try again.

LLVM develops quickly :wink: -- The patch you have is again out of sync.
I'll send an updated patch to the list soon.

Suggestion: would it be possible to have a patch for the stable version
(LLVM 3.0)?

I'll add that to my TODO list, but I probably won't get to it until
after the current patch finishes code review. I'll worry about
backporting after that.

-Hal

I'm still getting the following error:

---
1 out of 3 hunks FAILED -- saving rejects to file
lib/Transforms/IPO/PassManagerBuilder.cpp.rej
---

I'm using LLVM rev. 146369 (current trunk). Is it the same as you? If
not, tell me your revision and I'll try again.

LLVM develops quickly :wink: -- The patch you have is again out of sync.
I'll send an updated patch to the list soon.

Great! I'll wait for the new patch. Thanks for the help!

One more question: I'm currently using dragonegg for autovectorization, but I cannot get any vector longer than 4 elements for floats and 2 for doubles. I suspect this is because my processor doesn't support bigger vectors. However, I would like to generate bigger vectors into the LLVM IR, and then decide what to do with them in the backend. Can your vectorizer do something like that?

Thanks,
Pablo

>>
>> I'm still getting the following error:
>>
>> ---
>> 1 out of 3 hunks FAILED -- saving rejects to file
>> lib/Transforms/IPO/PassManagerBuilder.cpp.rej
>> ---
>>
>> I'm using LLVM rev. 146369 (current trunk). Is it the same as you? If
>> not, tell me your revision and I'll try again.
> LLVM develops quickly :wink: -- The patch you have is again out of sync.
> I'll send an updated patch to the list soon.

Great! I'll wait for the new patch. Thanks for the help!

One more question: I'm currently using dragonegg for autovectorization,
but I cannot get any vector longer than 4 elements for floats and 2 for
doubles. I suspect this is because my processor doesn't support bigger
vectors. However, I would like to generate bigger vectors into the LLVM
IR, and then decide what to do with them in the backend. Can your
vectorizer do something like that?

Yes, just pass the flag: -bb-vectorize-vector-bits=256 (or whatever). It
will then try to generate vectors *up to* that size (could be smaller,
but not larger).

-Hal

> >>
> >> I'm still getting the following error:
> >>
> >> ---
> >> 1 out of 3 hunks FAILED -- saving rejects to file
> >> lib/Transforms/IPO/PassManagerBuilder.cpp.rej
> >> ---
> >>
> >> I'm using LLVM rev. 146369 (current trunk). Is it the same as you? If
> >> not, tell me your revision and I'll try again.
> > LLVM develops quickly :wink: -- The patch you have is again out of sync.
> > I'll send an updated patch to the list soon.
>
> Great! I'll wait for the new patch. Thanks for the help!

Try the patch attached to:
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20111212/133389.html

-Hal