Using vector units

R

Richard Cavell

Hi,

Many processors have some kind of facility for working on multiple data
at once (MMX, SIMD, SSE2, Altivec, Velocity Engine, etc). What's the
state of the art with regards trying to use these with C/C++? How does
one present data to the compiler so that the compiler might be able to
invoke the vector unit?
 
V

Victor Bazarov

Richard said:
Many processors have some kind of facility for working on multiple data
at once (MMX, SIMD, SSE2, Altivec, Velocity Engine, etc). What's the
state of the art with regards trying to use these with C/C++? How does
one present data to the compiler so that the compiler might be able to
invoke the vector unit?

AFAIK, the only facility that comes close to bridging the gap between the
language and the CPU in that matter is 'std::valarray'. The library is
free to implement any operations on it using the vector facility in the
hardware.

Then again, I've never used that template, so I wouldn't really know...

V
 
H

Howard

Richard Cavell said:
Hi,

Many processors have some kind of facility for working on multiple data at
once (MMX, SIMD, SSE2, Altivec, Velocity Engine, etc). What's the state
of the art with regards trying to use these with C/C++? How does one
present data to the compiler so that the compiler might be able to invoke
the vector unit?

I'm not sure what you mean bvy a "vector unit"...? Are you referring to
multiple processors on one computer? If so, the OS takes care of when/if
those are used, usually. But if you write code that uses threads, then the
computer is likely to make use of both processors when two threads are
running concurrently.

However, hardware issues and threads are not topical to this newsgroup,
which discusses C++ language issues (since standard C++ does not specify
anything (at least not yet) about threading models). I don't know if
there's a newsgroup that does discuss general multi-processor questions, but
you could search on groups.google.com, or find a newsgroup that discusses
the particular OS or hardware you're interested in.

-Howard
 
J

Jerry Coffin

Richard said:
Hi,

Many processors have some kind of facility for working on multiple
data at once (MMX, SIMD, SSE2, Altivec, Velocity Engine, etc).
What's the state of the art with regards trying to use these with
C/C++? How does one present data to the compiler so that the
compiler might be able to invoke the vector unit?

Some compilers do attempt vectorization, but the results I've seen have
been rather underwhelming (on the order of 10-20%). A fair number of
compilers include intrinsics so you can include the vector instructions
directly into C++. These generally require you to use special key words
for the data types.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,202
Messages
2,571,057
Members
47,660
Latest member
vidotip479

Latest Threads

Top