473,626 Members | 3,373 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using vector units

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?
Jul 23 '05 #1
3 1389
Richard Cavell wrote:
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
Jul 23 '05 #2

"Richard Cavell" <ri***********@ mail.com> wrote in message
news:d0******** **@nnrp.waia.as n.au...
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.c om, or find a newsgroup that discusses
the particular OS or hardware you're interested in.

-Howard
Jul 23 '05 #3
Richard Cavell wrote:
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.

--
Later,
Jerry.

The universe is a figment of its own imagination.

Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
28943
by: Karen | last post by:
Hi, I have one constant variable and want to use it in two files. I put it in the header file and then include the header file. The compiler always say "error C2370: 'arraysize' : redefinition; different storage class". What shall I do? Files are listed below. I'm using Visual C++ 6.0 By the way, how to use STL (vector , for example) to create a multi-dimension array?
7
10620
by: Forecast | last post by:
I run the following code in UNIX compiled by g++ 3.3.2 successfully. : // proj2.cc: returns a dynamic vector and prints out at main~~ : // : #include <iostream> : #include <vector> : : using namespace std; : : vector<string>* getTyphoon()
19
2856
by: becte | last post by:
I need to use three bytes to store four 6-bit integers (4 * 6 = 3 * 8) like this 11111122|22223333|33444444 Suppose the input is, int c1, c2, c3, c4, range 0 .. 2^6 -1 and the output is int o1,o2,o3, range 0 .. 2^8-1 How to do this in a clever way? (The 6 bits integers represent characters in range A-Z and 0-9)
6
8149
by: johannblake | last post by:
I am wondering whether it is easy to setup a coordinate system for drawing (using GDI+) that uses meters (or any custom scaling for that matter). Currently, I need to convert from pixels to meters for scaling. This can sometimes get rather complex when you need to take scaling into account or other things like window resizing, scrolling, etc. There is a property called PageUnit which can be set to World. I could not find any examples...
5
2216
by: Javaman59 | last post by:
I just saw an interesting identifier in a C# book I'm reading... double dollarsPerHead This jumped out at me, as it is not common to put units in an identifer. We don't see "millisecondsSinceStart" ("time"), or "milesPerHour" ("speed"). But, perhaps it's a good idea. If memory serves me right, one of the Mars landers crashed because two development teams used different units (metric and imperial), across an interface. Also, when I'm...
5
2670
by: JoeC | last post by:
I have a vector of elements, how can I take the first element of a vector and put it in the end and have all the other elements cycle down? Ex: 1, 2, 3, 4... cycle 4, 1, 2 ,3
5
6023
by: sjsn | last post by:
Basic C++, just started this course in school... So I'm very limited. What I'm at doing is, below I have a variable named inputTemp, which is the product of a char, F = Fahrenheit, C = Celsius and K = Kelvin... I want to be specific when asking the user for more information, such as degrees. So when I ask for degrees in F... it wont sound so kinda funny. I know I can write "Enter unit of temp that you want converted using (F)ahrenheit,...
4
2267
by: Dia | last post by:
Hi there, I struggle to get this going i would like to insert data into 2 tmp tables in a view. If i run the code on it's own it works perfectly until i want to create a view it complains about the INSERT this is my code
0
1240
by: rupak | last post by:
I am using the xml file as given below <?xml version="1.0"?> <propertyfolio> <property_group description="abc"> <property ref="1" name="One"> <unit id="2147365895" /> <units> <unit property_ref="1" ref="1" description="description of One" strung_address="Address One" />
0
8268
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8202
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8707
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8641
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8366
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5575
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2628
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1812
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1512
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.