Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

VMS must die!


devel / comp.lang.c++ / How does parallel sort() scale on your PC

SubjectAuthor
o How does parallel sort() scale on your PCBonita Montero

1
How does parallel sort() scale on your PC

<u2u303$1c2lt$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=3&group=comp.lang.c%2B%2B#3

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.Montero@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: How does parallel sort() scale on your PC
Date: Wed, 3 May 2023 18:43:47 +0200
Organization: A noiseless patient Spider
Lines: 56
Message-ID: <u2u303$1c2lt$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 3 May 2023 16:43:47 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="7e5769ab5375687dd3b04f74115d68f5";
logging-data="1444541"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18J59Ixq1j5ixqXCjCRr+ceW7iNN5MAkLw="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.10.1
Cancel-Lock: sha1:0rPOAWLsPcCtZ+fzyeiHOm7I6GQ=
Content-Language: de-DE
 by: Bonita Montero - Wed, 3 May 2023 16:43 UTC

#include <iostream>
#include <algorithm>
#include <execution>
#include <vector>
#include <random>
#include <chrono>
#include <charconv>
#include <functional>

#if defined(_MSC_VER)
#pragma warning(disable: 4996)
#endif

using namespace std;
using namespace chrono;

int main( int argc, char **argv )
{ if( argc < 2 )
return EXIT_FAILURE;
size_t upper;
bool b16 = strnicmp( argv[1], "0x", 2 ) == 0;
argv[1] += b16 ? 2 : 0;
if( from_chars_result fcr = from_chars( argv[1], argv[1] + strlen(
argv[1] ), upper, b16 ? 16 : 10 ); (bool)fcr.ec || *fcr.ptr )
return EXIT_FAILURE;
vector<size_t> vs;
vs.reserve( upper );
size_t size = 1;
mt19937_64 mt;
uniform_int_distribution<size_t> uid( 0, -1 );
do
{
size = size * 2 <= upper ? size * 2 : upper;
vs.resize( size );
auto perf = [&]( function<void ()> const &fn )
{
for( size_t &s : vs )
s = uid( mt );
auto start = high_resolution_clock::now();
fn();
return duration_cast<nanoseconds>( high_resolution_clock::now() -
start ).count() / 1.0e9;
};
double
tParallel = perf( [&]() { sort( execution::parallel_policy(),
vs.begin(), vs.end() ); } ),
tSerial = perf( [&]() { sort( vs.begin(), vs.end() ); } );
auto s2 = []( double d ) -> double { return trunc( 100.0 * d + 0.5 ) /
100.0; };
cout << "0x" << hex << size << ": " << tSerial / tParallel << " (" <<
s2( tSerial ) << " : " << s2( tParallel ) << ")" << endl;
} while( size < upper );
}

I get only a scaling up to 8x on a 3990X (Windows) and a 7950X (Linux).


devel / comp.lang.c++ / How does parallel sort() scale on your PC

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor