A SpECTRE With a New face Nils Deppe Simulating eXtreme Spacetimes - - PowerPoint PPT Presentation

a spectre with a new face
SMART_READER_LITE
LIVE PREVIEW

A SpECTRE With a New face Nils Deppe Simulating eXtreme Spacetimes - - PowerPoint PPT Presentation

A SpECTRE With a New face Nils Deppe Simulating eXtreme Spacetimes Collaboration Charm ++ Workshop April 11, 2018 github.com/sxs-collaboration/spectre A SpECTRE With a New Face 1 / 21 Table of Contents 1 SpECTRE 2 The New face


slide-1
SLIDE 1

A SpECTRE With a New ’face

Nils Deppe Simulating eXtreme Spacetimes Collaboration

Charm++ Workshop

April 11, 2018

github.com/sxs-collaboration/spectre A SpECTRE With a New Face 1 / 21

slide-2
SLIDE 2

Table of Contents

1 SpECTRE 2 The New ’face

github.com/sxs-collaboration/spectre A SpECTRE With a New Face 2 / 21

slide-3
SLIDE 3

SpECTRE Goals

Physics:

  • Multi-scale, multi-physics relativistic astrophysics
  • Binary black holes, binary neutron stars
  • Core-collapse supernovae with micro-physics
  • Multi-disciplinary

HPC:

  • Open-source, github.com/sxs-collaboration/spectre
  • Efficient
  • Exascale

github.com/sxs-collaboration/spectre A SpECTRE With a New Face 3 / 21

slide-4
SLIDE 4

Domain Decomposition and Local Time Stepping

  • B. Szilagyi, arXiv: 1405.3693

github.com/sxs-collaboration/spectre A SpECTRE With a New Face 4 / 21

slide-5
SLIDE 5

Dual Frames

github.com/sxs-collaboration/spectre A SpECTRE With a New Face 5 / 21

slide-6
SLIDE 6

Table of Contents

1 SpECTRE 2 The New ’face

github.com/sxs-collaboration/spectre A SpECTRE With a New Face 6 / 21

slide-7
SLIDE 7

Eliminating Charm++ Interface Files

Issues with interface files:

  • Restrictive
  • Error-prone (undefined behavior =

⇒ difficult bugs)

  • Maintenance burden (users and Charm++ devs)
  • Can’t handle modern C++ =

⇒ inefficient generated code

github.com/sxs-collaboration/spectre A SpECTRE With a New Face 7 / 21

slide-8
SLIDE 8

Eliminating Charm++ Interface Files

Issues with interface files:

  • Restrictive
  • Error-prone (undefined behavior =

⇒ difficult bugs)

  • Maintenance burden (users and Charm++ devs)
  • Can’t handle modern C++ =

⇒ inefficient generated code

Metaprogramming!

github.com/sxs-collaboration/spectre A SpECTRE With a New Face 7 / 21

slide-9
SLIDE 9

Important Features

We think:

  • Reduce user code
  • Really easy to use
  • Similar to current model: familiarity =

⇒ faster adoption

  • Error-free code generation
  • Eliminate runtime errors

Any others??

github.com/sxs-collaboration/spectre A SpECTRE With a New Face 8 / 21

slide-10
SLIDE 10

Design Steps

1 Invoking entry methods 2 Creating chares 3 Reductions

github.com/sxs-collaboration/spectre A SpECTRE With a New Face 8 / 21

slide-11
SLIDE 11

Invoking Entry Methods

Entry methods MyEntryMethod0, MyEntryMethod1, and Charm++ proxy my proxy. No arguments:

charmxx ::invoke <MyEntryMethod0 >( my_proxy);

Passing arguments:

charmxx ::invoke <MyEntryMethod1 >(my_proxy , arg0 , arg1 , std::move(arg2));

github.com/sxs-collaboration/spectre A SpECTRE With a New Face 9 / 21

slide-12
SLIDE 12

Entry Methods/Actions

struct MyEntryMethod1 { static void apply(const Arg0& arg0 , const Arg1& arg1 , Arg2&& arg2) noexcept { /* do work */ } };

  • Entry methods are “member functions”

github.com/sxs-collaboration/spectre A SpECTRE With a New Face 10 / 21

slide-13
SLIDE 13

Entry Methods/Actions

struct MyEntryMethod1 { static void apply(const Arg0& arg0 , const Arg1& arg1 , Arg2&& arg2) noexcept { /* do work */ } };

  • Entry methods are “member functions”
  • How to handle attributes?

github.com/sxs-collaboration/spectre A SpECTRE With a New Face 10 / 21

slide-14
SLIDE 14

Entry Methods/Actions

struct MyEntryMethod1 { static void apply(const Arg0& arg0 , const Arg1& arg1 , Arg2&& arg2) noexcept { /* do work */ } };

  • Entry methods are “member functions”
  • How to handle attributes?
  • Where is chare member data?

github.com/sxs-collaboration/spectre A SpECTRE With a New Face 10 / 21

slide-15
SLIDE 15

Entry Method Attributes

Possible ways of controlling attributes:

  • Inside entry method class:

struct EntryMethod0 { using attributes = charmxx ::AttrList < charmxx ::attrs::Inline >; /* apply function */

  • At call site:

charmxx ::invoke <MyEntryMethod1 , charmxx ::AttrList <charmxx ::attrs::Inline >>( my_proxy , arg0 , arg1 , std::move(arg2));

github.com/sxs-collaboration/spectre A SpECTRE With a New Face 11 / 21

slide-16
SLIDE 16

Member Data

  • Chares hold a TaggedTuple i.e. compile-time hash table
  • Tags to chare as template parameter, maybe:

charmxx ::Chare <charmxx ::TagList <ParticleCoordinate , ParticleVelocity >> my_chare{start_coord , start_velocity };

  • TaggedTuple passed to entry methods

github.com/sxs-collaboration/spectre A SpECTRE With a New Face 12 / 21

slide-17
SLIDE 17

Passing Member Data To Entry Methods

struct MyEntryMethod2 { template <class ... Tags > static void apply(charmxx :: TaggedTuple <Tags ...>& member_data , const double& delta_time) noexcept { const auto& vel = charmxx ::get <ParticleVelocity >( member_data); auto& coord = charmxx ::get <ParticleCoordinate >( member_data); coord += vel * delta_time; } };

github.com/sxs-collaboration/spectre A SpECTRE With a New Face 13 / 21

slide-18
SLIDE 18

Reducing Compilation Time 1/2

In MyEntryMethod2.hpp:

#include "UpdateCoordinate.hpp" struct MyEntryMethod2 { template <class ... Tags > static void apply(charmxx :: TaggedTuple <Tags ...>& member_data , const double& delta_time) noexcept { update_coordinate( charmxx ::get <ParticleCoordinate >( member_data), charmxx ::get <ParticleVelocity >( member_data), delta_time); } };

github.com/sxs-collaboration/spectre A SpECTRE With a New Face 14 / 21

slide-19
SLIDE 19

Reducing Compilation Time 2/2

In UpdateCoordinate.hpp:

void update_coordinate(double& coord , const double& vel , const double& delta_time); void update_coordinate(Vector& coord , const Vector& vel , const double& delta_time);

In UpdateCoordinate.cpp:

void update_coordinate(double& coord , const double& vel , const double& delta_time) { coord += vel * delta_time; } void update_coordinate(Vector& coord , const Vector& vel , const double& delta_time) { coord += vel * delta_time; }

github.com/sxs-collaboration/spectre A SpECTRE With a New Face 15 / 21

slide-20
SLIDE 20

Design Steps

1 Invoking entry methods 2 Creating chares 3 Reductions

github.com/sxs-collaboration/spectre A SpECTRE With a New Face 15 / 21

slide-21
SLIDE 21

Naming/Identifying Chares

Charm++ will supply class templates, need “names”

struct MyChareName { // Singleton , Array , Group , or Nodegroup using chare_type = charmxx ::Array; // For arrays must specify index: using array_index = MyAwesomeArrayIndex; // List of the tags that are member data using tags = charmxx ::TagList <ParticleCoordinate , ParticleVelocity >; // To put proxy into a TaggedTuple: using type = charmxx :: compute_type <chare_type , tags >; };

github.com/sxs-collaboration/spectre A SpECTRE With a New Face 16 / 21

slide-22
SLIDE 22

Creating Chares

Create using:

auto my_proxy = charmxx :: MyChareName >( start_coord , start_velocity); auto my_proxy2 = charmxx ::create <MyChareName2 >( my_proxy , start_coord , start_velocity);

  • create replaces ckNew
  • Chare name is also tag!

github.com/sxs-collaboration/spectre A SpECTRE With a New Face 17 / 21

slide-23
SLIDE 23

Bonus! Custom Array Indices

Can handle custom array indices more easily, e.g.

template <size_t VolumeDim > class ElementIndex { public: ElementIndex(const ElementId <VolumeDim >& id) noexcept; private: std::array <SegmentIndex , VolumeDim > segments_; };

ElementId indexes block, x, y, and z in domain

github.com/sxs-collaboration/spectre A SpECTRE With a New Face 18 / 21

slide-24
SLIDE 24

Design Steps

1 Invoking entry methods 2 Creating chares 3 Reductions

github.com/sxs-collaboration/spectre A SpECTRE With a New Face 18 / 21

slide-25
SLIDE 25

Reductions

  • Reductions become quite straight forward:

charmxx :: contribute_to_reduction < ProcessReducedProductOfDoublesEntryMethod >( my_send_double , array_proxy[my_index], target_proxy , charmxx :: Reduction :: product_double);

github.com/sxs-collaboration/spectre A SpECTRE With a New Face 19 / 21

slide-26
SLIDE 26

Reductions

  • Reductions become quite straight forward:

charmxx :: contribute_to_reduction < ProcessReducedProductOfDoublesEntryMethod >( my_send_double , array_proxy[my_index], target_proxy , charmxx :: Reduction :: product_double);

  • Reducing custom data also simpler
  • Supply generic data structure for custom reductions

charmxx :: ReductionData <int , std:: unordered_map <std::string , int >, std::vector <double >>;

github.com/sxs-collaboration/spectre A SpECTRE With a New Face 19 / 21

slide-27
SLIDE 27

Custom Reductions

Function to reduce custom data structure:

charmxx :: ReductionMsg* reduce_reduction_data( const int number_of_messages , charmxx :: ReductionMsg ** const msgs) noexcept { /* custom reduction function */ }

github.com/sxs-collaboration/spectre A SpECTRE With a New Face 20 / 21

slide-28
SLIDE 28

Custom Reductions

Function to reduce custom data structure:

charmxx :: ReductionMsg* reduce_reduction_data( const int number_of_messages , charmxx :: ReductionMsg ** const msgs) noexcept { /* custom reduction function */ }

Inside an entry method:

charmxx :: ReductionData <int , std:: unordered_map <std::string , int >, std::vector <int >> my_send_data{ 10, my_send_map , std::vector <int >{ array_index ,10,-8}}; charmxx :: contribute_to_reduction < &reduce_reduction_data , ProcessCustomReductionEntryMethod >( my_send_data , array_proxy[my_index], target_proxy);

github.com/sxs-collaboration/spectre A SpECTRE With a New Face 20 / 21

slide-29
SLIDE 29

Summary

  • Charm++ interface files replaced with basic metaprogramming
  • Users do not need to metaprogram
  • Large number of errors eliminated
  • Most remaining errors compile time
  • Integrate into Charm++ v7?

github.com/sxs-collaboration/spectre A SpECTRE With a New Face 21 / 21