2004-11-22 00:37:56 +00:00
|
|
|
/*
|
2005-11-05 19:57:48 +00: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 20:09:25 +00:00
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
|
|
* University of Stuttgart. All rights reserved.
|
2005-03-24 12:43:37 +00:00
|
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
2004-11-22 01:38:40 +00:00
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
2004-11-22 00:37:56 +00:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
2004-08-06 19:35:57 +00:00
|
|
|
#ifndef _COMMON_SM_MMAP_H_
|
|
|
|
#define _COMMON_SM_MMAP_H_
|
2004-06-16 15:41:29 +00:00
|
|
|
|
2005-02-07 22:13:58 +00:00
|
|
|
#include "ompi_config.h"
|
|
|
|
|
2005-07-03 16:06:07 +00:00
|
|
|
#include "opal/class/opal_object.h"
|
2005-07-03 16:22:16 +00:00
|
|
|
#include "opal/class/opal_list.h"
|
2006-02-12 01:33:29 +00:00
|
|
|
#include "opal/sys/atomic.h"
|
|
|
|
#include "ompi/mca/mpool/mpool.h"
|
2005-06-24 21:12:38 +00:00
|
|
|
|
2004-10-20 22:31:03 +00:00
|
|
|
#if defined(c_plusplus) || defined(__cplusplus)
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
2005-06-21 17:10:28 +00:00
|
|
|
|
|
|
|
struct mca_mpool_base_module_t;
|
|
|
|
|
2004-08-18 15:02:21 +00:00
|
|
|
struct mca_common_sm_file_header_t {
|
2004-11-06 22:00:24 +00:00
|
|
|
|
2004-08-11 16:06:14 +00:00
|
|
|
/* lock to control atomic access */
|
2005-07-03 21:38:51 +00:00
|
|
|
opal_atomic_lock_t seg_lock;
|
2004-08-11 16:06:14 +00:00
|
|
|
/* is the segment ready for use */
|
2004-11-06 22:00:24 +00:00
|
|
|
|
2004-08-04 17:22:16 +00:00
|
|
|
volatile bool seg_inited;
|
2004-08-11 16:06:14 +00:00
|
|
|
/* Offset to next available memory location available for allocation */
|
2004-06-16 15:41:29 +00:00
|
|
|
size_t seg_offset;
|
2004-11-06 22:00:24 +00:00
|
|
|
|
2004-08-11 16:06:14 +00:00
|
|
|
/* total size of the segment */
|
2004-06-16 15:41:29 +00:00
|
|
|
size_t seg_size;
|
2004-11-06 22:00:24 +00: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 15:41:29 +00:00
|
|
|
};
|
2004-08-18 15:02:21 +00:00
|
|
|
typedef struct mca_common_sm_file_header_t mca_common_sm_file_header_t;
|
2004-06-16 15:41:29 +00:00
|
|
|
|
|
|
|
|
2004-08-06 19:35:57 +00:00
|
|
|
struct mca_common_sm_mmap_t {
|
2004-08-11 16:06:14 +00:00
|
|
|
/* double link list element */
|
2005-07-03 16:22:16 +00:00
|
|
|
opal_list_item_t map_item;
|
2004-08-18 15:02:21 +00:00
|
|
|
/* pointer to header imbeded in the shared memory file */
|
|
|
|
mca_common_sm_file_header_t* map_seg;
|
2004-08-11 16:06:14 +00:00
|
|
|
/* base address of the mmap'ed file */
|
2004-06-17 16:13:20 +00:00
|
|
|
unsigned char *map_addr;
|
2004-08-11 16:06:14 +00:00
|
|
|
/* base address of data segment */
|
|
|
|
unsigned char *data_addr;
|
2004-06-16 15:41:29 +00:00
|
|
|
size_t map_size;
|
2005-02-07 22:13:58 +00:00
|
|
|
char map_path[OMPI_PATH_MAX];
|
2006-08-20 19:45:28 +00:00
|
|
|
#if defined(__WINDOWS__)
|
|
|
|
HANDLE hMappedObject;
|
|
|
|
#endif /* defined(__WINDOWS__) */
|
2004-06-16 15:41:29 +00:00
|
|
|
};
|
2004-08-06 19:35:57 +00:00
|
|
|
typedef struct mca_common_sm_mmap_t mca_common_sm_mmap_t;
|
2004-06-16 15:41:29 +00:00
|
|
|
|
2004-08-06 19:35:57 +00:00
|
|
|
OBJ_CLASS_DECLARATION(mca_common_sm_mmap_t);
|
2004-06-16 15:41:29 +00:00
|
|
|
|
|
|
|
|
2004-08-04 17:22:16 +00: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 15:02:21 +00:00
|
|
|
* is assumed to have mca_common_sm_file_header_t
|
2004-08-04 17:22:16 +00:00
|
|
|
* as its first segment (IN)
|
|
|
|
*
|
|
|
|
* @param data_set_alignment alignment of the data segment. this
|
2005-08-08 21:38:27 +00: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 15:02:21 +00:00
|
|
|
*
|
|
|
|
* @returnvalue pointer to control structure at head of file.
|
2004-08-04 17:22:16 +00:00
|
|
|
*/
|
|
|
|
|
2005-12-31 15:06:24 +00:00
|
|
|
OMPI_DECLSPEC extern
|
|
|
|
mca_common_sm_mmap_t* mca_common_sm_mmap_init(
|
2005-06-21 17:10:28 +00:00
|
|
|
size_t size,
|
|
|
|
char *file_name,
|
|
|
|
size_t size_ctl_structure,
|
|
|
|
size_t data_seg_alignment);
|
|
|
|
|
2005-12-31 15:06:24 +00:00
|
|
|
OMPI_DECLSPEC extern
|
|
|
|
void* mca_common_sm_mmap_seg_alloc(
|
2005-06-21 17:10:28 +00:00
|
|
|
struct mca_mpool_base_module_t* mpool,
|
|
|
|
size_t* size,
|
2005-06-24 21:12:38 +00:00
|
|
|
mca_mpool_base_registration_t** registration);
|
2004-08-06 19:35:57 +00:00
|
|
|
|
2005-12-31 15:06:24 +00: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 19:35:57 +00:00
|
|
|
/*
|
|
|
|
* Instance that is shared between components that use shared memory
|
|
|
|
*/
|
|
|
|
|
2004-10-22 16:06:05 +00:00
|
|
|
OMPI_DECLSPEC extern mca_common_sm_mmap_t *mca_common_sm_mmap;
|
2004-06-16 15:41:29 +00:00
|
|
|
|
2004-10-20 22:31:03 +00:00
|
|
|
#if defined(c_plusplus) || defined(__cplusplus)
|
|
|
|
}
|
|
|
|
#endif
|
2004-06-16 15:41:29 +00:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|