From 0c35d06692ac03b49a76a60b761ee8f848325825 Mon Sep 17 00:00:00 2001 From: Mohamad Chaarawi Date: Fri, 30 Aug 2013 17:35:18 -0500 Subject: [svn-r24091] Start adding infrastructure for Transaction and Read Context changes --- src/H5Ipublic.h | 2 + src/H5Pint.c | 49 ++++- src/H5Pprivate.h | 5 +- src/H5Ppublic.h | 12 ++ src/H5Prcapl.c | 131 ++++++++++++ src/H5Ptrspl.c | 131 ++++++++++++ src/H5RC.c | 462 +++++++++++++++++++++++++++++++++++++++++ src/H5RCprivate.h | 61 ++++++ src/H5RCpublic.h | 75 +++++++ src/H5TR.c | 606 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/H5TRprivate.h | 63 ++++++ src/H5TRpublic.h | 63 ++++++ src/Makefile.am | 2 +- src/Makefile.in | 28 +-- 14 files changed, 1673 insertions(+), 17 deletions(-) create mode 100644 src/H5Prcapl.c create mode 100644 src/H5Ptrspl.c create mode 100644 src/H5RC.c create mode 100644 src/H5RCprivate.h create mode 100644 src/H5RCpublic.h create mode 100644 src/H5TR.c create mode 100644 src/H5TRprivate.h create mode 100644 src/H5TRpublic.h diff --git a/src/H5Ipublic.h b/src/H5Ipublic.h index 02693f0..3c614c2 100644 --- a/src/H5Ipublic.h +++ b/src/H5Ipublic.h @@ -47,6 +47,8 @@ typedef enum H5I_type_t { H5I_VFL, /*type ID for virtual file layer */ H5I_VOL, /*type ID for virtual object layer */ H5I_EQ, /*type ID for Event Queue objects */ + H5I_RC, /*type ID for Read Context objects */ + H5I_TR, /*type ID for Transaction objects */ H5I_GENPROP_CLS, /*type ID for generic property list classes */ H5I_GENPROP_LST, /*type ID for generic property lists */ H5I_ERROR_CLASS, /*type ID for error classes */ diff --git a/src/H5Pint.c b/src/H5Pint.c index dfc6e2e..64d283c 100644 --- a/src/H5Pint.c +++ b/src/H5Pint.c @@ -122,7 +122,10 @@ hid_t H5P_CLS_ATTRIBUTE_CREATE_g = FAIL; hid_t H5P_CLS_OBJECT_COPY_g = FAIL; hid_t H5P_CLS_LINK_CREATE_g = FAIL; hid_t H5P_CLS_LINK_ACCESS_g = FAIL; -hid_t H5P_CLS_STRING_CREATE_g = FAIL; +hid_t H5P_CLS_STRING_CREATE_g = FAIL; +hid_t H5P_CLS_READ_CONTEXT_ACQUIRE_g = FAIL; +hid_t H5P_CLS_TRANSACTION_START_g = FAIL; +hid_t H5P_CLS_TRANSACTION_FINISH_g = FAIL; /* * Predefined property lists for each predefined class. These are initialized @@ -142,6 +145,9 @@ hid_t H5P_LST_ATTRIBUTE_CREATE_g = FAIL; hid_t H5P_LST_OBJECT_COPY_g = FAIL; hid_t H5P_LST_LINK_CREATE_g = FAIL; hid_t H5P_LST_LINK_ACCESS_g = FAIL; +hid_t H5P_LST_READ_CONTEXT_ACQUIRE_g = FAIL; +hid_t H5P_LST_TRANSACTION_START_g = FAIL; +hid_t H5P_LST_TRANSACTION_FINISH_g = FAIL; /* Root property list class library initialization object */ const H5P_libclass_t H5P_CLS_ROOT[1] = {{ @@ -210,6 +216,22 @@ const H5P_libclass_t H5P_CLS_TACC[1] = {{ NULL /* Class close callback info */ }}; +/* Transaction finish property list class library initialization object */ +/* (move to proper source code file when used for real) */ +const H5P_libclass_t H5P_CLS_TRFCC[1] = {{ + "transaction finish", /* Class name for debugging */ + H5P_TYPE_TRANSACTION_FINISH, /* Class type */ + &H5P_CLS_ROOT_g, /* Parent class ID */ + &H5P_CLS_TRANSACTION_FINISH_g, /* Pointer to class ID */ + &H5P_LST_TRANSACTION_FINISH_g, /* Pointer to default property list ID */ + NULL, /* Default property registration routine */ + NULL, /* Class creation callback */ + NULL, /* Class creation callback info */ + NULL, /* Class copy callback */ + NULL, /* Class copy callback info */ + NULL, /* Class close callback */ + NULL /* Class close callback info */ +}}; /* Library property list classes defined in other code modules */ H5_DLLVAR const H5P_libclass_t H5P_CLS_OCRT[1]; /* Object creation */ @@ -225,7 +247,9 @@ H5_DLLVAR const H5P_libclass_t H5P_CLS_DXFR[1]; /* Data transfer */ H5_DLLVAR const H5P_libclass_t H5P_CLS_FMNT[1]; /* File mount */ H5_DLLVAR const H5P_libclass_t H5P_CLS_ACRT[1]; /* Attribute creation */ H5_DLLVAR const H5P_libclass_t H5P_CLS_LCRT[1]; /* Link creation */ - +H5_DLLVAR const H5P_libclass_t H5P_CLS_RCACC[1]; /* Read Context acquire */ +H5_DLLVAR const H5P_libclass_t H5P_CLS_TRSCC[1]; /* Transaction start */ +//H5_DLLVAR const H5P_libclass_t H5P_CLS_TRFCC[1]; /* Transaction finish */ /*****************************/ /* Library Private Variables */ @@ -261,6 +285,9 @@ static H5P_libclass_t const * const init_class[] = { H5P_CLS_TCRT, /* Datatype creation */ H5P_CLS_TACC, /* Datatype access */ H5P_CLS_ACRT, /* Attribute creation */ + H5P_CLS_RCACC, /* Read Context acquire */ + H5P_CLS_TRSCC, /* Transaction start */ + H5P_CLS_TRFCC, /* Transaction finish */ H5P_CLS_LCRT /* Link creation */ }; @@ -582,6 +609,9 @@ H5P_term_interface(void) H5P_LST_OBJECT_COPY_g = H5P_LST_LINK_CREATE_g = H5P_LST_LINK_ACCESS_g = + H5P_LST_READ_CONTEXT_ACQUIRE_g = + H5P_LST_TRANSACTION_START_g = + H5P_LST_TRANSACTION_FINISH_g = H5P_LST_FILE_MOUNT_g = (-1); } /* end if */ } /* end if */ @@ -608,6 +638,9 @@ H5P_term_interface(void) H5P_CLS_OBJECT_COPY_g = H5P_CLS_LINK_CREATE_g = H5P_CLS_LINK_ACCESS_g = + H5P_CLS_READ_CONTEXT_ACQUIRE_g = + H5P_CLS_TRANSACTION_START_g = + H5P_CLS_TRANSACTION_FINISH_g = H5P_CLS_FILE_MOUNT_g = (-1); } /* end if */ } /* end if */ @@ -5135,6 +5168,18 @@ H5P__new_plist_of_type(H5P_plist_type_t type) class_id = H5P_CLS_LINK_ACCESS_g; break; + case H5P_TYPE_READ_CONTEXT_ACQUIRE: + class_id = H5P_CLS_READ_CONTEXT_ACQUIRE_g; + break; + + case H5P_TYPE_TRANSACTION_START: + class_id = H5P_CLS_TRANSACTION_START_g; + break; + + case H5P_TYPE_TRANSACTION_FINISH: + class_id = H5P_CLS_TRANSACTION_FINISH_g; + break; + case H5P_TYPE_USER: /* shut compiler warnings up */ case H5P_TYPE_ROOT: case H5P_TYPE_MAX_TYPE: diff --git a/src/H5Pprivate.h b/src/H5Pprivate.h index 93b57ef..f258357 100644 --- a/src/H5Pprivate.h +++ b/src/H5Pprivate.h @@ -67,7 +67,10 @@ typedef enum H5P_plist_type_t { H5P_TYPE_ATTRIBUTE_CREATE = 14, H5P_TYPE_OBJECT_COPY = 15, H5P_TYPE_LINK_CREATE = 16, - H5P_TYPE_LINK_ACCESS = 17, + H5P_TYPE_READ_CONTEXT_ACQUIRE = 17, + H5P_TYPE_TRANSACTION_START = 18, + H5P_TYPE_TRANSACTION_FINISH = 19, + H5P_TYPE_LINK_ACCESS = 20, H5P_TYPE_MAX_TYPE } H5P_plist_type_t; diff --git a/src/H5Ppublic.h b/src/H5Ppublic.h index 882b195..e395f22 100644 --- a/src/H5Ppublic.h +++ b/src/H5Ppublic.h @@ -69,6 +69,9 @@ #define H5P_OBJECT_COPY (H5OPEN H5P_CLS_OBJECT_COPY_g) #define H5P_LINK_CREATE (H5OPEN H5P_CLS_LINK_CREATE_g) #define H5P_LINK_ACCESS (H5OPEN H5P_CLS_LINK_ACCESS_g) +#define H5P_RC_ACQUIRE (H5OPEN H5P_CLS_READ_CONTEXT_ACQUIRE_g) +#define H5P_TR_START (H5OPEN H5P_CLS_TRANSACTION_START_g) +#define H5P_TR_FINISH (H5OPEN H5P_CLS_TRANSACTION_FINISH_g) /* * The library's default property lists @@ -87,6 +90,9 @@ #define H5P_OBJECT_COPY_DEFAULT (H5OPEN H5P_LST_OBJECT_COPY_g) #define H5P_LINK_CREATE_DEFAULT (H5OPEN H5P_LST_LINK_CREATE_g) #define H5P_LINK_ACCESS_DEFAULT (H5OPEN H5P_LST_LINK_ACCESS_g) +#define H5P_RC_ACQUIRE_DEFAULT (H5OPEN H5P_LST_READ_CONTEXT_ACQUIRE_g) +#define H5P_TR_START_DEFAULT (H5OPEN H5P_LST_TRANSACTION_START_g) +#define H5P_TR_FINISH_DEFAULT (H5OPEN H5P_LST_TRANSACTION_FINISH_g) /* Common creation order flags (for links in groups and attributes on objects) */ #define H5P_CRT_ORDER_TRACKED 0x0001 @@ -190,6 +196,9 @@ H5_DLLVAR hid_t H5P_CLS_ATTRIBUTE_CREATE_g; H5_DLLVAR hid_t H5P_CLS_OBJECT_COPY_g; H5_DLLVAR hid_t H5P_CLS_LINK_CREATE_g; H5_DLLVAR hid_t H5P_CLS_LINK_ACCESS_g; +H5_DLLVAR hid_t H5P_CLS_READ_CONTEXT_ACQUIRE_g; +H5_DLLVAR hid_t H5P_CLS_TRANSACTION_START_g; +H5_DLLVAR hid_t H5P_CLS_TRANSACTION_FINISH_g; /* Default roperty list IDs */ /* (Internal to library, do not use! Use macros above) */ @@ -207,6 +216,9 @@ H5_DLLVAR hid_t H5P_LST_ATTRIBUTE_CREATE_g; H5_DLLVAR hid_t H5P_LST_OBJECT_COPY_g; H5_DLLVAR hid_t H5P_LST_LINK_CREATE_g; H5_DLLVAR hid_t H5P_LST_LINK_ACCESS_g; +H5_DLLVAR hid_t H5P_LST_READ_CONTEXT_ACQUIRE_g; +H5_DLLVAR hid_t H5P_LST_TRANSACTION_START_g; +H5_DLLVAR hid_t H5P_LST_TRANSACTION_FINISH_g; /*********************/ /* Public Prototypes */ diff --git a/src/H5Prcapl.c b/src/H5Prcapl.c new file mode 100644 index 0000000..590d9b5 --- /dev/null +++ b/src/H5Prcapl.c @@ -0,0 +1,131 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/*------------------------------------------------------------------------- + * + * Created: H5Prcapl.c + * August 2013 + * Mohamad Chaarawi + * + * Purpose: Read Context Acquire property list class routines + * + *------------------------------------------------------------------------- + */ + +/****************/ +/* Module Setup */ +/****************/ +#define H5P_PACKAGE /*suppress error about including H5Ppkg */ + + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Ppkg.h" /* Property lists */ +#include "H5RCprivate.h" /* Read Context */ + +/****************/ +/* Local Macros */ +/****************/ + +/* ========= Read Context properties ============ */ +/* Definitions for Container Version being Acquired */ +#define H5RC_ACQUIRE_CV_REQUEST_SIZE sizeof(H5RC_request_t) +#define H5RC_ACQUIRE_CV_REQUEST_DEF H5RC_EXACT +#define H5RC_ACQUIRE_CV_REQUEST_ENC H5P__encode_uint8_t +#define H5RC_ACQUIRE_CV_REQUEST_DEC H5P__decode_uint8_t + +/******************/ +/* Local Typedefs */ +/******************/ + + +/********************/ +/* Package Typedefs */ +/********************/ + + +/********************/ +/* Local Prototypes */ +/********************/ + +/* Property class callbacks */ +static herr_t H5P__rcacc_reg_prop(H5P_genclass_t *pclass); + + +/*********************/ +/* Package Variables */ +/*********************/ + +/* Read Context acquire property list class library initialization object */ +const H5P_libclass_t H5P_CLS_RCACC[1] = {{ + "read context acquire", /* Class name for debugging */ + H5P_TYPE_READ_CONTEXT_ACQUIRE, /* Class type */ + &H5P_CLS_ROOT_g, /* Parent class ID */ + &H5P_CLS_READ_CONTEXT_ACQUIRE_g, /* Pointer to class ID */ + &H5P_LST_READ_CONTEXT_ACQUIRE_g, /* Pointer to default property list ID */ + H5P__rcacc_reg_prop, /* Default property registration routine */ + NULL, /* Class creation callback */ + NULL, /* Class creation callback info */ + NULL, /* Class copy callback */ + NULL, /* Class copy callback info */ + NULL, /* Class close callback */ + NULL /* Class close callback info */ +}}; + + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + + +/*******************/ +/* Local Variables */ +/*******************/ + + + +/*------------------------------------------------------------------------- + * Function: H5P__rcacc_reg_prop + * + * Purpose: Register the read context acquire property list class's + * properties + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Mohamad Chaarawi + * August 2013 + *------------------------------------------------------------------------- + */ +static herr_t +H5P__rcacc_reg_prop(H5P_genclass_t *pclass) +{ + H5RC_request_t acquire_req = H5RC_ACQUIRE_CV_REQUEST_DEF; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Register the size of raw data chunk cache (elements) */ + if(H5P_register_real(pclass, H5RC_ACQUIRE_CV_REQUEST_NAME, H5RC_ACQUIRE_CV_REQUEST_SIZE, &acquire_req, + NULL, NULL, NULL, H5RC_ACQUIRE_CV_REQUEST_ENC, H5RC_ACQUIRE_CV_REQUEST_DEC, + NULL, NULL, NULL, NULL) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__trscc_reg_prop() */ diff --git a/src/H5Ptrspl.c b/src/H5Ptrspl.c new file mode 100644 index 0000000..aba5b3c --- /dev/null +++ b/src/H5Ptrspl.c @@ -0,0 +1,131 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/*------------------------------------------------------------------------- + * + * Created: H5Ptrspl.c + * August 2013 + * Mohamad Chaarawi + * + * Purpose: Transaction Start property list class routines + * + *------------------------------------------------------------------------- + */ + +/****************/ +/* Module Setup */ +/****************/ +#define H5P_PACKAGE /*suppress error about including H5Ppkg */ + + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Ppkg.h" /* Property lists */ +#include "H5TRprivate.h" /* Read Context */ + +/****************/ +/* Local Macros */ +/****************/ + +/* ========= Read Context properties ============ */ +/* Definitions for Transaction being started */ +#define H5TR_START_NUM_PEERS_SIZE sizeof(unsigned) +#define H5TR_START_NUM_PEERS_DEF 0 +#define H5TR_START_NUM_PEERS_ENC H5P__encode_unsigned +#define H5TR_START_NUM_PEERS_DEC H5P__decode_unsigned + +/******************/ +/* Local Typedefs */ +/******************/ + + +/********************/ +/* Package Typedefs */ +/********************/ + + +/********************/ +/* Local Prototypes */ +/********************/ + +/* Property class callbacks */ +static herr_t H5P__trscc_reg_prop(H5P_genclass_t *pclass); + + +/*********************/ +/* Package Variables */ +/*********************/ + +/* Transaction start property list class library initialization object */ +const H5P_libclass_t H5P_CLS_TRSCC[1] = {{ + "transaction start", /* Class name for debugging */ + H5P_TYPE_TRANSACTION_START, /* Class type */ + &H5P_CLS_ROOT_g, /* Parent class ID */ + &H5P_CLS_TRANSACTION_START_g, /* Pointer to class ID */ + &H5P_LST_TRANSACTION_START_g, /* Pointer to default property list ID */ + H5P__trscc_reg_prop, /* Default property registration routine */ + NULL, /* Class creation callback */ + NULL, /* Class creation callback info */ + NULL, /* Class copy callback */ + NULL, /* Class copy callback info */ + NULL, /* Class close callback */ + NULL /* Class close callback info */ +}}; + + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + + +/*******************/ +/* Local Variables */ +/*******************/ + + + +/*------------------------------------------------------------------------- + * Function: H5P__trscc_reg_prop + * + * Purpose: Register the transaction start property list class's + * properties + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Mohamad Chaarawi + * August 2013 + *------------------------------------------------------------------------- + */ +static herr_t +H5P__trscc_reg_prop(H5P_genclass_t *pclass) +{ + unsigned num_peers = H5TR_START_NUM_PEERS_DEF; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Register the size of raw data chunk cache (elements) */ + if(H5P_register_real(pclass, H5TR_START_NUM_PEERS_NAME, H5TR_START_NUM_PEERS_SIZE, &num_peers, + NULL, NULL, NULL, H5TR_START_NUM_PEERS_ENC, H5TR_START_NUM_PEERS_DEC, + NULL, NULL, NULL, NULL) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__trscc_reg_prop() */ diff --git a/src/H5RC.c b/src/H5RC.c new file mode 100644 index 0000000..f07cedb --- /dev/null +++ b/src/H5RC.c @@ -0,0 +1,462 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Mohamad Chaarawi + * August, 2013 + * + * Purpose: Read Context APIs to support Exascale FastForward + * functionality. + * + */ + + +/****************/ +/* Module Setup */ +/****************/ + +/* Interface initialization */ +#define H5_INTERFACE_INIT_FUNC H5RC_init_interface + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5EQprivate.h" /* Event Queues */ +#include "H5RCprivate.h" /* Read Contexts */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5VLprivate.h" /* VOL plugins */ + + +/****************/ +/* Local Macros */ +/****************/ + + +/******************/ +/* Local Typedefs */ +/******************/ + + +/********************/ +/* Local Prototypes */ +/********************/ + + +/*********************/ +/* Package Variables */ +/*********************/ + + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + + +/*******************/ +/* Local Variables */ +/*******************/ + +/* Declare a free list to manage the H5RC_t struct */ +H5FL_DEFINE(H5RC_t); + +/* Dataspace ID class */ +static const H5I_class_t H5I_RC_CLS[1] = {{ + H5I_RC, /* ID class value */ + 0, /* Class flags */ + 64, /* Minimum hash size for class */ + 2, /* # of reserved IDs for class */ + NULL, /* Callback routine for closing objects of this class */ + (H5I_free2_t)H5RC_close /* Callback routine for closing auxilary objects of this class */ +}}; + + + +/*------------------------------------------------------------------------- + * Function: H5RC_init + * + * Purpose: Initialize the interface from some other package. + * + * Return: Success: non-negative + * Failure: negative + * + * Programmer: Mohamad Chaarawi + * August 2013 + * + *------------------------------------------------------------------------- + */ +herr_t +H5RC_init(void) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + /* FUNC_ENTER() does all the work */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5RC_init() */ + + +/*-------------------------------------------------------------------------- +NAME + H5RC_init_interface -- Initialize interface-specific information +USAGE + herr_t H5RC_init_interface() + +RETURNS + Non-negative on success/Negative on failure +DESCRIPTION + Initializes any interface-specific data or routines. + +--------------------------------------------------------------------------*/ +static herr_t +H5RC_init_interface(void) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + /* Initialize the atom group for the RC IDs */ + if(H5I_register_type(H5I_RC_CLS) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize interface") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5RC_init_interface() */ + + +/*-------------------------------------------------------------------------- + NAME + H5RC_term_interface + PURPOSE + Terminate various H5RC objects + USAGE + void H5RC_term_interface() + RETURNS + Non-negative on success/Negative on failure + DESCRIPTION + Release the atom group and any other resources allocated. + GLOBAL VARIABLES + COMMENTS, BUGS, ASSUMPTIONS + Can't report errors... + EXAMPLES + REVISION LOG +--------------------------------------------------------------------------*/ +int +H5RC_term_interface(void) +{ + int n = 0; + + FUNC_ENTER_NOAPI_NOINIT_NOERR + + if(H5_interface_initialize_g) { + if((n = H5I_nmembers(H5I_RC))) { + H5I_clear_type(H5I_RC, FALSE, FALSE); + } /* end if */ + else { + /* Free data types */ + H5I_dec_type_ref(H5I_RC); + + /* Shut down interface */ + H5_interface_initialize_g = 0; + n = 1; /*H5I*/ + } /* end else */ + } /* end if */ + + FUNC_LEAVE_NOAPI(n) +} /* end H5RC_term_interface() */ + + +/*------------------------------------------------------------------------- + * Function: H5Pset_rcapl_version_request + * + * Purpose: Set the request type for acquring the container version, + * whether it has to be exactly the one requested (H5RC_EXACT), + * the lowest available greater than the one requested if it is + * not available (H5RC_NEXT), or the last one available ((H5RC_LAST). + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Mohamad Chaarawi + * August 2013 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Pset_rcapl_version_request(hid_t rcapl_id, H5RC_request_t acquire_req) +{ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ + + FUNC_ENTER_API(FAIL) + + if(H5RC_EXACT > acquire_req || H5RC_LAST < acquire_req) + HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "Acquire request can be either H5RC_EXACT, H5RC_NEXT, or H5RC_LAST"); + + /* Get the plist structure */ + if(NULL == (plist = H5P_object_verify(rcapl_id, H5P_RC_ACQUIRE))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); + + /* Set property */ + if(H5P_set(plist, H5RC_ACQUIRE_CV_REQUEST_NAME, &acquire_req) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET,FAIL, "can't set acquire request"); + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Pset_rcapl_version_request() */ + + +/*------------------------------------------------------------------------- + * Function: H5RCcreate + * + * Purpose: Wraps an hid_t around a container version and a file ID. + * The user is responsible for making sure the container version + * is acquired. + * + * Return: Success: The ID for a new read context. + * Failure: FAIL + * + * Programmer: Mohamad Chaarawi + * August 2013 + * + *------------------------------------------------------------------------- + */ +hid_t +H5RCcreate(hid_t file_id, uint64_t c_version) +{ + void *file = NULL; + H5VL_t *vol_plugin = NULL; + H5RC_t *rc = NULL; + hid_t ret_value; + + FUNC_ENTER_API(FAIL) + + /* get the file object */ + if(NULL == (file = (void *)H5I_object_verify(file_id, H5I_FILE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") + /* get the plugin pointer */ + if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(file_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information") + + /* create a new read context object */ + if(NULL == (rc = H5RC_create(file, c_version))) + HGOTO_ERROR(H5E_SYM, H5E_CANTCREATE, FAIL, "unable to create read context") + + /* Get an atom for the event queue with the VOL information as the auxilary struct*/ + if((ret_value = H5I_register2(H5I_RC, rc, vol_plugin, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize read context handle") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5RCcreate() */ + + +/*------------------------------------------------------------------------- + * Function: H5RC_create + * + * Purpose: Private routine for H5RCcreate + * + * Return: Success: RC structure + * Failure: NULL + * + * Programmer: Mohamad Chaarawi + * August 2013 + * + *------------------------------------------------------------------------- + */ +H5RC_t * +H5RC_create(void *file, uint64_t c_version) +{ + void *file = NULL; + H5VL_t *vol_plugin = NULL; + H5RC_t *rc = NULL; + H5RC_t *ret_value = NULL; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + /* allocate read context struct */ + if(NULL == (rc = H5FL_CALLOC(H5RC_t))) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, NULL, "can't allocate top read context structure") + + rc->file = file; + rc->c_version = c_version; + + /* set return value */ + ret_value = rc; + +done: + if(!ret_value && rc) + rc = H5FL_FREE(H5RC_t, rc); + + FUNC_LEAVE_API(ret_value) +} /* end H5RC_create() */ + +hid_t +H5RCacquire(hid_t file_id, /*IN/OUT*/ uint64_t *c_version, + hid_t rcapl_id, hid_t eq_id) +{ + void *file = NULL; + H5VL_t *vol_plugin = NULL; + H5RC_t *rc = NULL; + H5_priv_request_t *request = NULL; /* private request struct inserted in event queue */ + void **req = NULL; /* pointer to plugin generate requests (Stays NULL if plugin does not support async */ + hid_t ret_value; + + FUNC_ENTER_API(FAIL) + + /* get the file object */ + if(NULL == (file = (void *)H5I_object_verify(file_id, H5I_FILE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") + /* get the plugin pointer */ + if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(file_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information") + + /* Get correct property list */ + if(H5P_DEFAULT == rcapl_id) + rcapl_id = H5P_RC_ACQUIRE_DEFAULT; + else + if(TRUE != H5P_isa_class(rcapl_id, H5P_RC_ACQUIRE)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not read context acquire property list") + + /* create a new read context object with the provided container + version. The container version associated with the RC object + might be changed if the version is not available for read. */ + if(NULL == (rc = H5RC_create(file, *c_version))) + HGOTO_ERROR(H5E_SYM, H5E_CANTCREATE, FAIL, "unable to create read context") + /* Get an atom for the event queue with the VOL information as the auxilary struct*/ + if((ret_value = H5I_register2(H5I_RC, rc, vol_plugin, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize read context handle") + + if(eq_id != H5_EVENT_QUEUE_NULL) { + /* create the private request */ + if(NULL == (request = (H5_priv_request_t *)H5MM_calloc(sizeof(H5_priv_request_t)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); + request->req = NULL; + req = &request->req; + request->next = NULL; + request->vol_plugin = vol_plugin; + } + + if(H5VL_iod_rc_acquire(file, rc, req) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "failed to request a read context on container"); + + if(request && *req) { + if(H5EQinsert(eq_id, request) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "failed to insert request in event queue"); + } + +done: + FUNC_LEAVE_API(ret_value) +} + +herr_t +H5RCrelease(hid_t rc_id , hid_t eq_id) +{ + H5RC_t *rc = NULL; + H5_priv_request_t *request = NULL; /* private request struct inserted in event queue */ + void **req = NULL; /* pointer to plugin generate requests (Stays NULL if plugin does not support async */ + herr_t ret_value; + + FUNC_ENTER_API(FAIL) + H5TRACE2("e", "ii", rc_id, eq_id); + + /* get the RC object */ + if(NULL == (rc = (H5RC_t *)H5I_object_verify(rc_id, H5I_RC))) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a Read Context ID") + + if(eq_id != H5_EVENT_QUEUE_NULL) { + /* create the private request */ + if(NULL == (request = (H5_priv_request_t *)H5MM_calloc(sizeof(H5_priv_request_t)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); + request->req = NULL; + req = &request->req; + request->next = NULL; + request->vol_plugin = vol_plugin; + } + + if(H5VL_iod_rc_release(rc, req) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "failed to request a release on a read context on container"); + + if(request && *req) { + if(H5EQinsert(eq_id, request) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "failed to insert request in event queue"); + } + +done: + FUNC_LEAVE_API(ret_value) +} + + +/*------------------------------------------------------------------------- + * Function: H5RCclose + * + * Purpose: Closes the specified read context ID. The ID will no longer be + * valid for accessing the read context. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Mohamad Chaarawi + * August 2013 + * + *------------------------------------------------------------------------- + */ +herr_t +H5RCclose(hid_t rc_id) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE1("e", "i", rc_id); + + /* Check args */ + if(NULL == H5I_object_verify(rc_id,H5I_RC)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an read context ID") + + if(H5I_dec_app_ref(rc_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close read context") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5RCclose() */ + + +/*------------------------------------------------------------------------- + * Function: H5RC_close + * + * Purpose: Closes the specified read context ID. The ID will no longer be + * valid for accessing the read context. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Mohamad Chaarawi + * August 2013 + * + *------------------------------------------------------------------------- + */ +herr_t +H5RC_close(H5RC_t *rc) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + + rc = H5FL_FREE(H5RC_t, rc); + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5RC_close() */ + diff --git a/src/H5RCprivate.h b/src/H5RCprivate.h new file mode 100644 index 0000000..e4ffa75 --- /dev/null +++ b/src/H5RCprivate.h @@ -0,0 +1,61 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * This file contains private information about the H5RC module + */ +#ifndef _H5RCprivate_H +#define _H5RCprivate_H + +/* Include package's public header */ +#include "H5RCpublic.h" + +/* Private headers needed by this file */ +#include "H5private.h" /* Generic Functions */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5VLprivate.h" /* VOL plugins */ + +/**************************/ +/* Library Private Macros */ +/**************************/ + +/****************************/ +/* Library Private Typedefs */ +/****************************/ +/* the client Read Context struct */ +typedef struct H5RC_t { + void *file; + uint64_t c_version; +} H5RC_t; + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + +/******************************/ +/* Library Private Prototypes */ +/******************************/ +#if 0 +herr_t H5RC_init(void); + +/* API wrappers */ +H5_DLL H5RC_t *H5RC_create(void *file, uint64_t c_version); +H5_DLL herr_t H5RC_close(H5RC_t *rc); + +H5_DLL herr_t H5VL_iod_rc_acquire(H5VL_iod_file_t *file, H5RC_t *rc, void **req); +H5_DLL herr_t H5VL_iod_rc_release(H5RC_t *rc, void **req); +#endif + +#endif /* _H5RCprivate_H */ diff --git a/src/H5RCpublic.h b/src/H5RCpublic.h new file mode 100644 index 0000000..e6083e3 --- /dev/null +++ b/src/H5RCpublic.h @@ -0,0 +1,75 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * This file contains function prototypes for each exported function in the + * H5RC module. + */ +#ifndef _H5RCpublic_H +#define _H5RCpublic_H + +/* System headers needed by this file */ + +/* Public headers needed by this file */ +#include "H5public.h" +#include "H5Ipublic.h" + +/*****************/ +/* Public Macros */ +/*****************/ +#define H5RC_ACQUIRE_CV_REQUEST_NAME "acquire_request_name" + +/*******************/ +/* Public Typedefs */ +/*******************/ +typedef enum H5RC_request_t{ + H5RC_EXACT, /* default */ + H5RC_NEXT, + H5RC_LAST +} H5RC_request_t; + +/********************/ +/* Public Variables */ +/********************/ + + +#ifdef __cplusplus +extern "C" { +#endif + +/*********************/ +/* Public Prototypes */ +/*********************/ + +/* API wrappers */ +H5_DLL hid_t H5RCcreate(hid_t file_id, uint64_t container_version); +H5_DLL hid_t H5RCacquire(hid_t file_id, /*IN/OUT*/ uint64_t *container_version, + hid_t rcapl_id, hid_t eq_id); +H5_DLL herr_t H5RCrelease(hid_t rc_id , hid_t eq_id); +H5_DLL herr_t H5RCclose(hid_t rc_id); + +H5_DLL herr_t H5Pset_rcapl_version_request(hid_t rcapl_id, H5RC_request_t acquire_req); + +#if 0 +/* Those are not set for now */ +H5_DLL herr_t H5Fskip_trans(hid_t file_id, uint64_t start_trans_num, uint64_t count, hid_t eq_id); +H5_DLL herr_t H5Fpersist(hid_t file_id, uint64_t rc_num, hid_t eq_id); +H5_DLL herr_t H5Fsnapshot(hid_t file_id, uint64_t container_version, + const char* snapshot_name, hid_t eq_id); +#endif + +#ifdef __cplusplus +} +#endif +#endif /* _H5RCpublic_H */ diff --git a/src/H5TR.c b/src/H5TR.c new file mode 100644 index 0000000..d46823b --- /dev/null +++ b/src/H5TR.c @@ -0,0 +1,606 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Mohamad Chaarawi + * August, 2013 + * + * Purpose: Transaction APIs to support Exascale FastForward + * functionality. + * + */ + + +/****************/ +/* Module Setup */ +/****************/ + +/* Interface initialization */ +#define H5_INTERFACE_INIT_FUNC H5TR_init_interface + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5TRprivate.h" /* Transactions */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5VLprivate.h" /* VOL plugins */ + + +/****************/ +/* Local Macros */ +/****************/ + + +/******************/ +/* Local Typedefs */ +/******************/ + + +/********************/ +/* Local Prototypes */ +/********************/ + + +/*********************/ +/* Package Variables */ +/*********************/ + + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + + +/*******************/ +/* Local Variables */ +/*******************/ + +/* Declare a free list to manage the H5TR_t struct */ +H5FL_DEFINE(H5TR_t); + +/* Dataspace ID class */ +static const H5I_class_t H5I_TR_CLS[1] = {{ + H5I_TR, /* ID class value */ + 0, /* Class flags */ + 64, /* Minimum hash size for class */ + 2, /* # of reserved IDs for class */ + NULL, /* Callback routine for closing objects of this class */ + (H5I_free2_t)H5TR_close /* Callback routine for closing auxilary objects of this class */ +}}; + + + +/*------------------------------------------------------------------------- + * Function: H5TR_init + * + * Purpose: Initialize the interface from some other package. + * + * Return: Success: non-negative + * Failure: negative + * + * Programmer: Mohamad Chaarawi + * August 2013 + * + *------------------------------------------------------------------------- + */ +herr_t +H5TR_init(void) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + /* FUNC_ENTER() does all the work */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5TR_init() */ + + +/*-------------------------------------------------------------------------- +NAME + H5TR_init_interface -- Initialize interface-specific information +USAGE + herr_t H5TR_init_interface() + +RETURNS + Non-negative on success/Negative on failure +DESCRIPTION + Initializes any interface-specific data or routines. + +--------------------------------------------------------------------------*/ +static herr_t +H5TR_init_interface(void) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + /* Initialize the atom group for the TR IDs */ + if(H5I_register_type(H5I_TR_CLS) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize interface") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5TR_init_interface() */ + + +/*-------------------------------------------------------------------------- + NAME + H5TR_term_interface + PURPOSE + Terminate various H5TR objects + USAGE + void H5TR_term_interface() + RETURNS + Non-negative on success/Negative on failure + DESCRIPTION + Release the atom group and any other resources allocated. + GLOBAL VARIABLES + COMMENTS, BUGS, ASSUMPTIONS + Can't report errors... + EXAMPLES + REVISION LOG +--------------------------------------------------------------------------*/ +int +H5TR_term_interface(void) +{ + int n = 0; + + FUNC_ENTER_NOAPI_NOINIT_NOERR + + if(H5_interface_initialize_g) { + if((n = H5I_nmembers(H5I_TR))) { + H5I_clear_type(H5I_TR, FALSE, FALSE); + } /* end if */ + else { + /* Free data types */ + H5I_dec_type_ref(H5I_TR); + + /* Shut down interface */ + H5_interface_initialize_g = 0; + n = 1; /*H5I*/ + } /* end else */ + } /* end if */ + + FUNC_LEAVE_NOAPI(n) +} /* end H5TR_term_interface() */ + + +/*------------------------------------------------------------------------- + * Function: H5Pset_trspl_num_peers + * + * Purpose: Set the number of peers that will call H5TRstart for a + * transaction. If num_peers=0, the application has appointed a + * transaction leader to signal the start and finish of the + * transaction, and to coordinate with processes participating in the + * transaction regarding when they can begin updating and when their + * updates are done. When this is the case, only one process (the + * transaction leader) can call H5TRstart and H5TRfinish for the given + * transaction_num. This mode of operation is typical for + * tightly-coupled applications. If num_peers>0, the I/O stack (in + * particular, IOD) will track the status of the transaction. All + * num_peers processes participating in the transaction must call + * H5TRstart with the same values for num_peers and transaction_num. + * As each participating process is done with their updates in the + * transaction, they individually call H5TRfinish for this + * transaction_num. When all num_peers processes have called + * H5TRfinish for this transaction_num, the I/O stack detects that the + * transaction is finished and updates appear atomically when all + * lower-numbered transactions are finished, aborted, or skipped. + * This mode of operation is typical for loosely-coupled applications. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Mohamad Chaarawi + * August 2013 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Pset_trspl_num_peers(hid_t trspl_id, unsigned num_peers) +{ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE2("e", "iIu", trspl_id, num_peers); + + /* Get the plist structure */ + if(NULL == (plist = H5P_object_verify(trspl_id, H5P_TR_START))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); + + /* Set property */ + if(H5P_set(plist, H5TR_START_NUM_PEERS_NAME, &num_peers) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET,FAIL, "can't set num peers in transaction"); + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Pset_trspl_num_peers() */ + + +/*------------------------------------------------------------------------- + * Function: H5TRcreate + * + * Purpose: Wraps an hid_t around a transaction number, a file ID, + * and a read context ID on that file that operations using + * the created transaction will read from. + * + * Return: Success: The ID for a new transaction. + * Failure: FAIL + * + * Programmer: Mohamad Chaarawi + * August 2013 + * + *------------------------------------------------------------------------- + */ +hid_t +H5TRcreate(hid_t file_id, hid_t rc_id, uint64_t trans_num) +{ + void *file = NULL; + H5VL_t *vol_plugin = NULL; + H5TR_t *tr = NULL; + hid_t ret_value; + + FUNC_ENTER_API(FAIL) + + /* get the file object */ + if(NULL == (file = (void *)H5I_object_verify(file_id, H5I_FILE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") + /* get the plugin pointer */ + if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(file_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information") + /* get the Read Context object */ + if(NULL == (rc = (H5RC_t *)H5I_object_verify(rc_id, H5I_RC))) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a read context ID") + + /* create a new transaction object */ + if(NULL == (tr = H5TR_create(file, rc, trans_num))) + HGOTO_ERROR(H5E_SYM, H5E_CANTCREATE, FAIL, "unable to create transaction object") + + /* Get an atom for the event queue with the VOL information as the auxilary struct*/ + if((ret_value = H5I_register2(H5I_TR, tr, vol_plugin, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize transaction handle") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5TRcreate() */ + + +/*------------------------------------------------------------------------- + * Function: H5TR_create + * + * Purpose: Private version for H5TRcreate. + * + * Return: Success: Transaction struct. + * Failure: NULL + * + * Programmer: Mohamad Chaarawi + * August 2013 + * + *------------------------------------------------------------------------- + */ +H5TR_t * +H5TR_create(void *file, H5RC_t *rc, uint64_t trans_num) +{ + void *file = NULL; + H5VL_t *vol_plugin = NULL; + H5TR_t *tr = NULL; + H5TR_t *ret_value = NULL; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + /* allocate transaction struct */ + if(NULL == (tr = H5FL_CALLOC(H5TR_t))) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, NULL, "can't allocate top transaction structure") + + tr->file = file; + tr->c_version = rc->c_version; + tr->trans_num = trans_num; + + /* set return value */ + ret_value = tr; + +done: + if(!ret_value && tr) + tr = H5FL_FREE(H5TR_t, tr); + + FUNC_LEAVE_API(ret_value) +} /* end H5TR_create() */ + + +/*------------------------------------------------------------------------- + * Function: H5TRstart + * + * Purpose: Starts a transaction that has been created with H5TRcreate. + * + * Return: Success: Non-Negative. + * Failure: Negative + * + * Programmer: Mohamad Chaarawi + * August 2013 + * + *------------------------------------------------------------------------- + */ +herr_t +H5TRstart(hid_t tr_id, hid_t trspl_id, hid_t eq_id) +{ + H5TR_t *tr = NULL; + H5_priv_request_t *request = NULL; /* private request struct inserted in event queue */ + void **req = NULL; /* pointer to plugin generate requests (Stays NULL if plugin does not support async */ + herr_t ret_value; + + FUNC_ENTER_API(FAIL) + H5TRACE3("e", "iii", tr_id, trspl_id, eq_id); + + /* get the TR object */ + if(NULL == (tr = (H5TR_t *)H5I_object_verify(tr_id, H5I_TR))) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a Transaction ID") + + /* Get correct property list */ + if(H5P_DEFAULT == trspl_id) + trspl_id = H5P_TR_START_DEFAULT; + else + if(TRUE != H5P_isa_class(trspl_id, H5P_TR_START)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not transaction start property list") + + if(eq_id != H5_EVENT_QUEUE_NULL) { + /* create the private request */ + if(NULL == (request = (H5_priv_request_t *)H5MM_calloc(sizeof(H5_priv_request_t)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); + request->req = NULL; + req = &request->req; + request->next = NULL; + request->vol_plugin = vol_plugin; + } + + if(H5VL_iod_tr_start(tr, trspl_id, req) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "failed to request a transaction start"); + + if(request && *req) { + if(H5EQinsert(eq_id, request) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "failed to insert request in event queue"); + } + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5TRstart()*/ + + +/*------------------------------------------------------------------------- + * Function: H5TRfinish + * + * Purpose: Finishes/Commits a transaction. + * + * Return: Success: Non-Negative. + * Failure: Negative + * + * Programmer: Mohamad Chaarawi + * August 2013 + * + *------------------------------------------------------------------------- + */ +herr_t +H5TRfinish(hid_t trans_id, hid_t trfpl_id, hid_t eq_id) +{ + H5TR_t *tr = NULL; + H5_priv_request_t *request = NULL; /* private request struct inserted in event queue */ + void **req = NULL; /* pointer to plugin generate requests (Stays NULL if plugin does not support async */ + herr_t ret_value; + + FUNC_ENTER_API(FAIL) + H5TRACE3("e", "iii", trans_id, trfpl_id, eq_id); + + /* get the TR object */ + if(NULL == (tr = (H5TR_t *)H5I_object_verify(tr_id, H5I_TR))) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a Transaction ID") + + /* Get correct property list */ + if(H5P_DEFAULT == trfpl_id) + trfpl_id = H5P_TR_FINISH_DEFAULT; + else + if(TRUE != H5P_isa_class(trfpl_id, H5P_TR_FINISH)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not transaction finish property list") + + if(eq_id != H5_EVENT_QUEUE_NULL) { + /* create the private request */ + if(NULL == (request = (H5_priv_request_t *)H5MM_calloc(sizeof(H5_priv_request_t)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); + request->req = NULL; + req = &request->req; + request->next = NULL; + request->vol_plugin = vol_plugin; + } + + if(H5VL_iod_tr_finish(tr, trfpl_id, req) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "failed to request a transaction finish"); + + if(request && *req) { + if(H5EQinsert(eq_id, request) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "failed to insert request in event queue"); + } + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5TRfinish()*/ + + +/*------------------------------------------------------------------------- + * Function: H5TRfinish + * + * Purpose: Set a depedency between two transactions. Transaction + * associated with trans_id is declaring a dependency on transaction + * numbered trans_num. trans_num must be < the transaction number + * trans_id is associated with. + * + * Return: Success: Non-Negative. + * Failure: Negative + * + * Programmer: Mohamad Chaarawi + * August 2013 + * + *------------------------------------------------------------------------- + */ +herr_t +H5TRset_dependency(hid_t trans_id, uint64_t trans_num, hid_t eq_id) +{ + H5TR_t *tr = NULL; + H5_priv_request_t *request = NULL; /* private request struct inserted in event queue */ + void **req = NULL; /* pointer to plugin generate requests (Stays NULL if plugin does not support async */ + herr_t ret_value; + + FUNC_ENTER_API(FAIL) + + /* get the TR object */ + if(NULL == (tr = (H5TR_t *)H5I_object_verify(tr_id, H5I_TR))) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a Transaction ID") + + if(tr->trans_num <= trans_num) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "The dependent transaction must be higher than the one it depends on") + + if(eq_id != H5_EVENT_QUEUE_NULL) { + /* create the private request */ + if(NULL == (request = (H5_priv_request_t *)H5MM_calloc(sizeof(H5_priv_request_t)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); + request->req = NULL; + req = &request->req; + request->next = NULL; + request->vol_plugin = vol_plugin; + } + + if(H5VL_iod_tr_set_dependency(tr, trans_num, req) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "failed to request a transaction set_dependency"); + + if(request && *req) { + if(H5EQinsert(eq_id, request) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "failed to insert request in event queue"); + } + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5TRset_dependency()*/ + + +/*------------------------------------------------------------------------- + * Function: H5TRabort + * + * Purpose: Aborts a transaction + * + * Return: Success: Non-Negative. + * Failure: Negative + * + * Programmer: Mohamad Chaarawi + * August 2013 + * + *------------------------------------------------------------------------- + */ +herr_t +H5TRabort(hid_t trans_id, hid_t eq_id) +{ + H5TR_t *tr = NULL; + H5_priv_request_t *request = NULL; /* private request struct inserted in event queue */ + void **req = NULL; /* pointer to plugin generate requests (Stays NULL if plugin does not support async */ + herr_t ret_value; + + FUNC_ENTER_API(FAIL) + H5TRACE2("e", "ii", trans_id, eq_id); + + /* get the TR object */ + if(NULL == (tr = (H5TR_t *)H5I_object_verify(tr_id, H5I_TR))) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a Transaction ID") + + if(eq_id != H5_EVENT_QUEUE_NULL) { + /* create the private request */ + if(NULL == (request = (H5_priv_request_t *)H5MM_calloc(sizeof(H5_priv_request_t)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); + request->req = NULL; + req = &request->req; + request->next = NULL; + request->vol_plugin = vol_plugin; + } + + if(H5VL_iod_tr_abort(tr, req) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "failed to request a transaction abort"); + + if(request && *req) { + if(H5EQinsert(eq_id, request) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "failed to insert request in event queue"); + } + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5TRabort()*/ + + +/*------------------------------------------------------------------------- + * Function: H5TRclose + * + * Purpose: Closes the specified transaction ID. The ID will no longer be + * valid for accessing the transaction. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Mohamad Chaarawi + * August 2013 + * + *------------------------------------------------------------------------- + */ +herr_t +H5TRclose(hid_t tr_id) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE1("e", "i", tr_id); + + /* Check args */ + if(NULL == H5I_object_verify(tr_id,H5I_TR)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an transaction ID") + + if(H5I_dec_app_ref(tr_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close transaction") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5TRclose() */ + + +/*------------------------------------------------------------------------- + * Function: H5TR_close + * + * Purpose: Closes the specified transaction ID. The ID will no longer be + * valid for accessing the transaction. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Mohamad Chaarawi + * August 2013 + * + *------------------------------------------------------------------------- + */ +herr_t +H5TR_close(H5TR_t *tr) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + + tr = H5FL_FREE(H5TR_t, tr); + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5TR_close() */ + diff --git a/src/H5TRprivate.h b/src/H5TRprivate.h new file mode 100644 index 0000000..54bbe20 --- /dev/null +++ b/src/H5TRprivate.h @@ -0,0 +1,63 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * This file contains private information about the H5TR module + */ +#ifndef _H5TRprivate_H +#define _H5TRprivate_H + +/* Include package's public header */ +#include "H5TRpublic.h" + +/* Private headers needed by this file */ +#include "H5private.h" /* Generic Functions */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5VLprivate.h" /* VOL plugins */ + +/**************************/ +/* Library Private Macros */ +/**************************/ + +/****************************/ +/* Library Private Typedefs */ +/****************************/ +/* the transaction struct */ +typedef struct H5TR_t { + void *file; + uint64_t c_version; + uint64_t trans_num; +} H5TR_t; + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + +/******************************/ +/* Library Private Prototypes */ +/******************************/ +#if 0 +herr_t H5TR_init(void); + +/* API wrappers */ +H5_DLL H5TR_t *H5TR_create(void *file, H5RC_t *rc, uint64_t trans_num); +H5_DLL herr_t H5TR_close(H5TR_t *tr); + + +H5_DLL herr_t H5VL_iod_tr_start(H5TR_t *tr, hid_t trspl_id, void **req); +H5_DLL herr_t H5VL_iod_tr_finish(H5TR_t *tr, hid_t trfpl_id, void **req); +H5_DLL herr_t H5VL_iod_tr_set_dependency(H5TR_t *tr, uint64_t trans_num, void **req); +H5_DLL herr_t H5VL_iod_tr_abort(H5TR_t *tr, void **req); +#endif +#endif /* _H5TRprivate_H */ diff --git a/src/H5TRpublic.h b/src/H5TRpublic.h new file mode 100644 index 0000000..07d6291 --- /dev/null +++ b/src/H5TRpublic.h @@ -0,0 +1,63 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * This file contains function prototypes for each exported function in the + * H5TR module. + */ +#ifndef _H5TRpublic_H +#define _H5TRpublic_H + +/* System headers needed by this file */ + +/* Public headers needed by this file */ +#include "H5public.h" +#include "H5Ipublic.h" + +/*****************/ +/* Public Macros */ +/*****************/ +#define H5TR_START_NUM_PEERS_NAME "number_of_peers_name" + +/*******************/ +/* Public Typedefs */ +/*******************/ + +/********************/ +/* Public Variables */ +/********************/ + + +#ifdef __cplusplus +extern "C" { +#endif + +/*********************/ +/* Public Prototypes */ +/*********************/ + +/* API wrappers */ +H5_DLL hid_t H5TRcreate(hid_t file_id, hid_t rc_id, uint64_t trans_num); +H5_DLL herr_t H5TRstart(hid_t trans_id, hid_t trspl_id, hid_t eq_id); +H5_DLL herr_t H5TRfinish(hid_t trans_id, hid_t trfpl_id, hid_t eq_id); +H5_DLL herr_t H5TRset_dependency(hid_t trans_id, uint64_t trans_num, hid_t eq_id); +H5_DLL herr_t H5TRabort(hid_t trans_id, hid_t eq_id); +H5_DLL herr_t H5TRclose(hid_t trans_id); + +H5_DLL herr_t H5Pset_trspl_num_peers(hid_t trspl_id, unsigned num_peers); + +#ifdef __cplusplus +} +#endif +#endif /* _H5TRpublic_H */ diff --git a/src/Makefile.am b/src/Makefile.am index 2f8cb1a..dedf109 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -93,7 +93,7 @@ libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \ H5P.c H5Pacpl.c H5Pdapl.c H5Pdcpl.c \ H5Pdeprec.c H5Pdxpl.c H5Pencdec.c \ H5Pfapl.c H5Pfcpl.c H5Pfmpl.c \ - H5Pgcpl.c H5Pint.c \ + H5Pgcpl.c H5Pint.c H5Prcapl.c H5Ptrspl.c \ H5Plapl.c H5Plcpl.c H5Pocpl.c H5Pocpypl.c H5Pstrcpl.c H5Ptest.c \ H5PL.c \ H5R.c H5Rdeprec.c \ diff --git a/src/Makefile.in b/src/Makefile.in index 48a3c36..11c754c 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -164,18 +164,18 @@ am_libhdf5_la_OBJECTS = H5.lo H5checksum.lo H5dbg.lo H5system.lo \ H5Oshared.lo H5Ostab.lo H5Oshmesg.lo H5Otest.lo H5Ounknown.lo \ H5P.lo H5Pacpl.lo H5Pdapl.lo H5Pdcpl.lo H5Pdeprec.lo \ H5Pdxpl.lo H5Pencdec.lo H5Pfapl.lo H5Pfcpl.lo H5Pfmpl.lo \ - H5Pgcpl.lo H5Pint.lo H5Plapl.lo H5Plcpl.lo H5Pocpl.lo \ - H5Pocpypl.lo H5Pstrcpl.lo H5Ptest.lo H5PL.lo H5R.lo \ - H5Rdeprec.lo H5UC.lo H5RS.lo H5S.lo H5Sall.lo H5Sdbg.lo \ - H5Shyper.lo H5Smpio.lo H5Snone.lo H5Spoint.lo H5Sselect.lo \ - H5Stest.lo H5SL.lo H5SM.lo H5SMbtree2.lo H5SMcache.lo \ - H5SMmessage.lo H5SMtest.lo H5ST.lo H5T.lo H5Tarray.lo \ - H5Tbit.lo H5Tcommit.lo H5Tcompound.lo H5Tconv.lo H5Tcset.lo \ - H5Tdbg.lo H5Tdeprec.lo H5Tenum.lo H5Tfields.lo H5Tfixed.lo \ - H5Tfloat.lo H5Tinit.lo H5Tnative.lo H5Toffset.lo H5Toh.lo \ - H5Topaque.lo H5Torder.lo H5Tpad.lo H5Tprecis.lo H5Tstrpad.lo \ - H5Tvisit.lo H5Tvlen.lo H5TS.lo H5V.lo H5WB.lo H5Z.lo \ - H5Zdeflate.lo H5Zfletcher32.lo H5Znbit.lo H5Zshuffle.lo \ + H5Pgcpl.lo H5Pint.lo H5Prcapl.lo H5Ptrspl.lo H5Plapl.lo \ + H5Plcpl.lo H5Pocpl.lo H5Pocpypl.lo H5Pstrcpl.lo H5Ptest.lo \ + H5PL.lo H5R.lo H5Rdeprec.lo H5UC.lo H5RS.lo H5S.lo H5Sall.lo \ + H5Sdbg.lo H5Shyper.lo H5Smpio.lo H5Snone.lo H5Spoint.lo \ + H5Sselect.lo H5Stest.lo H5SL.lo H5SM.lo H5SMbtree2.lo \ + H5SMcache.lo H5SMmessage.lo H5SMtest.lo H5ST.lo H5T.lo \ + H5Tarray.lo H5Tbit.lo H5Tcommit.lo H5Tcompound.lo H5Tconv.lo \ + H5Tcset.lo H5Tdbg.lo H5Tdeprec.lo H5Tenum.lo H5Tfields.lo \ + H5Tfixed.lo H5Tfloat.lo H5Tinit.lo H5Tnative.lo H5Toffset.lo \ + H5Toh.lo H5Topaque.lo H5Torder.lo H5Tpad.lo H5Tprecis.lo \ + H5Tstrpad.lo H5Tvisit.lo H5Tvlen.lo H5TS.lo H5V.lo H5WB.lo \ + H5Z.lo H5Zdeflate.lo H5Zfletcher32.lo H5Znbit.lo H5Zshuffle.lo \ H5Zszip.lo H5Zscaleoffset.lo H5Ztrans.lo libhdf5_la_OBJECTS = $(am_libhdf5_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) @@ -603,7 +603,7 @@ libhdf5_la_SOURCES = H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \ H5P.c H5Pacpl.c H5Pdapl.c H5Pdcpl.c \ H5Pdeprec.c H5Pdxpl.c H5Pencdec.c \ H5Pfapl.c H5Pfcpl.c H5Pfmpl.c \ - H5Pgcpl.c H5Pint.c \ + H5Pgcpl.c H5Pint.c H5Prcapl.c H5Ptrspl.c \ H5Plapl.c H5Plcpl.c H5Pocpl.c H5Pocpypl.c H5Pstrcpl.c H5Ptest.c \ H5PL.c \ H5R.c H5Rdeprec.c \ @@ -977,8 +977,10 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Plcpl.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Pocpl.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Pocpypl.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Prcapl.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Pstrcpl.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Ptest.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Ptrspl.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5R.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5RS.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Rdeprec.Plo@am__quote@ -- cgit v0.12