Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Intel Community
- Software
- Software Development Topics
- Software Tuning, Performance Optimization & Platform Monitoring
- Fast method to exchange values of two double-precision variables

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

SergeyKostrov

Valued Contributor II

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

03-30-2012
05:54 AM

57 Views

Fast method to exchange values of two double-precision variables

...

double dValueA = 55.55L;

double dValueB = 77.77L;

...

What is a

Best regards,

Sergey

Link Copied

5 Replies

Patrick_F_Intel1

Employee

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

03-31-2012
07:18 PM

57 Views

Hello Sergey,

Are you doing x87 math or SSE2 math?

Is this showing up as a bottleneck?

Pat

Are you doing x87 math or SSE2 math?

Is this showing up as a bottleneck?

Pat

SergeyKostrov

Valued Contributor II

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

04-01-2012
12:01 PM

57 Views

Are you doing x87 math or SSE2 math?

I'd like to provide some technical details. I don't need this to do the math butI need to use it inseveral sorting algorithms, like **MergeSort**, **QuickSort**, etc,

in cases when '**double**' data types are used.

In ageneric form it looks like:

Here is a solution I currently implemented:

Thesolution with **FLD-FSTP** instructions is~1.6x fasterand it improves performance of sorting algorithms.

Is it possible to make the exchange faster?

Best regards,

Sergey

TimP

Black Belt

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

04-01-2012
01:00 PM

57 Views

SergeyKostrov

Valued Contributor II

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

04-01-2012
05:38 PM

57 Views

Quoting TimP (Intel)

It means thatcodes must be highlyoptimized at a C/C++ level,sometimes with inline assembler, and

I can't rely all the time onoptimizations of aC/C++ compiler.

Thanks in advance.

SergeyKostrov

Valued Contributor II

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

04-05-2012
04:20 PM

57 Views

Quoting Sergey Kostrov

Thesolution with

Is it possible to make the exchange faster?

I've done a set of tests with '**Load-Shuffle-Store**' intrinsic functions, like

but it is not as fast as '**Fld-Fstp**' based exchange. Finalrelative resultsof my tests are as follows:

Generic basedExchange- ~**1.5x** slower than Fld-Fstp

Fld-Fstp basedExchange - **1.0x**

Shuffle basedExchange - ~**2.5x** slower than Fld-Fstp

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

For more complete information about compiler optimizations, see our Optimization Notice.