Skip to content
Snippets Groups Projects

Single Particle

Merged Slattery, Stuart requested to merge (removed):fix_warnings into master
1 unresolved thread

Adds a single particle to the library. This single particle is simply a tuple which holds access to multidimensional data of a trivial type for a single particle. This new class serves multiple purposes:

  • It provides a convenient get/set infrastructure for individual particles within a list of particles
  • It replaces the BufferParticle. The copy in this case should be more efficient than the byte-wise copy of the BufferParticle and also easier to maintain. This comes at the cost of potentially some extra memory usage because of the padding.
  • Because the particles themselves are trivial, one can make a Kokkos::View of these particles. This is effectively then an implementation of Array-of-Structs.
  • One should be able to easily use a Kokkos::View of particles with MPI because they are of trivial type by casting them to a char pointer.
  • This will hopefully also solve some potentially non-portable code that was doing a bunch of casting in the BufferParticle implementation as found by @gchen

Merge request reports

Merged by Slattery, StuartSlattery, Stuart 6 years ago (May 25, 2018 3:44pm UTC)

Merge details

  • Changes merged into master with 402967db.
  • Deleted the source branch.

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
525 531 return Index( array_size, s, i );
526 532 }
527 533
534 // -------------------------------
535 // Particle accessors.
536
537 /*!
538 \brief Get a particle at a given index.
539
540 \param idx The index to get the particle from.
541
542 \param particle The particle to assign the data to.
543 */
544 KOKKOS_INLINE_FUNCTION
545 particle_type getParticle( const Index idx ) const
  • How worried should we be about people abusing this deep copy thinking its a shallow (free) accessor?

    It's obviously implied by the typing, so I'm not sure how much we can do, but thought it was worth checking

  • Please register or sign in to reply
  • Seems pretty solid to me!

    One final question though, why is "The copy in this case should be more efficient than the byte-wise copy of the BufferParticle"? Isn't it ~the same?

  • I think it is more efficient because we are doing this to copy a double

    double x;
    double y = x;

    instead of something like this:

    double x;
    double y;
    for ( int b = 0; b < 8; ++b )
        static_cast<char*>(&y)[b] = static_cast<char*>(&x)[b]

    which is effectively what BufferParticle was doing. This was suggested by the LAMMPS team on the last call.

    At a minimum the syntax is more clear an an individual particle seems like a useful construct.

    Edited by Slattery, Stuart
  • Ok, great!

  • Slattery, Stuart mentioned in merge request !18 (merged)

    mentioned in merge request !18 (merged)

  • added 1 commit

    Compare with previous version

  • mentioned in commit 402967db

  • Please register or sign in to reply
    Loading