diff --git a/config/ompi_check_gpfs.m4 b/config/ompi_check_gpfs.m4 new file mode 100644 index 0000000000..7fe4632dce --- /dev/null +++ b/config/ompi_check_gpfs.m4 @@ -0,0 +1,47 @@ +# OMPI_CHECK_GPFS(prefix, [action-if-found], [action-if-not-found]) +# -------------------------------------------------------- +# check if GPFS support can be found. Sets prefix_{CPPFLAGS, +# LDFLAGS, LIBS} as needed and runs action-if-found if there is +# support, otherwise executes action-if-not-found + +AC_DEFUN([OMPI_CHECK_GPFS],[ + + check_gpfs_CPPFLAGS= + check_gpfs_LDFLAGS= + check_gpfs_LIBS= + + check_gpfs_save_LIBS="$LIBS" + check_gpfs_save_LDFLAGS="$LDFLAGS" + check_gpfs_save_CPPFLAGS="$CPPFLAGS" + + check_gpfs_configuration="none" + ompi_check_gpfs_happy="yes" + + + # Get some configuration information + AC_ARG_WITH([gpfs], + [AC_HELP_STRING([--with-gpfs(=DIR)], + [Build GPFS support, optionally adding DIR/include, DIR/lib, and DIR/lib64 to the search path for headers and libraries])]) + OPAL_CHECK_WITHDIR([gpfs], [$with_gpfs], [include/gpfs.h]) + + AS_IF([test -z "$with_gpfs"], + [ompi_check_gpfs_dir="/usr"], + [ompi_check_gpfs_dir="$with_gpfs"]) + + if test -e "$ompi_check_gpfs_dir/lib64" ; then + ompi_check_gpfs_libdir="$ompi_check_gpfs_dir/lib64" + else + ompi_check_gpfs_libdir="$ompi_check_gpfs_dir/lib" + fi + + # Add correct -I and -L flags + OPAL_CHECK_PACKAGE([$1], [gpfs.h], [gpfs], [gpfs_lib_init], [], + [$ompi_check_gpfs_dir], [$ompi_check_gpfs_libdir], [ompi_check_gpfs_happy="yes"], + [ompi_check_gpfs_happy="no"], [#include ]) + + AS_IF([test "$ompi_check_gpfs_happy" = "yes"], + [$2], + [AS_IF([test ! -z "$with_gpfs" -a "$with_gpfs" != "no"], + [echo GPFS support not found]) + $3]) +]) diff --git a/ompi/mca/common/ompio/common_ompio.h b/ompi/mca/common/ompio/common_ompio.h index ef7cc4c427..13f8850be4 100644 --- a/ompi/mca/common/ompio/common_ompio.h +++ b/ompi/mca/common/ompio/common_ompio.h @@ -107,7 +107,8 @@ enum ompio_fs_type PVFS2 = 2, LUSTRE = 3, PLFS = 4, - IME = 5 + IME = 5, + GPFS = 6 }; typedef struct mca_common_ompio_io_array_t { diff --git a/ompi/mca/fs/gpfs/Makefile.am b/ompi/mca/fs/gpfs/Makefile.am new file mode 100644 index 0000000000..9a0138e2e3 --- /dev/null +++ b/ompi/mca/fs/gpfs/Makefile.am @@ -0,0 +1,58 @@ +# +# 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. +# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, +# University of Stuttgart. All rights reserved. +# Copyright (c) 2004-2005 The Regents of the University of California. +# All rights reserved. +# Copyright (c) 2008-2011 University of Houston. All rights reserved. +# $COPYRIGHT$ +# +# Additional copyrights may follow +# +# $HEADER$ +# + +# Make the output library in this directory, and name it either +# mca__.la (for DSO builds) or libmca__.la +# (for static builds). + +if MCA_BUILD_ompi_fs_gpfs_DSO +component_noinst = +component_install = mca_fs_gpfs.la +else +component_noinst = libmca_fs_gpfs.la +component_install = +endif + +# Source files + +fs_gpfs_sources = \ + fs_gpfs_component.c \ + fs_gpfs_file_close.c \ + fs_gpfs_file_delete.c \ + fs_gpfs_file_get_size.c \ + fs_gpfs_file_open.c \ + fs_gpfs_file_set_info.c\ + fs_gpfs_file_set_size.c \ + fs_gpfs_file_sync.c \ + fs_gpfs.c \ + fs_gpfs.h + +AM_CPPFLAGS = $(fs_gpfs_CPPFLAGS) + +mcacomponentdir = $(pkglibdir) +mcacomponent_LTLIBRARIES = $(component_install) +mca_fs_gpfs_la_SOURCES = $(fs_gpfs_sources) +mca_fs_gpfs_la_LIBADD = $(fs_gpfs_LIBS) +mca_fs_gpfs_la_LDFLAGS = -module -avoid-version $(fs_gpfs_LDFLAGS) + +noinst_LTLIBRARIES = $(component_noinst) +libmca_fs_gpfs_la_SOURCES = $(fs_gpfs_sources) +libmca_fs_gpfs_la_LIBADD = $(fs_gpfs_LIBS) +libmca_fs_gpfs_la_LDFLAGS = -module -avoid-version $(fs_gpfs_LDFLAGS) + diff --git a/ompi/mca/fs/gpfs/configure.m4 b/ompi/mca/fs/gpfs/configure.m4 new file mode 100644 index 0000000000..ce88f2b39b --- /dev/null +++ b/ompi/mca/fs/gpfs/configure.m4 @@ -0,0 +1,43 @@ +# -*- shell-script -*- +# +# 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. +# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, +# University of Stuttgart. All rights reserved. +# Copyright (c) 2004-2005 The Regents of the University of California. +# All rights reserved. +# Copyright (c) 2010 Cisco Systems, Inc. All rights reserved. +# Copyright (c) 2008-2012 University of Houston. All rights reserved. +# $COPYRIGHT$ +# +# Additional copyrights may follow +# +# $HEADER$ +# + + +# MCA_fs_gpfs_CONFIG(action-if-can-compile, +# [action-if-cant-compile]) +# ------------------------------------------------ +AC_DEFUN([MCA_ompi_fs_gpfs_CONFIG],[ + AC_CONFIG_FILES([ompi/mca/fs/gpfs/Makefile]) + + OMPI_CHECK_GPFS([fs_gpfs], + [fs_gpfs_happy="yes"], + [fs_gpfs_happy="no"]) + + AS_IF([test "$fs_gpfs_happy" = "yes"], + [fs_gpfs_WRAPPER_EXTRA_LDFLAGS="$fs_gpfs_LDFLAGS" + fs_gpfs_WRAPPER_EXTRA_LIBS="$fs_gpfs_LIBS" + $1], + [$2]) + + # substitute in the things needed to build gpfs + AC_SUBST([fs_gpfs_CPPFLAGS]) + AC_SUBST([fs_gpfs_LDFLAGS]) + AC_SUBST([fs_gpfs_LIBS]) +])dnl diff --git a/ompi/mca/fs/gpfs/fs_gpfs.c b/ompi/mca/fs/gpfs/fs_gpfs.c new file mode 100644 index 0000000000..7572a534e4 --- /dev/null +++ b/ompi/mca/fs/gpfs/fs_gpfs.c @@ -0,0 +1,132 @@ +/* -*- Mode: C; c-basic-offset:4 ; -*- */ +/* + * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana + * University Research and Technology + * Corporation. All rights reserved. + * Copyright (c) 2004-2007 The University of Tennessee and The University + * of Tennessee Research Foundation. All rights + * reserved. + * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, + * University of Stuttgart. All rights reserved. + * Copyright (c) 2004-2005 The Regents of the University of California. + * All rights reserved. + * Copyright (c) 2008-2012 University of Houston. All rights reserved. + * Copyright (c) 2011 Cisco Systems, Inc. All rights reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "ompi_config.h" +#include "mpi.h" +#include "ompi/mca/fs/fs.h" +#include "ompi/mca/fs/base/base.h" +#include "ompi/mca/fs/gpfs/fs_gpfs.h" + +#ifdef HAVE_SYS_STATFS_H +#include /* or */ +#endif +#ifdef HAVE_SYS_PARAM_H +#include +#endif +#ifdef HAVE_SYS_MOUNT_H +#include +#endif +#ifdef HAVE_SYS_STAT_H +#include +#endif + +/* + * ******************************************************************* + * ************************ actions structure ************************ + * ******************************************************************* + */ +static mca_fs_base_module_1_0_0_t gpfs = { mca_fs_gpfs_module_init, /* initialize after being selected */ +mca_fs_gpfs_module_finalize, /* close a module on a communicator */ +mca_fs_gpfs_file_open, mca_fs_gpfs_file_close, mca_fs_gpfs_file_delete, + mca_fs_gpfs_file_set_size, mca_fs_gpfs_file_get_size, + mca_fs_gpfs_file_set_info, mca_fs_gpfs_file_sync }; +/* + * ******************************************************************* + * ************************* structure ends ************************** + * ******************************************************************* + */ + +int mca_fs_gpfs_component_init_query(bool enable_progress_threads, + bool enable_mpi_threads) { + /* Nothing to do */ + + return OMPI_SUCCESS; +} + +struct mca_fs_base_module_1_0_0_t * +mca_fs_gpfs_component_file_query(mca_io_ompio_file_t *fh, int *priority) { + int err; + char *dir; + struct statfs fsbuf; + char *tmp; + + /* The code in this function is based on the ADIO FS selection in ROMIO + * Copyright (C) 1997 University of Chicago. + * See COPYRIGHT notice in top-level directory. + */ + *priority = mca_fs_gpfs_priority; + + tmp = strchr(fh->f_filename, ':'); + if (!tmp) { + if (OMPIO_ROOT == fh->f_rank) { + do { + err = statfs(fh->f_filename, &fsbuf); + } while (err && (errno == ESTALE)); + + if (err && (errno == ENOENT)) { + mca_fs_base_get_parent_dir(fh->f_filename, &dir); + err = statfs(dir, &fsbuf); + free(dir); + } + +#ifndef GPFS_SUPER_MAGIC +#define GPFS_SUPER_MAGIC 0x47504653 /* Thats GPFS in ASCII */ +#endif + if (fsbuf.f_type == GPFS_SUPER_MAGIC) { + fh->f_fstype = GPFS; + } + } + fh->f_comm->c_coll.coll_bcast(&(fh->f_fstype), 1, + MPI_INT, + OMPIO_ROOT, fh->f_comm, fh->f_comm->c_coll.coll_bcast_module); + } else { + if (!strncmp(fh->f_filename, "gpfs:", 5) + || !strncmp(fh->f_filename, "GPFS:", 5)) { + fh->f_fstype = GPFS; + } + } + + if (GPFS == fh->f_fstype) { + if (*priority < 50) { + *priority = 50; + return &gpfs; + } + } + + return NULL; +} + +int mca_fs_gpfs_component_file_unquery(mca_io_ompio_file_t *file) { + /* This function might be needed for some purposes later. for now it + * does not have anything to do since there are no steps which need + * to be undone if this module is not selected */ + + return OMPI_SUCCESS; +} + +int mca_fs_gpfs_module_init(mca_io_ompio_file_t *file) { + return OMPI_SUCCESS; +} + +int mca_fs_gpfs_module_finalize(mca_io_ompio_file_t *file) { + return OMPI_SUCCESS; +} + diff --git a/ompi/mca/fs/gpfs/fs_gpfs.h b/ompi/mca/fs/gpfs/fs_gpfs.h new file mode 100644 index 0000000000..a4d881282a --- /dev/null +++ b/ompi/mca/fs/gpfs/fs_gpfs.h @@ -0,0 +1,84 @@ +/* -*- Mode: C; c-basic-offset:4 ; -*- */ +/* + * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana + * University Research and Technology + * Corporation. All rights reserved. + * Copyright (c) 2004-2007 The University of Tennessee and The University + * of Tennessee Research Foundation. All rights + * reserved. + * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, + * University of Stuttgart. All rights reserved. + * Copyright (c) 2004-2005 The Regents of the University of California. + * All rights reserved. + * Copyright (c) 2008-2012 University of Houston. All rights reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#ifndef MCA_FS_GPFS_H +#define MCA_FS_GPFS_H + +#include "ompi_config.h" +#include "opal/mca/mca.h" +#include "ompi/mca/fs/fs.h" +#include "ompi/mca/io/ompio/io_ompio.h" + +#include + +extern int mca_fs_gpfs_priority; + +BEGIN_C_DECLS + +int mca_fs_gpfs_component_init_query(bool enable_progress_threads, + bool enable_mpi_threads); +struct mca_fs_base_module_1_0_0_t * +mca_fs_gpfs_component_file_query(mca_io_ompio_file_t *fh, int *priority); +int mca_fs_gpfs_component_file_unquery(mca_io_ompio_file_t *file); + +int mca_fs_gpfs_module_init(mca_io_ompio_file_t *file); +int mca_fs_gpfs_module_finalize(mca_io_ompio_file_t *file); +OMPI_MODULE_DECLSPEC extern mca_fs_base_component_2_0_0_t mca_fs_gpfs_component; + +/* + * ****************************************************************** + * ********* functions which are implemented in this module ********* + * ****************************************************************** + */ + +int mca_fs_gpfs_file_open(struct ompi_communicator_t *comm, char *filename, + int amode, struct ompi_info_t *info, struct mca_io_ompio_file_t *fh); +int mca_fs_gpfs_file_close(struct mca_io_ompio_file_t *fh); +int mca_fs_gpfs_file_delete(char *filename, struct ompi_info_t *info); +int mca_fs_gpfs_file_set_size(struct mca_io_ompio_file_t *fh, + OMPI_MPI_OFFSET_TYPE size); +int mca_fs_gpfs_file_get_size(struct mca_io_ompio_file_t *fh, + OMPI_MPI_OFFSET_TYPE * size); +int mca_fs_gpfs_file_get_amode(struct ompi_file_t *fh, int *amode); +int mca_fs_gpfs_file_set_info(struct mca_io_ompio_file_t *fh, + struct ompi_info_t *info); +//int mca_fs_gpfs_file_get_info(struct ompi_file_t *fh, + //struct ompi_info_t **info_used); +int mca_fs_gpfs_prefetch_hints(int access_mode, + mca_io_ompio_file_t *fh, struct ompi_info_t *info); +int mca_fs_gpfs_io_selection(mca_io_ompio_file_t *fh, + struct ompi_info_t *info, struct ompi_info_t *info_selected); +int mca_fs_gpfs_file_sync(struct ompi_file_t *fh); +int +mca_fs_gpfs_file_seek(struct ompi_file_t *fh, OMPI_MPI_OFFSET_TYPE off, + int whence); +int +mca_fs_gpfs_file_get_position(struct ompi_file_t *fh, + OMPI_MPI_OFFSET_TYPE *offset); + +/* + * ****************************************************************** + * ************ functions implemented in this module end ************ + * ****************************************************************** + */ + +END_C_DECLS + +#endif /* MCA_FS_GPFS_H */ diff --git a/ompi/mca/fs/gpfs/fs_gpfs_component.c b/ompi/mca/fs/gpfs/fs_gpfs_component.c new file mode 100644 index 0000000000..dce4f5d7c9 --- /dev/null +++ b/ompi/mca/fs/gpfs/fs_gpfs_component.c @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2004-2007 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. + * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, + * University of Stuttgart. All rights reserved. + * Copyright (c) 2004-2005 The Regents of the University of California. + * All rights reserved. + * Copyright (c) 2008-2011 University of Houston. All rights reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "ompi_config.h" +#include "mpi.h" +#include "fs_gpfs.h" + +/* + * Public string showing the fs gpfs component version number + */ +const char *mca_fs_gpfs_component_version_string = + "OMPI/MPI gpfs FS MCA component version " OMPI_VERSION; + +static int gpfs_register(void); + +int mca_fs_gpfs_priority = 20; + +/* + * Instantiate the public struct with all of our public information + * and pointers to our public functions in it + */ +mca_fs_base_component_2_0_0_t mca_fs_gpfs_component = { + + /* First, the mca_component_t struct containing meta information + about the component itself */ + + { + MCA_FS_BASE_VERSION_2_0_0, + + /* Component name and version */ + "gpfs", + OMPI_MAJOR_VERSION, + OMPI_MINOR_VERSION, + OMPI_RELEASE_VERSION, + NULL, + NULL, + NULL, + gpfs_register + }, + { + /* This component is checkpointable */ + MCA_BASE_METADATA_PARAM_CHECKPOINT + }, + mca_fs_gpfs_component_init_query, /* get thread level */ + mca_fs_gpfs_component_file_query, /* get priority and actions */ + mca_fs_gpfs_component_file_unquery /* undo what was done by previous function */ +}; + +static int +gpfs_register(void) +{ + mca_fs_gpfs_priority = 20; + (void) mca_base_component_var_register(&mca_fs_gpfs_component.fsm_version, + "priority", "Priority of the gpfs fs component", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, &mca_fs_gpfs_priority); + return OMPI_SUCCESS; +} \ No newline at end of file diff --git a/ompi/mca/fs/gpfs/fs_gpfs_file_close.c b/ompi/mca/fs/gpfs/fs_gpfs_file_close.c new file mode 100644 index 0000000000..e91acce667 --- /dev/null +++ b/ompi/mca/fs/gpfs/fs_gpfs_file_close.c @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana + * University Research and Technology + * Corporation. All rights reserved. + * Copyright (c) 2004-2011 The University of Tennessee and The University + * of Tennessee Research Foundation. All rights + * reserved. + * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, + * University of Stuttgart. All rights reserved. + * Copyright (c) 2004-2005 The Regents of the University of California. + * All rights reserved. + * Copyright (c) 2008-2011 University of Houston. All rights reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + + +#include "ompi_config.h" +#include "fs_gpfs.h" +#include "gpfs.h" + +#include +#include +#include "mpi.h" +#include "ompi/constants.h" +#include "ompi/mca/fs/fs.h" + +/* + * file_close_gpfs + * + * Function: - closes a new file + * Accepts: - file handle + * Returns: - Success if file closed + */ +int +mca_fs_gpfs_file_close (mca_io_ompio_file_t *fh) +{ + printf("Using mca_fs_gpfs_file_close to close a file.\n"); + + fh->f_comm->c_coll.coll_barrier (fh->f_comm, + fh->f_comm->c_coll.coll_barrier_module); + /* close (*(int *)fh->fd);*/ + close (fh->fd); + + return OMPI_SUCCESS; +} diff --git a/ompi/mca/fs/gpfs/fs_gpfs_file_delete.c b/ompi/mca/fs/gpfs/fs_gpfs_file_delete.c new file mode 100644 index 0000000000..19440c8010 --- /dev/null +++ b/ompi/mca/fs/gpfs/fs_gpfs_file_delete.c @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana + * University Research and Technology + * Corporation. All rights reserved. + * Copyright (c) 2004-2011 The University of Tennessee and The University + * of Tennessee Research Foundation. All rights + * reserved. + * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, + * University of Stuttgart. All rights reserved. + * Copyright (c) 2004-2005 The Regents of the University of California. + * All rights reserved. + * Copyright (c) 2008-2011 University of Houston. All rights reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + + +#include "ompi_config.h" +#include "fs_gpfs.h" +#include + +#include "mpi.h" +#include "ompi/constants.h" +#include "ompi/mca/fs/fs.h" + +/* + * file_delete_lustre + * + * Function: - deletes a file + * Accepts: - file name & info + * Returns: - Success if file closed + */ +int +mca_fs_gpfs_file_delete (char *filename, + struct ompi_info_t *info) +{ + printf("Using mca_fs_gpfs_file_delete to delete a file.\n"); + int ret = OMPI_SUCCESS; + + ret = unlink(filename); + + if (0 > ret) { + return OMPI_ERROR; + } + + return OMPI_SUCCESS; +} diff --git a/ompi/mca/fs/gpfs/fs_gpfs_file_get_size.c b/ompi/mca/fs/gpfs/fs_gpfs_file_get_size.c new file mode 100644 index 0000000000..84f88cdc67 --- /dev/null +++ b/ompi/mca/fs/gpfs/fs_gpfs_file_get_size.c @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana + * University Research and Technology + * Corporation. All rights reserved. + * Copyright (c) 2004-2011 The University of Tennessee and The University + * of Tennessee Research Foundation. All rights + * reserved. + * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, + * University of Stuttgart. All rights reserved. + * Copyright (c) 2004-2005 The Regents of the University of California. + * All rights reserved. + * Copyright (c) 2008-2011 University of Houston. All rights reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + + +#include "ompi_config.h" +#include "fs_gpfs.h" + +#include "mpi.h" +#include "ompi/constants.h" +#include "ompi/mca/fs/fs.h" + +/* + * file_get_size_gpfs + * + * Function: - get_size of a file + * Accepts: - same arguments as MPI_File_get_size() + * Returns: - Success if size is get + */ +int +mca_fs_gpfs_file_get_size (mca_io_ompio_file_t *fh, + OMPI_MPI_OFFSET_TYPE *size) +{ + printf ("GPFS GET SIZE\n"); + *size = lseek(fh->fd, 0, SEEK_END); + if (-1 == *size) { + perror ("lseek"); + return OMPI_ERROR; + } + + if (-1 == (lseek(fh->fd, fh->f_offset, SEEK_SET))) { + perror ("lseek"); + return OMPI_ERROR; + } + return OMPI_SUCCESS; +} diff --git a/ompi/mca/fs/gpfs/fs_gpfs_file_open.c b/ompi/mca/fs/gpfs/fs_gpfs_file_open.c new file mode 100644 index 0000000000..7f0badd7cc --- /dev/null +++ b/ompi/mca/fs/gpfs/fs_gpfs_file_open.c @@ -0,0 +1,159 @@ +/* + * 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. + * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, + * University of Stuttgart. All rights reserved. + * Copyright (c) 2004-2005 The Regents of the University of California. + * All rights reserved. + * Copyright (c) 2008-2012 University of Houston. All rights reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "ompi_config.h" + +#include "ompi/communicator/communicator.h" +#include "ompi/info/info.h" +#include "ompi/file/file.h" +#include "ompi/mca/fs/fs.h" +#include "ompi/mca/fs/base/base.h" +#include "ompi/mca/fcoll/fcoll.h" +#include "ompi/mca/fcoll/base/base.h" +#include "ompi/mca/fbtl/fbtl.h" +#include "ompi/mca/fbtl/base/base.h" +#include "fs_gpfs.h" + +#include +#include + +#include +#include +#include +#include +#include + +int +mca_fs_gpfs_file_open (struct ompi_communicator_t *comm, + char* filename, + int access_mode, + struct ompi_info_t *info, + mca_io_ompio_file_t *fh) +{ + int amode; + int old_mask, perm; + + if (fh->f_perm == OMPIO_PERM_NULL) { + old_mask = umask(022); + umask(old_mask); + perm = old_mask ^ 0666; + } + else { + perm = fh->f_perm; + } + + amode = 0; + + if (access_mode & MPI_MODE_CREATE) + amode = amode | O_CREAT; + if (access_mode & MPI_MODE_RDONLY) + amode = amode | O_RDONLY; + if (access_mode & MPI_MODE_WRONLY) + amode = amode | O_WRONLY; + if (access_mode & MPI_MODE_RDWR) + amode = amode | O_RDWR; + if (access_mode & MPI_MODE_EXCL) + amode = amode | O_EXCL; + + printf("Opening a file using Linux open() within fs_gpfs_file_open\n"); + + // for DEBUG + //int gdb = 0; + //char hostname[256]; + //gethostname(hostname, sizeof(hostname)); + //printf("PID %d on %s ready for attach\n", getpid(), hostname); + //fflush(stdout); + //while (0 == gdb) + //sleep(5); + + fh->fd = open (filename, amode, perm); + if (-1 == fh->fd) { + return OMPI_ERROR; + } + + fh->f_amode=access_mode; + //Setting GPFS Hints + mca_fs_gpfs_file_set_info(fh, info); + + return OMPI_SUCCESS; +} + +int +mca_fs_gpfs_file_get_amode (ompi_file_t *fh, + int *amode) +{ + mca_io_ompio_data_t *data; + + data = (mca_io_ompio_data_t *) fh->f_io_selected_data; + + *amode = data->ompio_fh.f_amode; + + return OMPI_SUCCESS; +} + +int mca_fs_gpfs_file_seek(ompi_file_t *fh, OMPI_MPI_OFFSET_TYPE off, int whence) { + printf("GPFS FILE SEEK!"); + int ret = OMPI_SUCCESS; + mca_io_ompio_data_t *data; + OMPI_MPI_OFFSET_TYPE offset, temp_offset; + + data = (mca_io_ompio_data_t *) fh->f_io_selected_data; + + offset = off * data->ompio_fh.f_etype_size; + + switch (whence) { + case MPI_SEEK_SET: + if (offset < 0) { + return OMPI_ERROR; + } + break; + case MPI_SEEK_CUR: + offset += data->ompio_fh.f_position_in_file_view; + offset += data->ompio_fh.f_disp; + if (offset < 0) { + return OMPI_ERROR; + } + break; + case MPI_SEEK_END: + ret = data->ompio_fh.f_fs->fs_file_get_size(&data->ompio_fh, + &temp_offset); + offset += temp_offset; + if (offset < 0 || OMPI_SUCCESS != ret) { + return OMPI_ERROR; + } + break; + default: + return OMPI_ERROR; + } + + ret = ompi_io_ompio_set_explicit_offset(&data->ompio_fh, offset + / data->ompio_fh.f_etype_size); + return ret; +} + +int mca_fs_gpfs_file_get_position(ompi_file_t *fh, OMPI_MPI_OFFSET_TYPE *offset) { + mca_io_ompio_data_t *data; + + data = (mca_io_ompio_data_t *) fh->f_io_selected_data; + + *offset = data->ompio_fh.f_position_in_file_view + / data->ompio_fh.f_etype_size; + + return OMPI_SUCCESS; +} diff --git a/ompi/mca/fs/gpfs/fs_gpfs_file_set_info.c b/ompi/mca/fs/gpfs/fs_gpfs_file_set_info.c new file mode 100755 index 0000000000..1be9411736 --- /dev/null +++ b/ompi/mca/fs/gpfs/fs_gpfs_file_set_info.c @@ -0,0 +1,1052 @@ +/* + * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana + * University Research and Technology + * Corporation. All rights reserved. + * Copyright (c) 2004-2011 The University of Tennessee and The University + * of Tennessee Research Foundation. All rights + * reserved. + * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, + * University of Stuttgart. All rights reserved. + * Copyright (c) 2004-2005 The Regents of the University of California. + * All rights reserved. + * Copyright (c) 2008-2011 University of Houston. All rights reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "ompi_config.h" +#include "fs_gpfs.h" +#include "mpi.h" +#include "ompi/constants.h" +#include "ompi/mca/fs/fs.h" + +#include +#include + +#include +#include +#include +#include + +/* + * file_set_info_gpfs + * + * Function: - set_info of a file + * Accepts: - same arguments as MPI_File_set_info() + * Returns: - Success if info is set + */ + +/*struct { + gpfsFcntlHeader_t gpfsFcntlHeader; + gpfsAccessRange_t gpfsAccessRange; + gpfsFreeRange_t gpfsFreeRange; + gpfsRangeArray_t gpfsRangeArray; + gpfsMultipleAccessRange_t gpfsMultipleAccessRange; + gpfsClearFileCache_t gpfsClearFileCache; + gpfsCancelHints_t gpfsCancelHints; + gpfsDataShipStart_t gpfsDataShipStart; + gpfsDataShipMap_t gpfsDataShipMap; + gpfsDataShipMapVariable_t gpfsDataShipMapVariable; + gpfsDataShipStop_t gpfsDataShipStop; + gpfsSetReplication_t gpfsSetReplication; + gpfsSetStoragePool_t gpfsSetStoragePool; + gpfsByteRange_t gpfsByteRange; + gpfsRestripeData_t gpfsRestripeData; + gpfsRestripeRange_t gpfsRestripeRange; + gpfsGetReplication_t gpfsGetReplication; + gpfsGetStoragePool_t gpfsGetStoragePool; + gpfsGetFilesetName_t gpfsGetFilesetName; + gpfsGetSnapshotName_t gpfsGetSnapshotName; + gpfsSetImmutable_t gpfsSetImmutable; + gpfsGetImmutable_t gpfsGetImmutable; + gpfsSetExpTime_t gpfsSetExpTime; + gpfsGetExpTime_t gpfsGetExpTime; + gpfsSetAppendOnly_t gpfsSetAppendOnly; + gpfsGetAppendOnly_t gpfsGetAppendOnly; +} all_gpfs_hints;*/ + +struct { + gpfsFcntlHeader_t gpfsFcntlHeader; + gpfsAccessRange_t gpfsAccessRange; +} gpfs_hints_1; + +struct { + gpfsFcntlHeader_t gpfsFcntlHeader; + gpfsFreeRange_t gpfsFreeRange; +} gpfs_hints_2; + +struct { + gpfsFcntlHeader_t gpfsFcntlHeader; + gpfsRangeArray_t gpfsRangeArray; +} gpfs_hints_3; + +struct { + gpfsFcntlHeader_t gpfsFcntlHeader; + gpfsMultipleAccessRange_t gpfsMultipleAccessRange; +} gpfs_hints_4; + +struct { + gpfsFcntlHeader_t gpfsFcntlHeader; + gpfsClearFileCache_t gpfsClearFileCache; +} gpfs_hints_5; + +struct { + gpfsFcntlHeader_t gpfsFcntlHeader; + gpfsCancelHints_t gpfsCancelHints; +} gpfs_hints_6; + +struct { + gpfsFcntlHeader_t gpfsFcntlHeader; + gpfsDataShipStart_t gpfsDataShipStart; +} gpfs_hints_7; + +struct { + gpfsFcntlHeader_t gpfsFcntlHeader; + gpfsDataShipMap_t gpfsDataShipMap; +} gpfs_hints_8; + +struct { + gpfsFcntlHeader_t gpfsFcntlHeader; + gpfsDataShipMapVariable_t gpfsDataShipMapVariable; +} gpfs_hints_9; + +struct { + gpfsFcntlHeader_t gpfsFcntlHeader; + gpfsDataShipStop_t gpfsDataShipStop; +} gpfs_hints_10; + +struct { + gpfsFcntlHeader_t gpfsFcntlHeader; + gpfsSetReplication_t gpfsSetReplication; +} gpfs_hints_11; + +struct { + gpfsFcntlHeader_t gpfsFcntlHeader; + gpfsSetStoragePool_t gpfsSetStoragePool; +} gpfs_hints_12; + +struct { + gpfsFcntlHeader_t gpfsFcntlHeader; + gpfsByteRange_t gpfsByteRange; +} gpfs_hints_13; + +struct { + gpfsFcntlHeader_t gpfsFcntlHeader; + gpfsRestripeData_t gpfsRestripeData; +} gpfs_hints_14; + +//TODO +/*struct { + gpfsFcntlHeader_t gpfsFcntlHeader; + gpfsRestripeRange_t gpfsRestripeRange; +} gpfs_hints_15; + +struct { + gpfsFcntlHeader_t gpfsFcntlHeader; + gpfsGetReplication_t gpfsGetReplication; +} gpfs_hints_16; + +struct { + gpfsFcntlHeader_t gpfsFcntlHeader; + gpfsGetStoragePool_t gpfsGetStoragePool; +} gpfs_hints_17; + +struct { + gpfsFcntlHeader_t gpfsFcntlHeader; + gpfsGetFilesetName_t gpfsGetFilesetName; +} gpfs_hints_18; + +struct { + gpfsFcntlHeader_t gpfsFcntlHeader; + gpfsGetSnapshotName_t gpfsGetSnapshotName; +} gpfs_hints_19; + +struct { + gpfsFcntlHeader_t gpfsFcntlHeader; + gpfsSetImmutable_t gpfsSetImmutable; +} gpfs_hints_20; + +struct { + gpfsFcntlHeader_t gpfsFcntlHeader; + gpfsGetImmutable_t gpfsGetImmutable; +} gpfs_hints_21; + +struct { + gpfsFcntlHeader_t gpfsFcntlHeader; + gpfsSetExpTime_t gpfsSetExpTime; +} gpfs_hints_22; + +struct { + gpfsFcntlHeader_t gpfsFcntlHeader; + gpfsGetExpTime_t gpfsGetExpTime; +} gpfs_hints_23; + +struct { + gpfsFcntlHeader_t gpfsFcntlHeader; + gpfsSetAppendOnly_t gpfsSetAppendOnly; +} gpfs_hints_24; + +struct { + gpfsFcntlHeader_t gpfsFcntlHeader; + gpfsGetAppendOnly_t gpfsGetAppendOnly; +} gpfs_hints_25;*/ + +int mca_fs_gpfs_file_set_info(mca_io_ompio_file_t *fh, struct ompi_info_t *info) { + printf("GPFS SET INFO\n"); + int ret; + ret = mca_fs_gpfs_prefetch_hints(fh->f_amode, fh, info); + return ret; +} + +int mca_fs_gpfs_prefetch_hints(int access_mode, + mca_io_ompio_file_t *fh, struct ompi_info_t *info) { + + if (! (access_mode & MPI_MODE_RDONLY | access_mode & MPI_MODE_WRONLY + | access_mode & MPI_MODE_RDWR)) { + return OMPI_SUCCESS; + } + + gpfs_file_t gpfs_file_handle = fh->fd; + + int rc = 0, valueLen = MPI_MAX_INFO_VAL, flag; + char value[MPI_MAX_INFO_VAL + 1], gpfsHintsKey[50]; + const char* split = ","; + char* token; + int ret = OMPI_SUCCESS; + ompi_info_t *info_selected; + info_selected = info; + + strcpy(gpfsHintsKey, "useSIOXLib"); + ompi_info_get(info_selected, gpfsHintsKey, valueLen, value, &flag); + if (flag && strcmp(value, "true") == 0) { + //using the SIOX lib and the I/O pattern selection + ret = mca_fs_gpfs_io_selection(fh, info, info_selected); + if (ret != OMPI_SUCCESS) + return ret; + } + else { + //TODO Sending the MPI_INFO to SIOX for knowledgebase + } + + //Setting GPFS Hints 1 - gpfsAccessRange + strcpy(gpfsHintsKey, "sioxAccessRange"); + ompi_info_get(info_selected, gpfsHintsKey, valueLen, value, &flag); + if (flag) { + printf("GPFS Access Range is set: %s: %s\n", gpfsHintsKey, value); + gpfs_hints_1.gpfsFcntlHeader.totalLength = sizeof(gpfs_hints_1); + gpfs_hints_1.gpfsFcntlHeader.fcntlVersion = GPFS_FCNTL_CURRENT_VERSION; + gpfs_hints_1.gpfsFcntlHeader.fcntlReserved = 0; + + gpfs_hints_1.gpfsAccessRange.structLen = + sizeof(gpfs_hints_1.gpfsAccessRange); + gpfs_hints_1.gpfsAccessRange.structType = GPFS_ACCESS_RANGE; + token = strtok(value, split); + gpfs_hints_1.gpfsAccessRange.start = atol(token); + token = strtok(NULL, split); + gpfs_hints_1.gpfsAccessRange.length = atol(token); + token = strtok(NULL, split); + gpfs_hints_1.gpfsAccessRange.isWrite = atoi(token); + + rc = gpfs_fcntl(gpfs_file_handle, &gpfs_hints_1); + if (rc != 0) { + rc = errno; + printf( + "gpfs_hints_1 gpfs_fcntl(file handle: %d): Error number is %d, %s\n", + gpfs_file_handle, rc, strerror(rc)); + ret = OMPI_ERROR; + } + } + + //Setting GPFS Hints 2 - gpfsFreeRange + strcpy(gpfsHintsKey, "sioxFreeRange"); + ompi_info_get(info_selected, gpfsHintsKey, valueLen, value, &flag); + if (flag) { + printf("GPFS Free Range is set: %s: %s\n", gpfsHintsKey, value); + gpfs_hints_2.gpfsFcntlHeader.totalLength = sizeof(gpfs_hints_2); + gpfs_hints_2.gpfsFcntlHeader.fcntlVersion = GPFS_FCNTL_CURRENT_VERSION; + gpfs_hints_2.gpfsFcntlHeader.fcntlReserved = 0; + + gpfs_hints_2.gpfsFreeRange.structLen = + sizeof(gpfs_hints_2.gpfsFreeRange); + gpfs_hints_2.gpfsFreeRange.structType = GPFS_FREE_RANGE; + token = strtok(value, split); + gpfs_hints_2.gpfsFreeRange.start = atol(token); + token = strtok(NULL, split); + gpfs_hints_2.gpfsFreeRange.length = atol(token); + + rc = gpfs_fcntl(gpfs_file_handle, &gpfs_hints_2); + if (rc != 0) { + rc = errno; + printf( + "gpfs_hints_2 gpfs_fcntl(file handle: %d): Error number is %d, %s\n", + gpfs_file_handle, rc, strerror(rc)); + ret = OMPI_ERROR; + } + } + + //Setting GPFS Hints 3 - gpfsRangeArray + /*strcpy(gpfsHintsKey, "sioxFreeRange"); + ompi_info_get(info_selected, gpfsHintsKey, valueLen, value, &flag); + if (flag) { + printf("GPFS Free Range is set: %s: %s\n", gpfsHintsKey, value); + gpfs_hints_2.gpfsFcntlHeader.totalLength = sizeof(gpfs_hints_2); + gpfs_hints_2.gpfsFcntlHeader.fcntlVersion = GPFS_FCNTL_CURRENT_VERSION; + gpfs_hints_2.gpfsFcntlHeader.fcntlReserved = 0; + + gpfs_hints_2.gpfsFreeRange.structLen = + sizeof(gpfs_hints_2.gpfsFreeRange); + gpfs_hints_2.gpfsFreeRange.structType = GPFS_FREE_RANGE; + token = strtok(value, split); + gpfs_hints_2.gpfsFreeRange.start = atoi(token); + token = strtok(NULL, split); + gpfs_hints_2.gpfsFreeRange.length = atoi(token); + + rc = gpfs_fcntl(gpfs_file_handle, &gpfs_hints_2); + if (rc != 0) { + rc = errno; + printf( + "gpfs_hints_2 gpfs_fcntl(file handle: %d): Error number is %d, %s\n", + gpfs_file_handle, rc, strerror(rc)); + ret = OMPI_ERROR; + } + }*/ + + //Setting GPFS Hints 4 - gpfsMultipleAccessRange + /*strcpy(gpfsHintsKey, "sioxFreeRange"); + ompi_info_get(info_selected, gpfsHintsKey, valueLen, value, &flag); + if (flag) { + printf("GPFS Free Range is set: %s: %s\n", gpfsHintsKey, value); + gpfs_hints_2.gpfsFcntlHeader.totalLength = sizeof(gpfs_hints_2); + gpfs_hints_2.gpfsFcntlHeader.fcntlVersion = GPFS_FCNTL_CURRENT_VERSION; + gpfs_hints_2.gpfsFcntlHeader.fcntlReserved = 0; + + gpfs_hints_2.gpfsFreeRange.structLen = + sizeof(gpfs_hints_2.gpfsFreeRange); + gpfs_hints_2.gpfsFreeRange.structType = GPFS_FREE_RANGE; + token = strtok(value, split); + gpfs_hints_2.gpfsFreeRange.start = atoi(token); + token = strtok(NULL, split); + gpfs_hints_2.gpfsFreeRange.length = atoi(token); + + rc = gpfs_fcntl(gpfs_file_handle, &gpfs_hints_2); + if (rc != 0) { + rc = errno; + printf( + "gpfs_hints_2 gpfs_fcntl(file handle: %d): Error number is %d, %s\n", + gpfs_file_handle, rc, strerror(rc)); + ret = OMPI_ERROR; + } + }*/ + + //Setting GPFS Hints 5 - gpfsClearFileCache + strcpy(gpfsHintsKey, "sioxClearFileCache"); + ompi_info_get(info_selected, gpfsHintsKey, valueLen, value, &flag); + if (flag & strcmp(value, "true") == 0) { + printf("GPFS Clear File Cache is set: %s: %s\n", gpfsHintsKey, value); + gpfs_hints_5.gpfsFcntlHeader.totalLength = sizeof(gpfs_hints_5); + gpfs_hints_5.gpfsFcntlHeader.fcntlVersion = GPFS_FCNTL_CURRENT_VERSION; + gpfs_hints_5.gpfsFcntlHeader.fcntlReserved = 0; + + gpfs_hints_5.gpfsClearFileCache.structLen = + sizeof(gpfs_hints_5.gpfsClearFileCache); + gpfs_hints_5.gpfsClearFileCache.structType = GPFS_CLEAR_FILE_CACHE; + + rc = gpfs_fcntl(gpfs_file_handle, &gpfs_hints_5); + if (rc != 0) { + rc = errno; + printf( + "gpfs_hints_5 gpfs_fcntl(file handle: %d): Error number is %d, %s\n", + gpfs_file_handle, rc, strerror(rc)); + ret = OMPI_ERROR; + } + } + + //Setting GPFS Hints 6 - gpfsCancelHints + strcpy(gpfsHintsKey, "sioxCancelHints"); + ompi_info_get(info_selected, gpfsHintsKey, valueLen, value, &flag); + if (flag & strcmp(value, "true") == 0) { + printf("GPFS Cancel Hints is set: %s: %s\n", gpfsHintsKey, value); + gpfs_hints_6.gpfsFcntlHeader.totalLength = sizeof(gpfs_hints_6); + gpfs_hints_6.gpfsFcntlHeader.fcntlVersion = GPFS_FCNTL_CURRENT_VERSION; + gpfs_hints_6.gpfsFcntlHeader.fcntlReserved = 0; + + gpfs_hints_6.gpfsCancelHints.structLen = + sizeof(gpfs_hints_6.gpfsCancelHints); + gpfs_hints_6.gpfsCancelHints.structType = GPFS_CANCEL_HINTS; + + rc = gpfs_fcntl(gpfs_file_handle, &gpfs_hints_6); + if (rc != 0) { + rc = errno; + printf( + "gpfs_hints_6 gpfs_fcntl(file handle: %d): Error number is %d, %s\n", + gpfs_file_handle, rc, strerror(rc)); + ret = OMPI_ERROR; + } + } + + //Setting GPFS Hints 7 - gpfsDataShipStart + strcpy(gpfsHintsKey, "sioxDataShipStart"); + ompi_info_get(info_selected, gpfsHintsKey, valueLen, value, &flag); + if (flag) { + printf("GPFS Data Ship Start is set: %s: %s\n", gpfsHintsKey, value); + gpfs_hints_7.gpfsFcntlHeader.totalLength = sizeof(gpfs_hints_7); + gpfs_hints_7.gpfsFcntlHeader.fcntlVersion = GPFS_FCNTL_CURRENT_VERSION; + gpfs_hints_7.gpfsFcntlHeader.fcntlReserved = 0; + + gpfs_hints_7.gpfsDataShipStart.structLen = + sizeof(gpfs_hints_7.gpfsDataShipStart); + gpfs_hints_7.gpfsDataShipStart.structType = GPFS_DATA_SHIP_START; + token = strtok(value, split); + gpfs_hints_7.gpfsDataShipStart.numInstances = atoi(token); + gpfs_hints_7.gpfsDataShipStart.reserved = 0; + + rc = gpfs_fcntl(gpfs_file_handle, &gpfs_hints_7); + if (rc != 0) { + rc = errno; + printf( + "gpfs_hints_7 gpfs_fcntl(file handle: %d): Error number is %d, %s\n", + gpfs_file_handle, rc, strerror(rc)); + ret = OMPI_ERROR; + } + } + + //Setting GPFS Hints 8 - gpfsDataShipMap + /*strcpy(gpfsHintsKey, "sioxDataShipStart"); + ompi_info_get(info_selected, gpfsHintsKey, valueLen, value, &flag); + if (flag) { + printf("GPFS Data Ship Start is set: %s: %s\n", gpfsHintsKey, value); + gpfs_hints_7.gpfsFcntlHeader.totalLength = sizeof(gpfs_hints_7); + gpfs_hints_7.gpfsFcntlHeader.fcntlVersion = GPFS_FCNTL_CURRENT_VERSION; + gpfs_hints_7.gpfsFcntlHeader.fcntlReserved = 0; + + gpfs_hints_7.gpfsDataShipStart.structLen = + sizeof(gpfs_hints_7.gpfsDataShipStart); + gpfs_hints_7.gpfsDataShipStart.structType = GPFS_DATA_SHIP_START; + token = strtok(value, split); + gpfs_hints_7.gpfsDataShipStart.numInstances = atoi(token); + gpfs_hints_7.gpfsDataShipStart.reserved = 0; + + rc = gpfs_fcntl(gpfs_file_handle, &gpfs_hints_7); + if (rc != 0) { + rc = errno; + printf( + "gpfs_hints_7 gpfs_fcntl(file handle: %d): Error number is %d, %s\n", + gpfs_file_handle, rc, strerror(rc)); + ret = OMPI_ERROR; + } + }*/ + + //Setting GPFS Hints 9 - gpfsDataShipMapVariable + /*strcpy(gpfsHintsKey, "sioxDataShipStart"); + ompi_info_get(info_selected, gpfsHintsKey, valueLen, value, &flag); + if (flag) { + printf("GPFS Data Ship Start is set: %s: %s\n", gpfsHintsKey, value); + gpfs_hints_7.gpfsFcntlHeader.totalLength = sizeof(gpfs_hints_7); + gpfs_hints_7.gpfsFcntlHeader.fcntlVersion = GPFS_FCNTL_CURRENT_VERSION; + gpfs_hints_7.gpfsFcntlHeader.fcntlReserved = 0; + + gpfs_hints_7.gpfsDataShipStart.structLen = + sizeof(gpfs_hints_7.gpfsDataShipStart); + gpfs_hints_7.gpfsDataShipStart.structType = GPFS_DATA_SHIP_START; + token = strtok(value, split); + gpfs_hints_7.gpfsDataShipStart.numInstances = atoi(token); + gpfs_hints_7.gpfsDataShipStart.reserved = 0; + + rc = gpfs_fcntl(gpfs_file_handle, &gpfs_hints_7); + if (rc != 0) { + rc = errno; + printf( + "gpfs_hints_7 gpfs_fcntl(file handle: %d): Error number is %d, %s\n", + gpfs_file_handle, rc, strerror(rc)); + ret = OMPI_ERROR; + } + }*/ + + //Setting GPFS Hints 10 - gpfsDataShipStop + strcpy(gpfsHintsKey, "sioxDataShipStop"); + ompi_info_get(info_selected, gpfsHintsKey, valueLen, value, &flag); + if (flag & strcmp(value, "true") == 0) { + printf("GPFS Data Ship Stop is set: %s: %s\n", gpfsHintsKey, value); + gpfs_hints_10.gpfsFcntlHeader.totalLength = sizeof(gpfs_hints_10); + gpfs_hints_10.gpfsFcntlHeader.fcntlVersion = GPFS_FCNTL_CURRENT_VERSION; + gpfs_hints_10.gpfsFcntlHeader.fcntlReserved = 0; + + gpfs_hints_10.gpfsDataShipStop.structLen = + sizeof(gpfs_hints_10.gpfsDataShipStop); + gpfs_hints_10.gpfsDataShipStop.structType = GPFS_DATA_SHIP_STOP; + + rc = gpfs_fcntl(gpfs_file_handle, &gpfs_hints_10); + if (rc != 0) { + rc = errno; + printf( + "gpfs_hints_10 gpfs_fcntl(file handle: %d): Error number is %d, %s\n", + gpfs_file_handle, rc, strerror(rc)); + ret = OMPI_ERROR; + } + } + + //Setting GPFS Hints 11 - gpfsSetReplication + strcpy(gpfsHintsKey, "sioxSetReplication"); + ompi_info_get(info_selected, gpfsHintsKey, valueLen, value, &flag); + if (flag) { + printf("GPFS Set Replication is set: %s: %s\n", gpfsHintsKey, value); + gpfs_hints_11.gpfsFcntlHeader.totalLength = sizeof(gpfs_hints_11); + gpfs_hints_11.gpfsFcntlHeader.fcntlVersion = GPFS_FCNTL_CURRENT_VERSION; + gpfs_hints_11.gpfsFcntlHeader.fcntlReserved = 0; + + gpfs_hints_11.gpfsSetReplication.structLen = + sizeof(gpfs_hints_11.gpfsSetReplication); + gpfs_hints_11.gpfsSetReplication.structType = GPFS_FCNTL_SET_REPLICATION; + token = strtok(value, split); + gpfs_hints_11.gpfsSetReplication.metadataReplicas = atoi(token); + gpfs_hints_11.gpfsSetReplication.maxMetadataReplicas = atoi(token); + gpfs_hints_11.gpfsSetReplication.dataReplicas = atoi(token); + gpfs_hints_11.gpfsSetReplication.maxDataReplicas = atoi(token); + gpfs_hints_11.gpfsSetReplication.reserved = 0; + + rc = gpfs_fcntl(gpfs_file_handle, &gpfs_hints_11); + if (rc != 0) { + rc = errno; + printf( + "gpfs_hints_11 gpfs_fcntl(file handle: %d): Error number is %d, %s\n", + gpfs_file_handle, rc, strerror(rc)); + ret = OMPI_ERROR; + } + } + + //Setting GPFS Hints 12 - gpfsSetStoragePool + /*strcpy(gpfsHintsKey, "sioxDataShipStart"); + ompi_info_get(info_selected, gpfsHintsKey, valueLen, value, &flag); + if (flag) { + printf("GPFS Data Ship Start is set: %s: %s\n", gpfsHintsKey, value); + gpfs_hints_7.gpfsFcntlHeader.totalLength = sizeof(gpfs_hints_7); + gpfs_hints_7.gpfsFcntlHeader.fcntlVersion = GPFS_FCNTL_CURRENT_VERSION; + gpfs_hints_7.gpfsFcntlHeader.fcntlReserved = 0; + + gpfs_hints_7.gpfsDataShipStart.structLen = + sizeof(gpfs_hints_7.gpfsDataShipStart); + gpfs_hints_7.gpfsDataShipStart.structType = GPFS_DATA_SHIP_START; + token = strtok(value, split); + gpfs_hints_7.gpfsDataShipStart.numInstances = atoi(token); + gpfs_hints_7.gpfsDataShipStart.reserved = 0; + + rc = gpfs_fcntl(gpfs_file_handle, &gpfs_hints_7); + if (rc != 0) { + rc = errno; + printf( + "gpfs_hints_7 gpfs_fcntl(file handle: %d): Error number is %d, %s\n", + gpfs_file_handle, rc, strerror(rc)); + ret = OMPI_ERROR; + } + }*/ + + //Setting GPFS Hints 13 - gpfsByteRange + strcpy(gpfsHintsKey, "sioxByteRange"); + ompi_info_get(info_selected, gpfsHintsKey, valueLen, value, &flag); + if (flag) { + printf("GPFS Byte Range is set: %s: %s\n", gpfsHintsKey, value); + gpfs_hints_13.gpfsFcntlHeader.totalLength = sizeof(gpfs_hints_13); + gpfs_hints_13.gpfsFcntlHeader.fcntlVersion = GPFS_FCNTL_CURRENT_VERSION; + gpfs_hints_13.gpfsFcntlHeader.fcntlReserved = 0; + + token = strtok(value, split); + gpfs_hints_13.gpfsByteRange.startOffset = atol(token); + token = strtok(value, split); + gpfs_hints_13.gpfsByteRange.numOfBlks = atol(token); + + rc = gpfs_fcntl(gpfs_file_handle, &gpfs_hints_13); + if (rc != 0) { + rc = errno; + printf( + "gpfs_hints_13 gpfs_fcntl(file handle: %d): Error number is %d, %s\n", + gpfs_file_handle, rc, strerror(rc)); + ret = OMPI_ERROR; + } + } + + //Setting GPFS Hints 14 - gpfsRestripeData + strcpy(gpfsHintsKey, "sioxRestripeData"); + ompi_info_get(info_selected, gpfsHintsKey, valueLen, value, &flag); + if (flag) { + printf("GPFS Restripe Data is set: %s: %s\n", gpfsHintsKey, value); + gpfs_hints_14.gpfsFcntlHeader.totalLength = sizeof(gpfs_hints_14); + gpfs_hints_14.gpfsFcntlHeader.fcntlVersion = GPFS_FCNTL_CURRENT_VERSION; + gpfs_hints_14.gpfsFcntlHeader.fcntlReserved = 0; + + gpfs_hints_14.gpfsRestripeData.structLen = + sizeof(gpfs_hints_14.gpfsRestripeData); + gpfs_hints_14.gpfsRestripeData.structType = GPFS_FCNTL_RESTRIPE_DATA; + token = strtok(value, split); + gpfs_hints_14.gpfsRestripeData.options = atoi(token); + gpfs_hints_14.gpfsRestripeData.reserved1 = 0; + gpfs_hints_14.gpfsRestripeData.reserved2 = 0; + + rc = gpfs_fcntl(gpfs_file_handle, &gpfs_hints_14); + if (rc != 0) { + rc = errno; + printf( + "gpfs_hints_14 gpfs_fcntl(file handle: %d): Error number is %d, %s\n", + gpfs_file_handle, rc, strerror(rc)); + ret = OMPI_ERROR; + } + } + + //Setting GPFS Hints 15 - gpfsRestripeRange + /*strcpy(gpfsHintsKey, "sioxDataShipStart"); + ompi_info_get(info_selected, gpfsHintsKey, valueLen, value, &flag); + if (flag) { + printf("GPFS Data Ship Start is set: %s: %s\n", gpfsHintsKey, value); + gpfs_hints_7.gpfsFcntlHeader.totalLength = sizeof(gpfs_hints_7); + gpfs_hints_7.gpfsFcntlHeader.fcntlVersion = GPFS_FCNTL_CURRENT_VERSION; + gpfs_hints_7.gpfsFcntlHeader.fcntlReserved = 0; + + gpfs_hints_7.gpfsDataShipStart.structLen = + sizeof(gpfs_hints_7.gpfsDataShipStart); + gpfs_hints_7.gpfsDataShipStart.structType = GPFS_DATA_SHIP_START; + token = strtok(value, split); + gpfs_hints_7.gpfsDataShipStart.numInstances = atoi(token); + gpfs_hints_7.gpfsDataShipStart.reserved = 0; + + rc = gpfs_fcntl(gpfs_file_handle, &gpfs_hints_7); + if (rc != 0) { + rc = errno; + printf( + "gpfs_hints_7 gpfs_fcntl(file handle: %d): Error number is %d, %s\n", + gpfs_file_handle, rc, strerror(rc)); + ret = OMPI_ERROR; + } + }*/ + + //Setting GPFS Hints 16 - gpfsGetReplication + /*strcpy(gpfsHintsKey, "sioxDataShipStart"); + ompi_info_get(info_selected, gpfsHintsKey, valueLen, value, &flag); + if (flag) { + printf("GPFS Data Ship Start is set: %s: %s\n", gpfsHintsKey, value); + gpfs_hints_7.gpfsFcntlHeader.totalLength = sizeof(gpfs_hints_7); + gpfs_hints_7.gpfsFcntlHeader.fcntlVersion = GPFS_FCNTL_CURRENT_VERSION; + gpfs_hints_7.gpfsFcntlHeader.fcntlReserved = 0; + + gpfs_hints_7.gpfsDataShipStart.structLen = + sizeof(gpfs_hints_7.gpfsDataShipStart); + gpfs_hints_7.gpfsDataShipStart.structType = GPFS_DATA_SHIP_START; + token = strtok(value, split); + gpfs_hints_7.gpfsDataShipStart.numInstances = atoi(token); + gpfs_hints_7.gpfsDataShipStart.reserved = 0; + + rc = gpfs_fcntl(gpfs_file_handle, &gpfs_hints_7); + if (rc != 0) { + rc = errno; + printf( + "gpfs_hints_7 gpfs_fcntl(file handle: %d): Error number is %d, %s\n", + gpfs_file_handle, rc, strerror(rc)); + ret = OMPI_ERROR; + } + }*/ + + //Setting GPFS Hints 17 - gpfsGetStoragePool + /*strcpy(gpfsHintsKey, "sioxDataShipStart"); + ompi_info_get(info_selected, gpfsHintsKey, valueLen, value, &flag); + if (flag) { + printf("GPFS Data Ship Start is set: %s: %s\n", gpfsHintsKey, value); + gpfs_hints_7.gpfsFcntlHeader.totalLength = sizeof(gpfs_hints_7); + gpfs_hints_7.gpfsFcntlHeader.fcntlVersion = GPFS_FCNTL_CURRENT_VERSION; + gpfs_hints_7.gpfsFcntlHeader.fcntlReserved = 0; + + gpfs_hints_7.gpfsDataShipStart.structLen = + sizeof(gpfs_hints_7.gpfsDataShipStart); + gpfs_hints_7.gpfsDataShipStart.structType = GPFS_DATA_SHIP_START; + token = strtok(value, split); + gpfs_hints_7.gpfsDataShipStart.numInstances = atoi(token); + gpfs_hints_7.gpfsDataShipStart.reserved = 0; + + rc = gpfs_fcntl(gpfs_file_handle, &gpfs_hints_7); + if (rc != 0) { + rc = errno; + printf( + "gpfs_hints_7 gpfs_fcntl(file handle: %d): Error number is %d, %s\n", + gpfs_file_handle, rc, strerror(rc)); + ret = OMPI_ERROR; + } + }*/ + + //Setting GPFS Hints 18 - gpfsGetFilesetName + /*strcpy(gpfsHintsKey, "sioxDataShipStart"); + ompi_info_get(info_selected, gpfsHintsKey, valueLen, value, &flag); + if (flag) { + printf("GPFS Data Ship Start is set: %s: %s\n", gpfsHintsKey, value); + gpfs_hints_7.gpfsFcntlHeader.totalLength = sizeof(gpfs_hints_7); + gpfs_hints_7.gpfsFcntlHeader.fcntlVersion = GPFS_FCNTL_CURRENT_VERSION; + gpfs_hints_7.gpfsFcntlHeader.fcntlReserved = 0; + + gpfs_hints_7.gpfsDataShipStart.structLen = + sizeof(gpfs_hints_7.gpfsDataShipStart); + gpfs_hints_7.gpfsDataShipStart.structType = GPFS_DATA_SHIP_START; + token = strtok(value, split); + gpfs_hints_7.gpfsDataShipStart.numInstances = atoi(token); + gpfs_hints_7.gpfsDataShipStart.reserved = 0; + + rc = gpfs_fcntl(gpfs_file_handle, &gpfs_hints_7); + if (rc != 0) { + rc = errno; + printf( + "gpfs_hints_7 gpfs_fcntl(file handle: %d): Error number is %d, %s\n", + gpfs_file_handle, rc, strerror(rc)); + ret = OMPI_ERROR; + } + }*/ + + //Setting GPFS Hints 19 - gpfsGetSnapshotName + /*strcpy(gpfsHintsKey, "sioxDataShipStart"); + ompi_info_get(info_selected, gpfsHintsKey, valueLen, value, &flag); + if (flag) { + printf("GPFS Data Ship Start is set: %s: %s\n", gpfsHintsKey, value); + gpfs_hints_7.gpfsFcntlHeader.totalLength = sizeof(gpfs_hints_7); + gpfs_hints_7.gpfsFcntlHeader.fcntlVersion = GPFS_FCNTL_CURRENT_VERSION; + gpfs_hints_7.gpfsFcntlHeader.fcntlReserved = 0; + + gpfs_hints_7.gpfsDataShipStart.structLen = + sizeof(gpfs_hints_7.gpfsDataShipStart); + gpfs_hints_7.gpfsDataShipStart.structType = GPFS_DATA_SHIP_START; + token = strtok(value, split); + gpfs_hints_7.gpfsDataShipStart.numInstances = atoi(token); + gpfs_hints_7.gpfsDataShipStart.reserved = 0; + + rc = gpfs_fcntl(gpfs_file_handle, &gpfs_hints_7); + if (rc != 0) { + rc = errno; + printf( + "gpfs_hints_7 gpfs_fcntl(file handle: %d): Error number is %d, %s\n", + gpfs_file_handle, rc, strerror(rc)); + ret = OMPI_ERROR; + } + }*/ + + //Setting GPFS Hints 20 - gpfsSetImmutable + /*strcpy(gpfsHintsKey, "sioxDataShipStart"); + ompi_info_get(info_selected, gpfsHintsKey, valueLen, value, &flag); + if (flag) { + printf("GPFS Data Ship Start is set: %s: %s\n", gpfsHintsKey, value); + gpfs_hints_7.gpfsFcntlHeader.totalLength = sizeof(gpfs_hints_7); + gpfs_hints_7.gpfsFcntlHeader.fcntlVersion = GPFS_FCNTL_CURRENT_VERSION; + gpfs_hints_7.gpfsFcntlHeader.fcntlReserved = 0; + + gpfs_hints_7.gpfsDataShipStart.structLen = + sizeof(gpfs_hints_7.gpfsDataShipStart); + gpfs_hints_7.gpfsDataShipStart.structType = GPFS_DATA_SHIP_START; + token = strtok(value, split); + gpfs_hints_7.gpfsDataShipStart.numInstances = atoi(token); + gpfs_hints_7.gpfsDataShipStart.reserved = 0; + + rc = gpfs_fcntl(gpfs_file_handle, &gpfs_hints_7); + if (rc != 0) { + rc = errno; + printf( + "gpfs_hints_7 gpfs_fcntl(file handle: %d): Error number is %d, %s\n", + gpfs_file_handle, rc, strerror(rc)); + ret = OMPI_ERROR; + } + }*/ + + //Setting GPFS Hints 21 - gpfsGetImmutable + /*strcpy(gpfsHintsKey, "sioxDataShipStart"); + ompi_info_get(info_selected, gpfsHintsKey, valueLen, value, &flag); + if (flag) { + printf("GPFS Data Ship Start is set: %s: %s\n", gpfsHintsKey, value); + gpfs_hints_7.gpfsFcntlHeader.totalLength = sizeof(gpfs_hints_7); + gpfs_hints_7.gpfsFcntlHeader.fcntlVersion = GPFS_FCNTL_CURRENT_VERSION; + gpfs_hints_7.gpfsFcntlHeader.fcntlReserved = 0; + + gpfs_hints_7.gpfsDataShipStart.structLen = + sizeof(gpfs_hints_7.gpfsDataShipStart); + gpfs_hints_7.gpfsDataShipStart.structType = GPFS_DATA_SHIP_START; + token = strtok(value, split); + gpfs_hints_7.gpfsDataShipStart.numInstances = atoi(token); + gpfs_hints_7.gpfsDataShipStart.reserved = 0; + + rc = gpfs_fcntl(gpfs_file_handle, &gpfs_hints_7); + if (rc != 0) { + rc = errno; + printf( + "gpfs_hints_7 gpfs_fcntl(file handle: %d): Error number is %d, %s\n", + gpfs_file_handle, rc, strerror(rc)); + ret = OMPI_ERROR; + } + }*/ + + //Setting GPFS Hints 22 - gpfsSetExpTime + /*strcpy(gpfsHintsKey, "sioxDataShipStart"); + ompi_info_get(info_selected, gpfsHintsKey, valueLen, value, &flag); + if (flag) { + printf("GPFS Data Ship Start is set: %s: %s\n", gpfsHintsKey, value); + gpfs_hints_7.gpfsFcntlHeader.totalLength = sizeof(gpfs_hints_7); + gpfs_hints_7.gpfsFcntlHeader.fcntlVersion = GPFS_FCNTL_CURRENT_VERSION; + gpfs_hints_7.gpfsFcntlHeader.fcntlReserved = 0; + + gpfs_hints_7.gpfsDataShipStart.structLen = + sizeof(gpfs_hints_7.gpfsDataShipStart); + gpfs_hints_7.gpfsDataShipStart.structType = GPFS_DATA_SHIP_START; + token = strtok(value, split); + gpfs_hints_7.gpfsDataShipStart.numInstances = atoi(token); + gpfs_hints_7.gpfsDataShipStart.reserved = 0; + + rc = gpfs_fcntl(gpfs_file_handle, &gpfs_hints_7); + if (rc != 0) { + rc = errno; + printf( + "gpfs_hints_7 gpfs_fcntl(file handle: %d): Error number is %d, %s\n", + gpfs_file_handle, rc, strerror(rc)); + ret = OMPI_ERROR; + } + }*/ + + //Setting GPFS Hints 23 - gpfsGetExpTime + /*strcpy(gpfsHintsKey, "sioxDataShipStart"); + ompi_info_get(info_selected, gpfsHintsKey, valueLen, value, &flag); + if (flag) { + printf("GPFS Data Ship Start is set: %s: %s\n", gpfsHintsKey, value); + gpfs_hints_7.gpfsFcntlHeader.totalLength = sizeof(gpfs_hints_7); + gpfs_hints_7.gpfsFcntlHeader.fcntlVersion = GPFS_FCNTL_CURRENT_VERSION; + gpfs_hints_7.gpfsFcntlHeader.fcntlReserved = 0; + + gpfs_hints_7.gpfsDataShipStart.structLen = + sizeof(gpfs_hints_7.gpfsDataShipStart); + gpfs_hints_7.gpfsDataShipStart.structType = GPFS_DATA_SHIP_START; + token = strtok(value, split); + gpfs_hints_7.gpfsDataShipStart.numInstances = atoi(token); + gpfs_hints_7.gpfsDataShipStart.reserved = 0; + + rc = gpfs_fcntl(gpfs_file_handle, &gpfs_hints_7); + if (rc != 0) { + rc = errno; + printf( + "gpfs_hints_7 gpfs_fcntl(file handle: %d): Error number is %d, %s\n", + gpfs_file_handle, rc, strerror(rc)); + ret = OMPI_ERROR; + } + }*/ + + //Setting GPFS Hints 24 - gpfsSetAppendOnly + //Setting GPFS Hints 25 - gpfsGetAppendOnly + /*strcpy(gpfsHintsKey, "sioxDataShipStart"); + ompi_info_get(info_selected, gpfsHintsKey, valueLen, value, &flag); + if (flag) { + printf("GPFS Data Ship Start is set: %s: %s\n", gpfsHintsKey, value); + gpfs_hints_7.gpfsFcntlHeader.totalLength = sizeof(gpfs_hints_7); + gpfs_hints_7.gpfsFcntlHeader.fcntlVersion = GPFS_FCNTL_CURRENT_VERSION; + gpfs_hints_7.gpfsFcntlHeader.fcntlReserved = 0; + + gpfs_hints_7.gpfsDataShipStart.structLen = + sizeof(gpfs_hints_7.gpfsDataShipStart); + gpfs_hints_7.gpfsDataShipStart.structType = GPFS_DATA_SHIP_START; + token = strtok(value, split); + gpfs_hints_7.gpfsDataShipStart.numInstances = atoi(token); + gpfs_hints_7.gpfsDataShipStart.reserved = 0; + + rc = gpfs_fcntl(gpfs_file_handle, &gpfs_hints_7); + if (rc != 0) { + rc = errno; + printf( + "gpfs_hints_7 gpfs_fcntl(file handle: %d): Error number is %d, %s\n", + gpfs_file_handle, rc, strerror(rc)); + ret = OMPI_ERROR; + } + }*/ + + return ret; +} + +int mca_fs_gpfs_io_selection(mca_io_ompio_file_t *fh, + struct ompi_info_t *info, struct ompi_info_t *info_selected) { + +#ifdef HAVE_C_SIOX_H + char value[MPI_MAX_INFO_VAL + 1], sioxHintsKey[50], optimal_value_str[MPI_MAX_INFO_VAL + 1]; + int rc = 0, valueLen = MPI_MAX_INFO_VAL, flag; + //START SIOX initialization + if (siox_gpfs_uiid == SIOX_INVALID_ID){ + siox_gpfs_uiid = siox_system_information_lookup_interface_id("MPI", + "Generic"); + if (!siox_component_is_registered(siox_gpfs_uiid)){ + printf("SIOX Component MPI Generic is NOT registered!\n"); + siox_gpfs_component = siox_component_register(siox_gpfs_uiid, "GPFS"); + } + siox_gpfs_component_activity = siox_component_register_activity( + siox_gpfs_uiid, "MPI_File_open"); + } + printf("Beginning the SIOX_activity in mca_fs_gpfs_siox_io_selection()\n"); + + fh->f_siox_component = siox_gpfs_component; + fh->f_siox_activity = siox_activity_begin(siox_gpfs_component, + siox_gpfs_component_activity); + siox_activity_start(fh->f_siox_activity); + //END SIOX initialization + + info_selected = info; + + printf("Starting setting the SIOX_activity_attribute\n"); + siox_attribute **siox_attribute_array; + //START Registering the SIOX activities' attributes + //Make sure how many SIOX activities' attributes should be registered + int i = 0; + int number_of_info = opal_list_get_size(&(info_selected->super)); + printf("The size of number_of_info is: %d\n", number_of_info); + siox_attribute_array = (siox_attribute **) malloc( + sizeof(siox_attribute*) * number_of_info); + if (siox_attribute_array == 0) { + printf("assign siox_attribute_array fail, out of memory!\n"); + exit(0); + } + //END Registering the SIOX activities' attributes + // Setting the fileNameAttribute + siox_attribute_array[i] = siox_ontology_register_attribute("MPI", + "descriptor/filename", SIOX_STORAGE_STRING); + siox_activity_set_attribute(fh->f_siox_activity, + siox_attribute_array[i], fh->f_filename); + i++; + + //START setting the siox activity attributes + strcpy(sioxHintsKey, "sioxAccessRange"); + ompi_info_get(info_selected, sioxHintsKey, valueLen, value, &flag); + if (flag) { + printf("Setting sioxAccessRange hints to SIOX activity attribute.\n"); + siox_attribute_array[i] = siox_ontology_register_attribute("GPFS", + "sioxAccessRange", SIOX_STORAGE_STRING); + siox_activity_set_attribute(fh->f_siox_activity, + siox_attribute_array[i], &value); + if(siox_suggest_optimal_value_for_str(fh->f_siox_component, siox_attribute_array[i], fh->f_siox_activity, optimal_value_str, valueLen)) { + printf("Getting optimal value of sioxAccessRange hints from SIOX: %s \n", optimal_value_str); + ompi_info_set(info_selected, sioxHintsKey, optimal_value_str); + } + i++; + } + + strcpy(sioxHintsKey, "sioxFreeRange"); + ompi_info_get(info_selected, sioxHintsKey, valueLen, value, &flag); + if (flag) { + printf("Setting sioxFreeRange hints to SIOX activity attribute.\n"); + siox_attribute_array[i] = siox_ontology_register_attribute("GPFS", + "sioxFreeRange", SIOX_STORAGE_STRING); + siox_activity_set_attribute(fh->f_siox_activity, + siox_attribute_array[i], &value); + if(siox_suggest_optimal_value_for_str(fh->f_siox_component, siox_attribute_array[i], fh->f_siox_activity, optimal_value_str, valueLen)) { + printf("Getting optimal value of sioxFreeRange hints from SIOX: %s \n", optimal_value_str); + ompi_info_set(info_selected, sioxHintsKey, optimal_value_str); + } + i++; + } + + strcpy(sioxHintsKey, "sioxClearFileCache"); + ompi_info_get(info_selected, sioxHintsKey, valueLen, value, &flag); + if (flag) { + printf("Setting sioxClearFileCache hints to SIOX activity attribute.\n"); + siox_attribute_array[i] = siox_ontology_register_attribute("GPFS", + "sioxClearFileCache", SIOX_STORAGE_STRING); + siox_activity_set_attribute(fh->f_siox_activity, + siox_attribute_array[i], &value); + if(siox_suggest_optimal_value_for_str(fh->f_siox_component, siox_attribute_array[i], fh->f_siox_activity, optimal_value_str, valueLen)) { + printf("Getting optimal value of sioxClearFileCache hints from SIOX: %s \n", optimal_value_str); + ompi_info_set(info_selected, sioxHintsKey, optimal_value_str); + } + i++; + } + + strcpy(sioxHintsKey, "sioxCancelHints"); + ompi_info_get(info_selected, sioxHintsKey, valueLen, value, &flag); + if (flag) { + printf("Setting sioxCancelHints hints to SIOX activity attribute.\n"); + siox_attribute_array[i] = siox_ontology_register_attribute("GPFS", + "sioxCancelHints", SIOX_STORAGE_STRING); + siox_activity_set_attribute(fh->f_siox_activity, + siox_attribute_array[i], &value); + if(siox_suggest_optimal_value_for_str(fh->f_siox_component, siox_attribute_array[i], fh->f_siox_activity, optimal_value_str, valueLen)) { + printf("Getting optimal value of sioxCancelHints hints from SIOX: %s \n", optimal_value_str); + ompi_info_set(info_selected, sioxHintsKey, optimal_value_str); + } + i++; + } + + strcpy(sioxHintsKey, "sioxDataShipStart"); + ompi_info_get(info_selected, sioxHintsKey, valueLen, value, &flag); + if (flag) { + printf("Setting sioxDataShipStart hints to SIOX activity attribute.\n"); + siox_attribute_array[i] = siox_ontology_register_attribute("GPFS", + "sioxDataShipStart", SIOX_STORAGE_STRING); + siox_activity_set_attribute(fh->f_siox_activity, + siox_attribute_array[i], &value); + if(siox_suggest_optimal_value_for_str(fh->f_siox_component, siox_attribute_array[i], fh->f_siox_activity, optimal_value_str, valueLen)) { + printf("Getting optimal value of sioxDataShipStart hints from SIOX: %s \n", optimal_value_str); + ompi_info_set(info_selected, sioxHintsKey, optimal_value_str); + } + i++; + } + + strcpy(sioxHintsKey, "sioxDataShipStop"); + ompi_info_get(info_selected, sioxHintsKey, valueLen, value, &flag); + if (flag) { + printf("Setting sioxDataShipStop hints to SIOX activity attribute.\n"); + siox_attribute_array[i] = siox_ontology_register_attribute("GPFS", + "sioxDataShipStop", SIOX_STORAGE_STRING); + siox_activity_set_attribute(fh->f_siox_activity, + siox_attribute_array[i], &value); + if(siox_suggest_optimal_value_for_str(fh->f_siox_component, siox_attribute_array[i], fh->f_siox_activity, optimal_value_str, valueLen)) { + printf("Getting optimal value of sioxDataShipStop hints from SIOX: %s \n", optimal_value_str); + ompi_info_set(info_selected, sioxHintsKey, optimal_value_str); + } + i++; + } + + strcpy(sioxHintsKey, "sioxSetReplication"); + ompi_info_get(info_selected, sioxHintsKey, valueLen, value, &flag); + if (flag) { + printf("Setting sioxSetReplication hints to SIOX activity attribute.\n"); + siox_attribute_array[i] = siox_ontology_register_attribute("GPFS", + "sioxSetReplication", SIOX_STORAGE_STRING); + siox_activity_set_attribute(fh->f_siox_activity, + siox_attribute_array[i], &value); + if(siox_suggest_optimal_value_for_str(fh->f_siox_component, siox_attribute_array[i], fh->f_siox_activity, optimal_value_str, valueLen)) { + printf("Getting optimal value of sioxSetReplication hints from SIOX: %s \n", optimal_value_str); + ompi_info_set(info_selected, sioxHintsKey, optimal_value_str); + } + i++; + } + + strcpy(sioxHintsKey, "sioxByteRange"); + ompi_info_get(info_selected, sioxHintsKey, valueLen, value, &flag); + if (flag) { + printf("Setting sioxByteRange hints to SIOX activity attribute.\n"); + siox_attribute_array[i] = siox_ontology_register_attribute("GPFS", + "sioxByteRange", SIOX_STORAGE_STRING); + siox_activity_set_attribute(fh->f_siox_activity, + siox_attribute_array[i], &value); + if(siox_suggest_optimal_value_for_str(fh->f_siox_component, siox_attribute_array[i], fh->f_siox_activity, optimal_value_str, valueLen)) { + printf("Getting optimal value of sioxByteRange hints from SIOX: %s \n", optimal_value_str); + ompi_info_set(info_selected, sioxHintsKey, optimal_value_str); + } + i++; + } + + strcpy(sioxHintsKey, "sioxRestripeData"); + ompi_info_get(info_selected, sioxHintsKey, valueLen, value, &flag); + if (flag) { + printf("Setting sioxRestripeData hints to SIOX activity attribute.\n"); + siox_attribute_array[i] = siox_ontology_register_attribute("GPFS", + "sioxRestripeData", SIOX_STORAGE_STRING); + siox_activity_set_attribute(fh->f_siox_activity, + siox_attribute_array[i], &value); + if(siox_suggest_optimal_value_for_str(fh->f_siox_component, siox_attribute_array[i], fh->f_siox_activity, optimal_value_str, valueLen)) { + printf("Getting optimal value of sioxRestripeData hints from SIOX: %s \n", optimal_value_str); + ompi_info_set(info_selected, sioxHintsKey, optimal_value_str); + } + i++; + } + + printf("Stopping and ending the SIOX activity in mca_fs_gpfs_siox_io_selection()\n"); + siox_activity_stop(fh->f_siox_activity); + siox_activity_end(fh->f_siox_activity); +#else + info_selected = info; +#endif + return OMPI_SUCCESS; +} diff --git a/ompi/mca/fs/gpfs/fs_gpfs_file_set_size.c b/ompi/mca/fs/gpfs/fs_gpfs_file_set_size.c new file mode 100644 index 0000000000..8659683e46 --- /dev/null +++ b/ompi/mca/fs/gpfs/fs_gpfs_file_set_size.c @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana + * University Research and Technology + * Corporation. All rights reserved. + * Copyright (c) 2004-2011 The University of Tennessee and The University + * of Tennessee Research Foundation. All rights + * reserved. + * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, + * University of Stuttgart. All rights reserved. + * Copyright (c) 2004-2005 The Regents of the University of California. + * All rights reserved. + * Copyright (c) 2008-2011 University of Houston. All rights reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + + +#include "ompi_config.h" +#include "fs_gpfs.h" + +#include "mpi.h" +#include "ompi/constants.h" +#include "ompi/mca/fs/fs.h" + +/* + * file_set_size_gpfs + * + * Function: - set_size of a file + * Accepts: - same arguments as MPI_File_set_size() + * Returns: - Success if size is set + */ +int +mca_fs_gpfs_file_set_size (mca_io_ompio_file_t *fh, + OMPI_MPI_OFFSET_TYPE size) +{ + printf ("GPFS SET SIZE\n"); + int err = 0; + + err = ftruncate(fh->fd, size); + + fh->f_comm->c_coll.coll_bcast (&err, + 1, + MPI_INT, + OMPIO_ROOT, + fh->f_comm, + fh->f_comm->c_coll.coll_bcast_module); + if (-1 == err) { + return OMPI_ERROR; + } + return OMPI_SUCCESS; +} diff --git a/ompi/mca/fs/gpfs/fs_gpfs_file_sync.c b/ompi/mca/fs/gpfs/fs_gpfs_file_sync.c new file mode 100644 index 0000000000..ee6d1762d9 --- /dev/null +++ b/ompi/mca/fs/gpfs/fs_gpfs_file_sync.c @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana + * University Research and Technology + * Corporation. All rights reserved. + * Copyright (c) 2004-2011 The University of Tennessee and The University + * of Tennessee Research Foundation. All rights + * reserved. + * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, + * University of Stuttgart. All rights reserved. + * Copyright (c) 2004-2005 The Regents of the University of California. + * All rights reserved. + * Copyright (c) 2008-2009 University of Houston. All rights reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + + +#include "ompi_config.h" +#include "fs_gpfs.h" +//#include + +#include "mpi.h" +#include "ompi/constants.h" +#include "ompi/mca/fs/fs.h" + +/* + * file_sync_gpfs + * + * Function: - syn a new file + * Accepts: - file handle + * Returns: - Success if file closed + */ + +//TODO +int +mca_fs_gpfs_file_sync (ompi_file_t *fh) +{ + int ret = OMPI_SUCCESS; + mca_io_ompio_data_t *data; + + data = (mca_io_ompio_data_t *) fh->f_io_selected_data; + + ret = data->ompio_fh.f_fs->fs_file_sync (&data->ompio_fh); + + return ret; +}