Restrict for matrix multiply?

92 views
Skip to first unread message

erich

unread,
Jun 5, 2009, 2:01:05 PM6/5/09
to CoreMark
It would be easier for compilers to schedule instructions if you added
"restrict" to the pointers in the matrix multiply. Otherwise, it's
difficult[0] for the compiler to know that they don't alias in some
way. And OOO architectures with alias detection (or compilers tweaked
to do unsafe optimizations) get a large advantage.

Or, perhaps, this was intentional? I'm guessing not, since "ILP" was
one of the goals of the benchmark and without restrict you may be
artificially limiting ILP.

[0] Determining they don't alias is not impossible, because in C we
are allowed to consider different types as never aliasing.
Regardless, if they can't alias it would be nice to see restrict. :-)

Shay Gal-On

unread,
Jun 5, 2009, 2:07:08 PM6/5/09
to CoreMark
Hello Erich,

We actually discussed this at EEMBC and decided that putting in
restrict opens up questions like - ok, why not add pragmas for OpenMP?
And while at it, why not other keywords?

In fact, as you say it should be pretty easy for the compiler to know
that the output matrix is not aliased with any of the input matrixes
since they are of different types, and many compilers have an option
that allows you to consider elements of different types as unaliased.
Also, since we specifically allow compilation of all files together,
if you use static memory allocation, the compiler has full information
to be able to do complete alias analysis even without the type
information. The program is small enough that you can run Anderson
points-to analysis easily enough.

Does that help?
Thanks,
- Shay

erich

unread,
Jun 5, 2009, 3:14:36 PM6/5/09
to CoreMark
Yes, so long as leaving the "restrict" out was intentional, I have no
complaint...
Though I will point out that "restrict" is part of C99 and OpenMP
pragmas are not. :-)
Reply all
Reply to author
Forward
0 new messages