2004-11-22 03:37:56 +03:00
|
|
|
/*
|
2005-11-05 22:57:48 +03:00
|
|
|
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
|
|
|
* University Research and Technology
|
|
|
|
* Corporation. All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 The University of Tennessee and The University
|
|
|
|
* of Tennessee Research Foundation. All rights
|
|
|
|
* reserved.
|
2004-11-28 23:09:25 +03:00
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
|
|
* University of Stuttgart. All rights reserved.
|
2005-03-24 15:43:37 +03:00
|
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
2004-11-22 04:38:40 +03:00
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
2004-11-22 03:37:56 +03:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
2004-08-06 23:35:57 +04:00
|
|
|
#ifndef _COMMON_SM_MMAP_H_
|
|
|
|
#define _COMMON_SM_MMAP_H_
|
2004-06-16 19:41:29 +04:00
|
|
|
|
2005-02-08 01:13:58 +03:00
|
|
|
#include "ompi_config.h"
|
|
|
|
|
2005-07-03 20:06:07 +04:00
|
|
|
#include "opal/class/opal_object.h"
|
2005-07-03 20:22:16 +04:00
|
|
|
#include "opal/class/opal_list.h"
|
2006-02-12 04:33:29 +03:00
|
|
|
#include "opal/sys/atomic.h"
|
|
|
|
#include "ompi/mca/mpool/mpool.h"
|
2005-06-25 01:12:38 +04:00
|
|
|
|
2004-10-21 02:31:03 +04:00
|
|
|
#if defined(c_plusplus) || defined(__cplusplus)
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
2005-06-21 21:10:28 +04:00
|
|
|
|
|
|
|
struct mca_mpool_base_module_t;
|
|
|
|
|
2004-08-18 19:02:21 +04:00
|
|
|
struct mca_common_sm_file_header_t {
|
2004-11-07 01:00:24 +03:00
|
|
|
|
2004-08-11 20:06:14 +04:00
|
|
|
/* lock to control atomic access */
|
2005-07-04 01:38:51 +04:00
|
|
|
opal_atomic_lock_t seg_lock;
|
2004-08-11 20:06:14 +04:00
|
|
|
/* is the segment ready for use */
|
2004-11-07 01:00:24 +03:00
|
|
|
|
2004-08-04 21:22:16 +04:00
|
|
|
volatile bool seg_inited;
|
2004-08-11 20:06:14 +04:00
|
|
|
/* Offset to next available memory location available for allocation */
|
2004-06-16 19:41:29 +04:00
|
|
|
size_t seg_offset;
|
2004-11-07 01:00:24 +03:00
|
|
|
|
2004-08-11 20:06:14 +04:00
|
|
|
/* total size of the segment */
|
2004-06-16 19:41:29 +04:00
|
|
|
size_t seg_size;
|
2004-11-07 01:00:24 +03:00
|
|
|
|
|
|
|
/* array of pointers to the base of the shared memory address - one per
|
|
|
|
* local process */
|
|
|
|
volatile char **base_shared_mem_segment;
|
|
|
|
|
|
|
|
/* array of flags indicating base_shared_mem_segment is set */
|
|
|
|
volatile int *base_shared_mem_flags;
|
2004-06-16 19:41:29 +04:00
|
|
|
};
|
2004-08-18 19:02:21 +04:00
|
|
|
typedef struct mca_common_sm_file_header_t mca_common_sm_file_header_t;
|
2004-06-16 19:41:29 +04:00
|
|
|
|
|
|
|
|
2004-08-06 23:35:57 +04:00
|
|
|
struct mca_common_sm_mmap_t {
|
2004-08-11 20:06:14 +04:00
|
|
|
/* double link list element */
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_item_t map_item;
|
2004-08-18 19:02:21 +04:00
|
|
|
/* pointer to header imbeded in the shared memory file */
|
|
|
|
mca_common_sm_file_header_t* map_seg;
|
2004-08-11 20:06:14 +04:00
|
|
|
/* base address of the mmap'ed file */
|
2004-06-17 20:13:20 +04:00
|
|
|
unsigned char *map_addr;
|
2004-08-11 20:06:14 +04:00
|
|
|
/* base address of data segment */
|
|
|
|
unsigned char *data_addr;
|
2004-06-16 19:41:29 +04:00
|
|
|
size_t map_size;
|
2005-02-08 01:13:58 +03:00
|
|
|
char map_path[OMPI_PATH_MAX];
|
2006-08-20 23:45:28 +04:00
|
|
|
#if defined(__WINDOWS__)
|
|
|
|
HANDLE hMappedObject;
|
|
|
|
#endif /* defined(__WINDOWS__) */
|
2004-06-16 19:41:29 +04:00
|
|
|
};
|
2004-08-06 23:35:57 +04:00
|
|
|
typedef struct mca_common_sm_mmap_t mca_common_sm_mmap_t;
|
2004-06-16 19:41:29 +04:00
|
|
|
|
2004-08-06 23:35:57 +04:00
|
|
|
OBJ_CLASS_DECLARATION(mca_common_sm_mmap_t);
|
2004-06-16 19:41:29 +04:00
|
|
|
|
|
|
|
|
2004-08-04 21:22:16 +04:00
|
|
|
/**
|
|
|
|
* This routine is used to set up a shared memory file, backed
|
|
|
|
* by a specified file. It is assumed that the file does not
|
|
|
|
* exist before any of the current set of processes try and open
|
|
|
|
* it.
|
|
|
|
*
|
|
|
|
* @param size - size of the file, in bytes (IN)
|
|
|
|
*
|
|
|
|
* @param file_name name of file to be opened. (IN)
|
|
|
|
*
|
|
|
|
* @param size_ctl_structure size of the control structure at
|
|
|
|
* the head of the file. The control structure
|
2004-08-18 19:02:21 +04:00
|
|
|
* is assumed to have mca_common_sm_file_header_t
|
2004-08-04 21:22:16 +04:00
|
|
|
* as its first segment (IN)
|
|
|
|
*
|
|
|
|
* @param data_set_alignment alignment of the data segment. this
|
2005-08-09 01:38:27 +04:00
|
|
|
* follows the control structure. If this
|
|
|
|
* value if 0, then assume that there will
|
|
|
|
* be no data segment following the control
|
|
|
|
* structure. (IN)
|
2004-08-18 19:02:21 +04:00
|
|
|
*
|
|
|
|
* @returnvalue pointer to control structure at head of file.
|
2004-08-04 21:22:16 +04:00
|
|
|
*/
|
|
|
|
|
2005-12-31 18:06:24 +03:00
|
|
|
OMPI_DECLSPEC extern
|
|
|
|
mca_common_sm_mmap_t* mca_common_sm_mmap_init(
|
2005-06-21 21:10:28 +04:00
|
|
|
size_t size,
|
|
|
|
char *file_name,
|
|
|
|
size_t size_ctl_structure,
|
|
|
|
size_t data_seg_alignment);
|
|
|
|
|
2005-12-31 18:06:24 +03:00
|
|
|
OMPI_DECLSPEC extern
|
|
|
|
void* mca_common_sm_mmap_seg_alloc(
|
2005-06-21 21:10:28 +04:00
|
|
|
struct mca_mpool_base_module_t* mpool,
|
|
|
|
size_t* size,
|
2005-06-25 01:12:38 +04:00
|
|
|
mca_mpool_base_registration_t** registration);
|
2004-08-06 23:35:57 +04:00
|
|
|
|
2005-12-31 18:06:24 +03:00
|
|
|
/**
|
|
|
|
* This function will release all local ressources attached to the
|
|
|
|
* mmapped file. We assume that the operating system will destroy the
|
|
|
|
* file when the last process release it.
|
|
|
|
*
|
|
|
|
* @param sm_mmap - the control structure at head of file.
|
|
|
|
*
|
|
|
|
* @returnvalue 0 if everything was OK, otherwise a negative value.
|
|
|
|
*/
|
|
|
|
|
|
|
|
OMPI_DECLSPEC extern
|
|
|
|
int mca_common_sm_mmap_fini( mca_common_sm_mmap_t* sm_mmap );
|
|
|
|
|
2004-08-06 23:35:57 +04:00
|
|
|
/*
|
|
|
|
* Instance that is shared between components that use shared memory
|
|
|
|
*/
|
|
|
|
|
2004-10-22 20:06:05 +04:00
|
|
|
OMPI_DECLSPEC extern mca_common_sm_mmap_t *mca_common_sm_mmap;
|
2004-06-16 19:41:29 +04:00
|
|
|
|
2004-10-21 02:31:03 +04:00
|
|
|
#if defined(c_plusplus) || defined(__cplusplus)
|
|
|
|
}
|
|
|
|
#endif
|
2004-06-16 19:41:29 +04:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|