1
1
Also introduces work in progress "convertor" sender based copy algorithm. This algorithm cannot be selected without other modifications in the convertor (not currently available in trunk). The default old synchronous copy algorithm is selected by default.

This commit was SVN r17063.
Этот коммит содержится в:
Aurelien Bouteiller 2008-01-07 23:35:44 +00:00
родитель 0f0fde3490
Коммит 9bf54e1604
2 изменённых файлов: 115 добавлений и 52 удалений

Просмотреть файл

@ -20,8 +20,102 @@
#include "ompi/datatype/datatype_memcpy.h"
#include <fcntl.h>
#define sb mca_vprotocol_pessimist.sender_based
static int sb_mmap_file_open(const char *path)
{
#if defined(__WINDOWS__)
sb.sb_fd = CreateFile(path, GENERIC_READ | GENERIC_WRITE, 0, NULL,
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if(INVALID_HANDLE_VALUE == sb.sb_fd)
{
V_OUTPUT_ERR("pml_v: vprotocol_pessimist: sender_based_init: open (%s): %s",
path, GetLastError());
return OPAL_ERR_FILE_OPEN_FAILURE;
}
return OPAL_SUCCESS;
#else
sb.sb_fd = open(path, O_CREAT | O_TRUNC | O_RDWR, 0600);
if(-1 == sb.sb_fd)
{
V_OUTPUT_ERR("pml_v: vprotocol_pessimist: sender_based_init: open (%s): %s",
path, strerror(errno));
return OPAL_ERR_FILE_OPEN_FAILURE;
}
return OPAL_SUCCESS;
#endif
}
static void sb_mmap_file_close(void)
{
#if defined(__WINDOWS__)
closeHandle(sb.sb_fd);
#else
int ret = close(sb.sb_fd);
if(-1 == ret)
V_OUTPUT_ERR("pml_v: protocol_pessimist: sender_based_finalize: close (%d): %s",
sb.sb_fd, strerror(errno));
#endif
}
static void sb_mmap_alloc(void)
{
#if defined(__WINDOWS__)
sb.sb_map = CreateFileMapping(sb.sb_fd, NULL, PAGE_READWRITE, 0,
(DWORD)sb.sb_offset + sb.sb_length, NULL);
if(NULL == sb.sb_map)
{
V_OUTPUT_ERR("pml_v: vprotocol_pessimist: sender_based_alloc: CreateFileMapping : %s",
GetLastError());
ompi_mpi_abort(MPI_COMM_NULL, MPI_ERR_NO_SPACE, false);
}
sb.sb_addr = (uintptr_t) MapViewOfFile(sb.sb_map, FILE_MAP_ALL_ACCESS, 0,
sb.sb_offset, sb.sb_length);
if(NULL == sb.sb_addr)
{
V_OUTPUT_ERR("pml_v: vprotocol_pessimist: sender_based_alloc: mmap: %s",
GetLastError());
closeHandle(sb.sb_map);
closeHandle(sb.sb_fd);
ompi_mpi_abort(MPI_COMM_NULL, MPI_ERR_NO_SPACE, false);
}
#else
if(-1 == ftruncate(sb.sb_fd, sb.sb_offset + sb.sb_length))
{
V_OUTPUT_ERR("pml_v: vprotocol_pessimist: sender_based_alloc: ftruncate: %s",
strerror(errno));
close(sb.sb_fd);
ompi_mpi_abort(MPI_COMM_NULL, MPI_ERR_NO_SPACE, false);
}
sb.sb_addr = (uintptr_t) mmap((void *) sb.sb_addr, sb.sb_length,
PROT_WRITE | PROT_READ,
MAP_PRIVATE | MAP_NOCACHE, sb.sb_fd,
sb.sb_offset);
if(((uintptr_t) -1) == sb.sb_addr)
{
V_OUTPUT_ERR("pml_v: vprotocol_pessimist: sender_based_alloc: mmap: %s",
strerror(errno));
close(sb.sb_fd);
ompi_mpi_abort(MPI_COMM_NULL, MPI_ERR_NO_SPACE, false);
}
#endif
}
static void sb_mmap_free(void)
{
#if defined(__WINDOWS__)
UnmapViewOfFile(sb.sb_addr);
closeHandle(sb.sb_map);
#else
int ret = munmap((void *) sb.sb_addr, sb.sb_length);
if(-1 == ret)
V_OUTPUT_ERR("pml_v: protocol_pessimsit: sender_based_finalize: munmap (%p): %s",
(void *) sb.sb_addr, strerror(errno));
#endif
}
int vprotocol_pessimist_sender_based_init(const char *mmapfile, size_t size)
{
char path[PATH_MAX];
@ -43,31 +137,16 @@ int vprotocol_pessimist_sender_based_init(const char *mmapfile, size_t size)
sprintf(path, "%s"OPAL_PATH_SEP"%s", orte_process_info.proc_session_dir,
mmapfile);
sb.sb_fd = open(path, O_CREAT | O_TRUNC | O_RDWR, 0600);
if(-1 == sb.sb_fd)
{
V_OUTPUT_ERR("pml_v: vprotocol_pessimist: sender_based_init: open (%s): %s",
path, strerror(errno));
return OPAL_ERR_FILE_OPEN_FAILURE;
}
if(OPAL_SUCCESS != sb_mmap_file_open(path))
return OPAL_ERR_FILE_OPEN_FAILURE;
return OMPI_SUCCESS;
}
void vprotocol_pessimist_sender_based_finalize(void)
{
int ret;
if(((uintptr_t) NULL) != sb.sb_addr)
{
ret = munmap((void *) sb.sb_addr, sb.sb_length);
if(-1 == ret)
V_OUTPUT_ERR("pml_v: protocol_pessimsit: sender_based_finalize: munmap (%p): %s",
(void *) sb.sb_addr, strerror(errno));
}
ret = close(sb.sb_fd);
if(-1 == ret)
V_OUTPUT_ERR("pml_v: protocol_pessimist: sender_based_finalize: close (%d): %s",
sb.sb_fd, strerror(errno));
sb_mmap_free();
sb_mmap_file_close();
}
@ -77,7 +156,7 @@ void vprotocol_pessimist_sender_based_finalize(void)
void vprotocol_pessimist_sender_based_alloc(size_t len)
{
if(((uintptr_t) NULL) != sb.sb_addr)
munmap((void *) sb.sb_addr, sb.sb_length);
sb_mmap_free();
#ifdef SB_USE_SELFCOMM_METHOD
else
ompi_comm_dup(MPI_COMM_SELF, &sb.sb_comm, 1);
@ -95,34 +174,8 @@ void vprotocol_pessimist_sender_based_alloc(size_t len)
/* How much space left for application data */
sb.sb_available = sb.sb_length - sb.sb_cursor;
#if 0
if(-1 == lseek(sb.sb_fd, sb.sb_offset + sb.sb_length, SEEK_SET))
{
V_OUTPUT_ERR("pml_v: vprotocol_pessimist: sender_based_alloc: lseek: %s",
strerror(errno));
close(sb.sb_fd);
ompi_mpi_abort(MPI_COMM_NULL, MPI_ERR_NO_SPACE, false);
}
if(1 != write(sb.sb_fd, "", 1))
{
V_OUTPUT_ERR("pml_v: vprotocol_pessimist: sender_based_alloc: write: %s",
strerror(errno));
close(sb.sb_fd);
ompi_mpi_abort(MPI_COMM_NULL, MPI_ERR_NO_SPACE, false);
}
sb.sb_addr = (uintptr_t) mmap((void *) sb.sb_addr, sb.sb_length,
PROT_WRITE | PROT_READ, MAP_SHARED, sb.sb_fd,
sb.sb_offset);
#else
sb.sb_addr = (uintptr_t) malloc(sb.sb_length);
#endif
if(((uintptr_t) -1) == sb.sb_addr)
{
V_OUTPUT_ERR("pml_v: vprotocol_pessimist: sender_based_alloc: mmap: %s",
strerror(errno));
close(sb.sb_fd);
ompi_mpi_abort(MPI_COMM_NULL, MPI_ERR_NO_SPACE, false);
}
sb_mmap_alloc();
sb.sb_cursor += sb.sb_addr; /* set absolute addr of sender_based buffer */
V_OUTPUT_VERBOSE(30, "pessimist:\tsb\tgrow\toffset %llu\tlength %llu\tbase %p\tcursor %p", (unsigned long long) sb.sb_offset, (unsigned long long) sb.sb_length, (void *) sb.sb_addr, (void *) sb.sb_cursor);
}
@ -140,6 +193,9 @@ int32_t vprotocol_pessimist_sender_based_convertor_advance(ompi_convertor_t* pCo
preq = VPESSIMIST_CONV_REQ(pConvertor);
pConvertor->flags = preq->sb_conv_flags;
pConvertor->fAdvance = preq->sb_conv_advance;
#if 0
V_OUTPUT_VERBOSE(1, "%p\t%0x\t%p", pConvertor, pConvertor->flags & CONVERTOR_NO_OP, pConvertor->fAdvance);
#endif
ret = ompi_convertor_pack(pConvertor, iov, out_size, max_data);
V_OUTPUT_VERBOSE(39, "pessimist:\tsb\tpack\t%lu", *max_data);

Просмотреть файл

@ -14,13 +14,14 @@
#include "vprotocol_pessimist_request.h"
#include "ompi/mca/pml/base/pml_base_sendreq.h"
BEGIN_C_DECLS
/* There is several different ways of packing the data to the sender-based
* buffer. Just pick one.
*/
#undef SB_USE_PACK_METHOD
#define SB_USE_PACK_METHOD
#undef SB_USE_SELFCOMM_METHOD
#define SB_USE_CONVERTOR_METHOD
#undef SB_USE_CONVERTOR_METHOD
typedef struct vprotocol_pessimist_sender_based_t
@ -32,8 +33,12 @@ typedef struct vprotocol_pessimist_sender_based_t
#ifdef SB_USE_SELF_METHOD
ompi_communicator_t *sb_comm;
#endif
#if defined __WINDOWS__
HANDLE sb_fd; /* file handle of mapped file */
HANDLE sb_map; /* view handle of mapped file */
#else
int sb_fd; /* file descriptor of mapped file */
#endif
off_t sb_offset; /* offset in mmaped file */
uintptr_t sb_addr; /* base address of mmaped segment */
@ -153,7 +158,7 @@ int32_t vprotocol_pessimist_sender_based_convertor_advance(ompi_convertor_t*,
#define VPESSIMIST_CONV_REQ(CONV) ((mca_vprotocol_pessimist_send_request_t *) \
(mca_vprotocol_pessimist.sender_based.sb_conv_to_pessimist_offset + \
(uintptr_t) (CONV)))
(uintptr_t) ((CONV)->clone_of)))
/*******************************************************************************
@ -184,4 +189,6 @@ int32_t vprotocol_pessimist_sender_based_convertor_advance(ompi_convertor_t*,
#endif /* SB_USE_*_METHOD */
END_C_DECLS
#endif