... move the needle back towards 32?

Ah, I missed sharing that it no longer takes the full CPU (64-threads) to run as fast as C++. Below, I specify t1.txt four times to increase the compute time. It takes 17 physical CPU cores for Perl to run faster than C++ :).

Update: Using faster MCE variant. See tybalt89's enhancement.

$ time ./rtoa-pgatram-fixed t1.txt t1.txt t1.txt t1.txt >f.tmp read_input_files : 15996000 items read file time : 0.356 secs roman_to_dec time : 0.460 secs output time : 0.124 secs total time : 0.941 secs real 0m0.947s user 0m0.875s sys 0m0.072s # https://perlmonks.org/?node_id=11152168 max_workers => 16 $ time perl rtoa-pgatram-mce.pl t1.txt t1.txt t1.txt t1.txt >p.tmp rtoa pgatram start time 0.980 secs real 0m1.008s user 0m14.836s sys 0m0.075s # https://perlmonks.org/?node_id=11152168 max_workers => 17 $ time perl rtoa-pgatram-mce.pl t1.txt t1.txt t1.txt t1.txt >p.tmp rtoa pgatram start time 0.912 secs real 0m0.940s user 0m14.802s sys 0m0.123s # https://perlmonks.org/?node_id=11152168 max_workers => 32 $ time perl rtoa-pgatram-mce.pl t1.txt t1.txt t1.txt t1.txt >p.tmp rtoa pgatram start time 0.548 secs real 0m0.577s user 0m15.889s sys 0m0.231s $ cksum f.tmp p.tmp 737201628 75552000 f.tmp 737201628 75552000 p.tmp

I modified rtoa-pgatram-fixed.cpp and removed the last vector, cstart3, and cend3. Hence, write to standard output immediately. Perl now needs 4 more CPU cores to run faster. Crazy :)

// Convert roman to decimal cstart2 = high_resolution_clock::now(); for ( auto const& r : roman_list ) { // std::cout << roman_to_dec(r) << '\n'; fast_io::io::println(roman_to_dec(r)); } cend2 = high_resolution_clock::now(); double ctaken2 = elaspe_time(cend2, cstart2); std::cerr << "roman_to_dec time : " << std::setw(8) << ctaken2 << " + secs\n"; double ctaken = elaspe_time(cend2, cstart1); std::cerr << "total time : " << std::setw(8) << ctaken << +" secs\n";
$ time ./rtoa-pgatram-fixed2 t1.txt t1.txt t1.txt t1.txt >f.tmp read_input_files : 15996000 items read file time : 0.349 secs roman_to_dec time : 0.468 secs total time : 0.818 secs real 0m0.824s user 0m0.768s sys 0m0.056s # https://perlmonks.org/?node_id=11152168 max_workers => 21 $ time perl rtoa-pgatram-mce.pl t1.txt t1.txt t1.txt t1.txt >p.tmp rtoa pgatram start time 0.770 secs real 0m0.799s user 0m15.147s sys 0m0.131s

The above results were captured on Fedora Linux 38. I also tried the Perl binary on Clear Linux for better performance :)

# https://perlmonks.org/?node_id=11152168 max_workers => 21 $ time perl rtoa-pgatram-mce.pl t1.txt t1.txt t1.txt t1.txt >p.tmp rtoa pgatram start time 0.662 secs real 0m0.689s user 0m13.129s sys 0m0.132s # https://perlmonks.org/?node_id=11152168 max_workers => 32 $ time perl rtoa-pgatram-mce.pl t1.txt t1.txt t1.txt t1.txt >p.tmp rtoa pgatram start time 0.475 secs real 0m0.502s user 0m13.732s sys 0m0.246s

About the Perl MCE demonstration. I made the demonstration simply for showcasing running parallel in Perl. It was a fun exercise for checking how many CPU cores does Perl need to reach C++ using fast_io.


In reply to Re^5: Risque Romantic Rosetta Roman Race - MCE Results on AMD Box by marioroy
in thread Risque Romantic Rosetta Roman Race by eyepopslikeamosquito

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.