Capabilities and Limitations of Library-Based Software Transactional - - PowerPoint PPT Presentation

capabilities and limitations of library based software
SMART_READER_LITE
LIVE PREVIEW

Capabilities and Limitations of Library-Based Software Transactional - - PowerPoint PPT Presentation

Capabilities and Limitations of Library-Based Software Transactional Memory in C++ Luke Dalessandro, Virendra Marathe, Michael Spear Michael Scott University of Rochester cs.rochester.edu/research/synchronization TRANSACT August 2007 We Want


slide-1
SLIDE 1

Capabilities and Limitations of Library-Based Software Transactional Memory in C++

Luke Dalessandro, Virendra Marathe, Michael Spear Michael Scott University of Rochester cs.rochester.edu/research/synchronization TRANSACT August 2007

slide-2
SLIDE 2

We Want Language Support For Transactional Memory

  • Language support is appealing
  • Should make transactional memory easy to use
  • Many analysis benefits
  • etc
  • BUT
  • Lots of work to implement
  • High adoption costs
  • Unclear what it should look like (yet)

Luke Dalessandro 2

slide-3
SLIDE 3

In The Meantime

  • Maybe we can get by with library

implementation?

  • Low development overhead
  • Easily distributed
  • Unmatched flexibility
  • Reasonable performance
  • Most downsides relate to APIs
  • Complex, incompatible
  • Provide poor compile-time error detection

Luke Dalessandro 3

slide-4
SLIDE 4

Typical SW Library APIs

BEGIN_TRANSACTION; Node* curr = sentinel; while (curr != NULL) { if (curr->val >= v) break; curr = curr->next; } return ((curr != NULL) && (curr->val == v)); END_TRANSACTION; Luke Dalessandro 4

Holy Grail

slide-5
SLIDE 5

Typical SW Library APIs

BEGIN_TRANSACTION; Node* curr = sentinel; while (curr != NULL) { if (curr->val >= v) break; curr = curr->next; } return ((curr != NULL) && (curr->val == v)); END_TRANSACTION;

bool found; BEGIN_TRANSACTION(t); Node* curr = sentinel->open_RO(t); while (curr != NULL) { if (curr->val >= v) break; curr = curr->next->open_RO(t); } found = ((curr != NULL) && (curr->val == v)); END_TRANSACTION(t); return found;

Luke Dalessandro 4

Holy Grail Object-based with Indirection

slide-6
SLIDE 6

Typical SW Library APIs

BEGIN_TRANSACTION; Node* curr = sentinel; while (curr != NULL) { if (curr->val >= v) break; curr = curr->next; } return ((curr != NULL) && (curr->val == v)); END_TRANSACTION; Luke Dalessandro 4

bool found; BEGIN_TRANSACTION(t); found = false; Validator c_v; Node* curr = sentinel->open_RO(t, c_v); Node* n = curr->next; validate(c_v); curr = n->open_RO(t, c_v); while (curr != NULL) { long val = curr->val; validate(c_v); if (val >= v) break; n = curr->next; validate(c_v); ...

Holy Grail Object-based, No Indirection

slide-7
SLIDE 7

Typical SW Library APIs

BEGIN_TRANSACTION; Node* curr = sentinel; while (curr != NULL) { if (curr->val >= v) break; curr = curr->next; } return ((curr != NULL) && (curr->val == v)); END_TRANSACTION; bool found; BEGIN_TRANSACTION; found = false; Node* curr = sentinel; while (curr != NULL) { if (STM_READ_LONG(&curr->val) >= v) break; curr = (Node*)STM_READ_PTR(&curr->next); } found = ((curr != NULL) && (STM_READ_LONG(&curr->val) == v)); END_TRANSACTION; return found; Luke Dalessandro 4

Holy Grail Word-based

slide-8
SLIDE 8

Can Library TM Systems Suffice?

  • In The Short Term
  • Research community needs
  • TM implementation development and testing
  • Large application development (chicken and egg)
  • In The Long Term
  • Naive users
  • Current APIs: no and no
  • Better APIs: yes and no

Luke Dalessandro 5

slide-9
SLIDE 9

TM Hooks And Who Enforces Their Use

First Access Per Access Post Access DSTM RSTM Compiler N/A N/A TL2 N/A User User LibLTX Compiler N/A User

Luke Dalessandro 6

slide-10
SLIDE 10

RSTM2

  • Just an API, not an implementation!
  • Back end library implementation can be any

published C/C++ library TM

  • Current working implementations include RSTM,

~TL2, RTM, and several others

  • Evolved through the use of RSTM
  • RSTM was designed as an open platform to

experiment in C++

  • Originally adopted the DSTM interface

Luke Dalessandro 7

slide-11
SLIDE 11

RSTM2

Hook Mechanism Enforced By First Access Smart Pointers Compiler Per Access Smart Pointers Compiler Post Access Field Accessors Compiler*

Luke Dalessandro

*possible to circumvent

8

slide-12
SLIDE 12

Smart Pointers in C++

  • Overload operator->() and
  • perator*() to make objects act like

pointers.

template <class T> class smart_ptr { T* impl; public: T* operator->() { return impl; } T& operator*() { return *impl; } ... // const members, // etc... };

Luke Dalessandro 9

slide-13
SLIDE 13

Smart Pointers in RSTM2

  • API defines 4 types of smart pointers

State Name

  • perator->() returns

Shared sh_ptr N/A Readable rd_ptr const T* Writable wr_ptr T* Private un_ptr T*

Luke Dalessandro 10

slide-14
SLIDE 14

Accessors...

  • Macros generate accessors (get/set)

class Node { // sh_ptr<Node> next; GENERATE_FIELD(sh_ptr<Node>, next); //int val GENERATE_FIELD(int, val); }; wr_ptr<Node> curr(head); curr->set_val(10);

Luke Dalessandro 11

slide-15
SLIDE 15

And Validators

  • Getters take reference to smart

pointer

  • This provides object based libraries a

post access validation hook

Luke Dalessandro 12

// RSTM backend // rd_ptr caches object version on open rd_ptr<Node> curr(head); // accessor compares version on load sh_ptr<Node> n = curr->get_next(curr);

slide-16
SLIDE 16

Putting It Together

Luke Dalessandro 13

sh_ptr<Node> head; rd_ptr<Node> curr(head); curr = curr->get_next(curr); wr_ptr<Node> edit(curr); edit->set_val(10);

slide-17
SLIDE 17

Putting It Together

first access

Luke Dalessandro 13

sh_ptr<Node> head; rd_ptr<Node> curr(head); curr = curr->get_next(curr); wr_ptr<Node> edit(curr); edit->set_val(10);

slide-18
SLIDE 18

Putting It Together

first access per-access

Luke Dalessandro 13

sh_ptr<Node> head; rd_ptr<Node> curr(head); curr = curr->get_next(curr); wr_ptr<Node> edit(curr); edit->set_val(10);

slide-19
SLIDE 19

Putting It Together

per-access first access post access

Luke Dalessandro 13

sh_ptr<Node> head; rd_ptr<Node> curr(head); curr = curr->get_next(curr); wr_ptr<Node> edit(curr); edit->set_val(10);

slide-20
SLIDE 20

List Search With RSTM2

bool found; BEGIN_TRANSACTION; found = false; rd_ptr<Node> curr(sentinel); while (curr != NULL) { if (curr->get_val(curr) >= v) break; curr = curr->get_next(curr); } found = ((curr != NULL) && (curr->get_val(curr) == v)); END_TRANSACTION; return found;

Luke Dalessandro

BEGIN_TRANSACTION; Node* curr = sentinel; while (curr != NULL) { if (curr->val >= v) break; curr = curr->next; } return ((curr != NULL) && (curr->val == v)); END_TRANSACTION;

14

Holy Grail Any Library Type

slide-21
SLIDE 21

What have we gained?

  • Normalized interface
  • Write an app or benchmark once, test any library

implementation or feature you want

  • Automated code sharing between transactional and non-

transactional contexts with template metaprogramming

  • Clean enough for experts to use
  • Nearly no dependence on programmer

discipline (compiler enforced hooks)

  • Enables us to write non-trivial applications
  • Delaunay mesh generation
  • See papers on app [IISWC ’07], privatization [UR TR 915]

Luke Dalessandro 15

slide-22
SLIDE 22

API Annoyances

  • Arbitrary restrictions remain
  • this is not a smart pointer
  • No exceptions in shared object constructors
  • No nonlocal returns
  • Explicit transactional types (Node)
  • Programming awkwardness
  • Accessors an validators
  • Template based code sharing
  • Error messages are baffling
  • These could be solved with simple

compiler modifications

Luke Dalessandro 16

slide-23
SLIDE 23

More Fundamental Issues

  • Shared data is explicitly specified at
  • bject level
  • Requires program design from a shared object

perspective

  • Only shared objects revert on abort
  • This seems like the wrong semantics
  • Particularly annoying for simple loop indices
  • Many open research questions require

compiler level knowledge

  • eg. how much can be inferred about shared vs.

privatized data use?

Luke Dalessandro 17

slide-24
SLIDE 24

Conclusions

  • RSTM2 is suitable for short term needs
  • Allows write-once TM benchmarks
  • Simplifies large-scale application development
  • Good framework for investigating TM semantics
  • BUT it is not appropriate for naive users
  • Generic programming is complicated
  • Explicit use of 4 types of pointers too much
  • Annoyances are overwhelming
  • We feel that no pure library will suffice

long term (not surprising in retrospect)

Luke Dalessandro 18

slide-25
SLIDE 25

Future Work

  • Implement mappings to more back ends
  • Write more applications, benchmarks
  • Implement lightweight compiler support

to fix “the annoyances”

  • Investigation of TM semantics choices

and their consequences

Luke Dalessandro 19

slide-26
SLIDE 26

Thanks

  • The rest of the RSTM team:

Arrvindh Shriraman, Aaron Rolett, Sandhya Dwarkadas

  • Download RSTM2 and write your own

apps and benchmarks for the last time

  • http:/

/www.cs.rochester.edu/research/synchronization/

Luke Dalessandro 20