Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^8: Rosetta Code: Long List is Long (faster - vec - OpenMP)

by marioroy (Prior)
on Jan 11, 2023 at 22:07 UTC ( [id://11149541]=note: print w/replies, xml ) Need Help??


in reply to Re^7: Rosetta Code: Long List is Long (faster - vec - OpenMP)
in thread Rosetta Code: Long List is Long

It was weird experiencing the segfault due to strtok(NULL, "\n").

Great! What is strtok_r() function in C language? I compared strtok_r with context against strchr. After testing, I updated the OpenMP demonstration to find the tab character within the string. Now passing: limited length and variable length words, including OpenMP. Update 2 enables parallel sort.

# 15 input files, 1 thread, clang++ -std=c++20 strtok_r 9.655 seconds strchr 8.713 seconds
while ( ::fgets(line, MAX_LINE_LEN_L, fh) != NULL ) { found = ::strchr(line, '\t'); count = ::atoll( &line[found - line + 1] ); line[found - line] = '\0'; // word ... }

Also, I replaced strlen(...) with found - line.

::memcpy( fixword.data(), line, found - line );

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11149541]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (9)
As of 2024-04-18 11:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found