Keyval and callbacks Rules and Behaviors. Background Keyvals are used for caching attributes on {COMM,TYPE,WIN} objects Discussion will focus on COMM.

Slides:



Advertisements
Similar presentations
Implementation and Verification of a Cache Coherence protocol using Spin Steven Farago.
Advertisements

Construction process lasts until coding and testing is completed consists of design and implementation reasons for this phase –analysis model is not sufficiently.
Composition CMSC 202. Code Reuse Effective software development relies on reusing existing code. Code reuse must be more than just copying code and changing.
Quick Sort, Shell Sort, Counting Sort, Radix Sort AND Bucket Sort
1 Design by Contract Building Reliable Software. 2 Software Correctness Correctness is a relative notion  A program is correct with respect to its specification.
C++ Sets and Multisets Set containers automatically sort their elements automatically. Multisets allow duplication of elements whereas sets do not. Usually,
INIT and FINALIZE issues Madrid, September 2013 Hybrid WG Jeff Squyres v0.6 – 26 Aug 2013.
PLAGIARISM, QUOTING, PARAPHRASING
CSC1016 Coursework Clarification Derek Mortimer March 2010.
1 Homework Turn in HW2 at start of next class. Starting Chapter 2 K&R. Read ahead. HW3 is on line. –Due: class 9, but a lot to do! –You may want to get.
Sub Programs To Solve a Problem, First Make It Simpler.
19: Protection1 PROTECTION Protection is the mechanism for controlling access to computer resources. Security concerns the physical integrity of the system.
Computer Programming and Basic Software Engineering 4. Basic Software Engineering 1 Writing a Good Program 4. Basic Software Engineering 3 October 2007.
Companion slides for The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit Concurrent Skip Lists.
1.1 CAS CS 460/660 Introduction to Database Systems File Organization Slides from UC Berkeley.
Operator Overloading 1. Introduction Let’s define a class for Complex numbers: class Complex { private: double real, image; public: Complex () : real(0.0),
Problem solving in project management
Apply Sub Procedures/Methods and User Defined Functions
Sage CRM Developers Course
Real-Time Concepts for Embedded Systems Author: Qing Li with Caroline Yao ISBN: CMPBooks.
MPI3 Hybrid Proposal Description
Retrievals & Projections Objectives of the Lecture : To consider retrieval actions from a DB; To consider using relational algebra for defining relations;
HIP API issues in base spec Tom Henderson IETF-59, March 3, 2004.
June 14, 2001Exception Handling in Java1 Richard S. Huntrods June 14, 2001 University of Calgary.
Nachos Phase 1 Code -Hints and Comments
1 JavaScript. 2 What’s wrong with JavaScript? A very powerful language, yet –Often hated –Browser inconsistencies –Misunderstood –Developers find it painful.
Testing Michael Ernst CSE 140 University of Washington.
Testing CSE 140 University of Washington 1. Testing Programming to analyze data is powerful It’s useless if the results are not correct Correctness is.
HTML5 Communication. The Setup Somewhere on the web, a server makes a ”service” available, that we wish to use in a web application The service may offer.
© Logicalis Group Using DB2/400 effectively. Data integrity facilities Traditional iSeries database usage Applications are responsible for data integrity.
Exceptions Handling Exceptionally Sticky Problems.
Low-Level Detailed Design SAD (Soft Arch Design) Mid-level Detailed Design Low-Level Detailed Design Design Finalization Design Document.
Test vs. inspection Part 2 Tor Stålhane. Testing and inspection A short data analysis.
10/10/2012ISC239 Isabelle Bichindaritz1 Physical Database Design.
Computer Studies (AL) Memory Management Virtual Memory I.
Documentation Dr. Andrew Wallace PhD BEng(hons) EurIng
Object Oriented Programming Elhanan Borenstein Lecture #3 copyrights © Elhanan Borenstein.
Build-A-Button Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Wednesday, October 8, 2003.
C Functions Three major differences between C and Java functions: –Functions are stand-alone entities, not part of objects they can be defined in a file.
CPSC 252 The Big Three Page 1 The “Big Three” Every class that has data members pointing to dynamically allocated memory must implement these three methods:
SIP working group IETF#70 Essential corrections Keith Drage.
More Distributed Garbage Collection DC4 Reference Listing Distributed Mark and Sweep Tracing in Groups.
IDNAbis and Security Protocols or Internationalization Issues with Short Strings John C Klensin SAAG – 26 July 2007.
Sending large message counts (The MPI_Count issue)
1 Becoming More Effective with C++ … Day Two Stanley B. Lippman
Testing CSE 160 University of Washington 1. Testing Programming to analyze data is powerful It’s useless (or worse!) if the results are not correct Correctness.
SIP PUBLISH Method Jonathan Rosenberg dynamicsoft.
Companion slides for The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit Concurrent Skip Lists.
MPI Communicator Assertions Jim Dinan Point-to-Point WG March 2015 MPI Forum Meeting.
Issues #1 and #3 Fault Tolerance Working Group December 2015 MPI Forum.
Capability Model & B2B – Draft for Discussion IBM Research – Haifa Moti Nisenson.
Slide title In CAPITALS 50 pt Slide subtitle 32 pt RTSP draft-ietf-mmusic-rfc2396bis-10 Magnus Westerlund Co-auhtors: Henning Schulzrinne, Rob Lanphier,
Session 7 Introduction to Inheritance. Accumulator Example a simple calculator app classes needed: –AdderApp - contains main –AddingFrame - GUI –CloseableFrame.
Extra Recitations Wednesday 19:40-22:30 FENS L055 (tomorrow!) Friday 13:40-16:30 FENS L063 Friday 17: :30 FENS L045 Friday 19:40-22:30 FENS G032.
Exceptions Lecture 11 COMP 401, Fall /25/2014.
1 Linked Lists Assignment What about assignment? –Suppose you have linked lists: List lst1, lst2; lst1.push_front( 35 ); lst1.push_front( 18 ); lst2.push_front(
© 2004 Microsoft Corporation. All rights reserved. 1 Processing IO Operations.
Classroom Management By: Amber Seguin. Hello Practicum Students, Whether this is your first or second practicum there are a few things every potential.
SQL Triggers, Functions & Stored Procedures Programming Operations.
Today… Modularity, or Writing Functions. Winter 2016CISC101 - Prof. McLeod1.
Companion slides for The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit Concurrent Skip Lists.
CSE 332: C++ Exceptions Motivation for C++ Exceptions Void Number:: operator/= (const double denom) { if (denom == 0.0) { // what to do here? } m_value.
1 Project 12: Cars from File. This is an extension of Project 11, Car Class You may use the posted solution for Project 11 as a starting point for this.
Handling Exceptionally Sticky Problems
OpenStorage API part II
This pointer, Dynamic memory allocation, Constructors and Destructor
Handling Exceptionally Sticky Problems
Promises.
Presentation transcript:

Keyval and callbacks Rules and Behaviors

Background Keyvals are used for caching attributes on {COMM,TYPE,WIN} objects Discussion will focus on COMM functions for convenience APIs: MPI_Comm_create_keyval MPI_Comm_free_keyval MPI_Comm_set_attr MPI_Comm_get_attr Callbacks MPI_Comm_copy_attr_function MPI_Comm_delete_attr_function

Behavior Create a key (global) that can subsequently be used to set/clear attributes on objects. Keys are represented by their key value (keyval) (page 286, line 7) Keyval is set to MPI_KEYVAL_INVALID by MPI_Comm_free_keyval 1 - * relationship between keys and attributes Attributes on objects reference the key, even if the key is freed (and its keyval set to MPI_KEYVAL_INVALID).

Callbacks Copy callback is invoked when an object is duplicated E.g. MPI_Comm_dup Delete callback is invoked when an object is freed E.g. MPI_Comm_free Callback takes ‘comm’ and ‘keyval’ as input parameter ‘oldcomm’ in copy, but for simplicity following will use ‘comm’ for both Delete callback harder to handle than copy callback Following slides focus (mostly) on delete callbacks

Ordering of delete callbacks MPI_Comm_free indicates delete callback called in arbitrary order Page 248, Line 27 MPI_Finalize indicates that attributes on MPI_COMM_SELF are deleted in reverse order from creation, despite behaving as-if MPI_Comm_free was called for MPI_COMM_SELF. Page 363, Line 17 Recommend: Make standard consistent Define ordering as reverse from creation Backward compatible

Are Keyvals Handles? They behave like handles MPI_Comm_free_keyval sets the keyval to MPI_KEYVAL_INVALID Similar to MPI_Comm_free sets comm to MPI_COMM_NULL They don’t have an associated handle type Standard defines it as ‘integer’ type MPI_KEYVAL_INVALID vs. MPI_COMM_NULL Can copy of keyval be used after MPI_Comm_free_keyval? Generally erroneous to use a handle after it has been freed Exception is MPI_Grequest_complete, which may be called (using a copy of the original handle value) after MPI_Request_free. Didn’t find any other exception Standard doesn’t clearly state anywhere that using stale handles is ‘erroneous’ Duh!

The Real Problem Standard does not specify what can (or cannot) be done in a callback i.e. nothing is forbidden, thus everything is valid Must tread lightly here, as we could break back-compat Standard does not specify if the ‘keyval’ param can be temporary i.e. for the duration/scope of the callback only Again, potential back-compat issues Standard does not specify if ‘keyval’ can be reused before ‘key’ is freed. Not forbidden, thus valid (despite introducing issues)

Scenario MPI_Comm_create_keyval( …, &keyval, …) Keyval = 3 MPI_Comm_set_attr( MPI_COMM_WORLD, keyval, attr_val ) MPI_Comm_free_keyval( &keyval ) Keyval = MPI_KEYVAL_INVALID MPI_Comm_dup( MPI_COMM_WORLD, &dup ) Copy callback is called – what is keyval param? MPI_KEYVAL_INVALID? 3? Something else? MPI_Comm_free( &dup ) Delete callback is called – what is keyval param? MPI_KEYVAL_INVALID? 3? Something else?

Calls from (delete) callbacks FunctionMPI_KEYVAL_INVALIDOriginal keyvalSomething Else Blocking comms/IOYYY Non-blocking comms/IOGTFO? MPI_Comm_free_keyvalN? Y MPI_Comm_get_attrN? Y MPI_Comm_set_attrN? Y MPI_Comm_delete_attrNDiff comm or diff keyval?Y (except same comm??) …

Communication or I/O Don’t need the keyval, so independent of whether keyval was freed Blocking probably OK, a bit strange though Non-blocking potentially problematic unless waiting in the callback Nasty if initiated form an attribute delete callback on MPI_COMM_SELF during MPI_Finalize

MPI_Comm_free_keyval OK for different comm and/or keyval (retrieved via extra_state or global?) E.g. Free keyval B from a callback for key A Can get messy if keyval was already freed Double free? Implementation must have a way to track whether keyval was freed Proper reference counting on key when callback unwinds Mitigated by using “something else” than original keyval keyval encodes that MPI_Comm_free_keyval is noop somehow

MPI_Comm_get_attr OK for different comm and/or keyval Unneccessary for same comm and keyval Attribute value is passed as input parameter Probably harmless

MPI_Comm_set_attr OK for copy callback Likely always wrong in delete callback Throw in MPI_THREAD_MULTIPLE for extra fun! Definitely wrong in delete callback for same comm Seriously messes with callback ordering requirements communciator is being freed, what’s the point?

MPI_Comm_delete_attr Probably OK for different comm and/or keyval Just plain wrong from a delete callback for same comm and keyval

Unwind Semantics If delete_fn fails, the associated MPI_*_FREE call fails Potentially nasty implications to ordering requirement for attribute callbacks if attributes can be set from delete callback If delete_fn succeeds, ordering would require newly added attributes to be deleted next If delete_fn fails, ordering would require newly added attributes to precede the failed attribute

Summary It’s like picking a scab… It’s pretty horrid with many corner cases Even if the keyval wasn’t freed Worse yet if the keyval was freed Fixing it can break existing apps Solution should minimize potential for back-compat Except egregious behavior

Recommendation Option 1 (Cleanest): MPI_Comm_free_keyval sets keyval to MPI_KEYVAL_INVALID, which will also be the value that is passed to the callbacks. Likely back-compat issues for lazy apps (e.g. PETc) Option 2 (Best back-compat): Document that keyval parameter to callbacks may not be the same as the keyval created by MPI_Comm_create_keyval if that keyval was freed with MPI_comm_free_keyval. Enable encoding ‘behavior’ in keyval, e.g. MPI_Comm_free_keyval is noop Applications can use ‘extra_state’ for context if needed Makes behavior if original keyval was freed rational Create either white list or black list of acceptable calls during callbacks Laborious Black list likely more reasonable given back-compat All I/O (comm or file) initiated during callback must be completed in callback Allows non-blocking, but with restrictions

Suggested Black List Only needed for delete callbacks? FunctionSame CommSame KeyvalBoth SameNeither Same MPI_Comm_set_attrNo MPI_Comm_delete_attrYes NoYes MPI_Comm_get_attrYes Yes (but silly)Yes