GithubHelp home page GithubHelp logo

Comments (4)

greg7mdp avatar greg7mdp commented on June 5, 2024 1

Oh, I just thought that your bench will be a bit faster if you reserve the size in your map:

    new_ids.reserve(vertex_ids.size() * 110 / 100);

from parallel-hashmap.

greg7mdp avatar greg7mdp commented on June 5, 2024

Hi @samuelpmish , thank you for using phmap.

I have a fix for you. You''ll be happy with the speed:

  1. use phmap::parallel_flat_hash_map, it is faster.
  2. create another type alias (I called it pmap_nullmutex) which has phmap::NullMutex as the mutex type
  3. call the renumber function with this extra type, as in:
    renumber< pmap<4>, pmap_nullmutex<4> >(vertex_ids, elements, 1);
  4. before the update part, swap the pmap with the mutex with the one with the NullMutex, and then use the new map with no mutex locking (which is unneeded as we access the map only for read), as in:
  stopwatch.start();
  Map_nomutex new_ids_nc;
  new_ids_nc.swap(new_ids);
  pool.parallel_for(elements.size(), [&](uint64_t i){
    auto & elem = elements[i];
    elem[0] = new_ids_nc.at(elem[0]);
    elem[1] = new_ids_nc.at(elem[1]);
    elem[2] = new_ids_nc.at(elem[2]);
    elem[3] = new_ids_nc.at(elem[3]);
  });
  stopwatch.stop();

Here are the results I got:

generating dataset .. done
std::unordered_map, 1 thread: 1073.95ms 4651.66ms
std::unordered_map, 32 thread (single threaded insertion): 1253.99ms 464.183ms
pmap4, 1 thread: 649.7ms 2574.57ms
pmap4, 32 threads: 353.275ms 217.594ms
pmap6, 1 thread: 365.098ms 2615.59ms
pmap6, 32 threads: 204.003ms 219.373ms

from parallel-hashmap.

greg7mdp avatar greg7mdp commented on June 5, 2024

Here is your updated benchmark

PS: would you mind if I add it as an example in phmap?
PS2: your benchmark feels very familiar. I used to develop a graphics lbrary for FE element analysis at Altair Engineering :-).

from parallel-hashmap.

samuelpmish avatar samuelpmish commented on June 5, 2024

thanks for the update, that was what I was missing!

would you mind if I add it as an example in phmap?

sounds good to me

your benchmark feels very familiar. I used to develop a graphics lbrary for FE element analysis at Altair Engineering :-)

you've figured me out, it's taken from a finite element project-- thanks again for the help!

from parallel-hashmap.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.