GithubHelp home page GithubHelp logo

Comments (4)

greg7mdp avatar greg7mdp commented on May 23, 2024 1

Hi @marioroy , if you want to guarantee that your map is cleared, you can swap it with a temporary map, for example:

MyMap map;
map.emplace(....);
...
MyMap().swap(map); // swap map with an empty temporary, which is immediately destroyed

from parallel-hashmap.

marioroy avatar marioroy commented on May 23, 2024 1

Thank you. Your suggestion works.

from parallel-hashmap.

marioroy avatar marioroy commented on May 23, 2024 1

Ah, the vector is already fully allocated initially. Never mind. The maximum memory consumption is reached.

I'm updating the llil4map demonstrations and checking gcc++, clang++, including nvc++. Nvc++ is the reason for the update. I'm resolving nvc++ slow compile and slow program output.

from parallel-hashmap.

marioroy avatar marioroy commented on May 23, 2024

Hi, @greg7mdp. I met to ask another question. Is it possible to clear/destroy a sub map individually, inside the top-level parallel loop? This will help minimize total memory consumption.

   // Store the properties into a vector
   vec_str_int_type propvec;
   size_t prev_num_keys;

   propvec.resize(map.size());
   std::vector<vec_str_int_type::iterator> I; I.resize(map.subcnt());
   I[0] = propvec.begin();
   
   for (size_t i = 0; i < map.subcnt(); ++i) {
      map.with_submap(i, [&](const map_str_int_type::EmbeddedSet& set) {
         if (i == 0) {
            prev_num_keys = set.size();
         } else {
            I[i] = I[i-1] + prev_num_keys;
            prev_num_keys = set.size();
         }
      });
   }  
   
   #pragma omp parallel for schedule(static, 1) num_threads(4)
   for (size_t i = 0; i < map.subcnt(); ++i) {
      map.with_submap(i, [&](const map_str_int_type::EmbeddedSet& set) {
         auto it = I[i];
         for (auto& x : set)
            *it++ = std::make_pair(std::move(x.first), x.second);
         // here, I like to reclaim memory after the inner-for-loop completes
      });
   }
   
   // swap map with an empty temporary, which is immediately destroyed
   map_str_int_type().swap(map);

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.