From 99adeb7f6e07fb2cb4ce5bd035f0750bcc39c36e Mon Sep 17 00:00:00 2001 From: Nathan Hjelm Date: Thu, 25 Jul 2013 19:08:21 +0000 Subject: [PATCH] Fix support for complex datatypes when fortran is not available but _Complex is This commit was SVN r28951. --- ompi/mca/op/base/functions.h | 49 +++++++++++- ompi/mca/op/base/op_base_functions.c | 103 ++++++++++++++++++++++--- ompi/mca/op/op.h | 8 ++ ompi/op/op.c | 8 +- opal/datatype/opal_datatype_internal.h | 6 +- 5 files changed, 153 insertions(+), 21 deletions(-) diff --git a/ompi/mca/op/base/functions.h b/ompi/mca/op/base/functions.h index d9de6cbf0e..2fd64e0fa3 100644 --- a/ompi/mca/op/base/functions.h +++ b/ompi/mca/op/base/functions.h @@ -10,6 +10,8 @@ * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. * Copyright (c) 2008-2009 Cisco Systems, Inc. All rights reserved. + * Copyright (c) 2013 Los Alamos National Security, LLC. All rights + * reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -160,12 +162,34 @@ #else #define OMPI_OP_HANDLER_COMPLEX32(name) #endif +#if HAVE_FLOAT__COMPLEX +#define OMPI_OP_HANDLER_FLOAT__COMPLEX(name) \ + void ompi_op_base_##name##_c_float__complex OMPI_OP_PROTO; +#else +#define OMPI_OP_HANDLER_FLOAT__COMPLEX(name) +#endif +#if HAVE_DOUBLE__COMPLEX +#define OMPI_OP_HANDLER_DOUBLE__COMPLEX(name) \ + void ompi_op_base_##name##_c_double__complex OMPI_OP_PROTO; +#else +#define OMPI_OP_HANDLER_DOUBLE__COMPLEX(name) +#endif +#if HAVE_LONG_DOUBLE__COMPLEX +#define OMPI_OP_HANDLER_LONG_DOUBLE__COMPLEX(name) \ + void ompi_op_base_##name##_c_long_double__complex OMPI_OP_PROTO; +#else +#define OMPI_OP_HANDLER_LONG_DOUBLE__COMPLEX(name) +#endif + #define OMPI_OP_HANDLER_COMPLEX(name) \ OMPI_OP_HANDLER_COMPLEX_INTRINSIC(name) \ OMPI_OP_HANDLER_DOUBLE_COMPLEX_INTRINSIC(name) \ OMPI_OP_HANDLER_COMPLEX8(name) \ OMPI_OP_HANDLER_COMPLEX16(name) \ - OMPI_OP_HANDLER_COMPLEX32(name) + OMPI_OP_HANDLER_COMPLEX32(name) \ + OMPI_OP_HANDLER_FLOAT__COMPLEX(name) \ + OMPI_OP_HANDLER_DOUBLE__COMPLEX(name) \ + OMPI_OP_HANDLER_LONG_DOUBLE__COMPLEX(name) /* Byte */ @@ -406,12 +430,33 @@ BEGIN_C_DECLS #else #define OMPI_OP_3BUFF_HANDLER_COMPLEX32(name) #endif +#if HAVE_FLOAT__COMPLEX +#define OMPI_OP_3BUFF_HANDLER_FLOAT__COMPLEX(name) \ + void ompi_op_base_3buff_##name##_c_float__complex OMPI_OP_PROTO_3BUF; +#else +#define OMPI_OP_3BUFF_HANDLER_FLOAT__COMPLEX(name) +#endif +#if HAVE_DOUBLE__COMPLEX +#define OMPI_OP_3BUFF_HANDLER_DOUBLE__COMPLEX(name) \ + void ompi_op_base_3buff_##name##_c_double__complex OMPI_OP_PROTO_3BUF; +#else +#define OMPI_OP_3BUFF_HANDLER_DOUBLE__COMPLEX(name) +#endif +#if HAVE_LONG_DOUBLE__COMPLEX +#define OMPI_OP_3BUFF_HANDLER_LONG_DOUBLE__COMPLEX(name) \ + void ompi_op_base_3buff_##name##_c_long_double__complex OMPI_OP_PROTO_3BUF; +#else +#define OMPI_OP_3BUFF_HANDLER_LONG_DOUBLE__COMPLEX(name) +#endif #define OMPI_OP_3BUFF_HANDLER_COMPLEX(name) \ OMPI_OP_3BUFF_HANDLER_COMPLEX_INTRINSIC(name) \ OMPI_OP_3BUFF_HANDLER_DOUBLE_COMPLEX_INTRINSIC(name) \ OMPI_OP_3BUFF_HANDLER_COMPLEX8(name) \ OMPI_OP_3BUFF_HANDLER_COMPLEX16(name) \ - OMPI_OP_3BUFF_HANDLER_COMPLEX32(name) + OMPI_OP_3BUFF_HANDLER_COMPLEX32(name) \ + OMPI_OP_3BUFF_HANDLER_FLOAT__COMPLEX(name) \ + OMPI_OP_3BUFF_HANDLER_DOUBLE__COMPLEX(name) \ + OMPI_OP_3BUFF_HANDLER_LONG_DOUBLE__COMPLEX(name) /* Byte */ diff --git a/ompi/mca/op/base/op_base_functions.c b/ompi/mca/op/base/op_base_functions.c index a233cd3dad..9ea9651d8f 100644 --- a/ompi/mca/op/base/op_base_functions.c +++ b/ompi/mca/op/base/op_base_functions.c @@ -1,3 +1,4 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* * Copyright (c) 2004-2006 The Trustees of Indiana University and Indiana * University Research and Technology @@ -322,6 +323,15 @@ COMPLEX_OP_FUNC_SUM(fortran_complex16, ompi_fortran_complex16_t) #if OMPI_HAVE_FORTRAN_REAL16 && OMPI_HAVE_FORTRAN_COMPLEX32 COMPLEX_OP_FUNC_SUM(fortran_complex32, ompi_fortran_complex32_t) #endif +#if HAVE_FLOAT__COMPLEX +OP_FUNC(sum, c_float__complex, float _Complex, +=) +#endif +#if HAVE_DOUBLE__COMPLEX +OP_FUNC(sum, c_double__complex, double _Complex, +=) +#endif +#if HAVE_LONG_DOUBLE__COMPLEX +OP_FUNC(sum, c_long_double__complex, long double _Complex, +=) +#endif /************************************************************************* * Product @@ -395,6 +405,15 @@ COMPLEX_OP_FUNC_PROD(fortran_complex16, ompi_fortran_complex16_t) #if OMPI_HAVE_FORTRAN_REAL16 && OMPI_HAVE_FORTRAN_COMPLEX32 COMPLEX_OP_FUNC_PROD(fortran_complex32, ompi_fortran_complex32_t) #endif +#if HAVE_FLOAT__COMPLEX +OP_FUNC(prod, c_float__complex, float _Complex, *=) +#endif +#if HAVE_DOUBLE__COMPLEX +OP_FUNC(prod, c_double__complex, double _Complex, *=) +#endif +#if HAVE_LONG_DOUBLE__COMPLEX +OP_FUNC(prod, c_long_double__complex, long double _Complex, *=) +#endif /************************************************************************* * Logical AND @@ -947,6 +966,15 @@ COMPLEX_OP_FUNC_SUM_3BUF(fortran_complex16, ompi_fortran_complex16_t) #if OMPI_HAVE_FORTRAN_REAL16 && OMPI_HAVE_FORTRAN_COMPLEX32 COMPLEX_OP_FUNC_SUM_3BUF(fortran_complex32, ompi_fortran_complex32_t) #endif +#if HAVE_FLOAT__COMPLEX +OP_FUNC_3BUF(sum, c_float__complex, float _Complex, +=) +#endif +#if HAVE_DOUBLE__COMPLEX +OP_FUNC_3BUF(sum, c_double__complex, double _Complex, +=) +#endif +#if HAVE_LONG_DOUBLE__COMPLEX +OP_FUNC_3BUF(sum, c_long_double__complex, long double _Complex, +=) +#endif /************************************************************************* * Product @@ -1020,6 +1048,15 @@ COMPLEX_OP_FUNC_PROD_3BUF(fortran_complex16, ompi_fortran_complex16_t) #if OMPI_HAVE_FORTRAN_REAL16 && OMPI_HAVE_FORTRAN_COMPLEX32 COMPLEX_OP_FUNC_PROD_3BUF(fortran_complex32, ompi_fortran_complex32_t) #endif +#if HAVE_FLOAT__COMPLEX +OP_FUNC_3BUF(prod, c_float__complex, float _Complex, *=) +#endif +#if HAVE_DOUBLE__COMPLEX +OP_FUNC_3BUF(prod, c_double__complex, double _Complex, *=) +#endif +#if HAVE_LONG_DOUBLE__COMPLEX +OP_FUNC_3BUF(prod, c_long_double__complex, long double _Complex, *=) +#endif /************************************************************************* * Logical AND @@ -1547,6 +1584,9 @@ LOC_FUNC_3BUF(minloc, long_double_int, <) #if OMPI_HAVE_FORTRAN_REAL4 && OMPI_HAVE_FORTRAN_COMPLEX8 #define COMPLEX8(name) ompi_op_base_##name##_fortran_complex8 #define COMPLEX8_3BUFF(name) ompi_op_base_3buff_##name##_fortran_complex8 +#elif HAVE_FLOAT__COMPLEX +#define COMPLEX8(name) ompi_op_base_##name##_c_float__complex +#define COMPLEX8_3BUFF(name) ompi_op_base_3buff_##name##_c_float__complex #else #define COMPLEX8(name) NULL #define COMPLEX8_3BUFF(name) NULL @@ -1554,6 +1594,9 @@ LOC_FUNC_3BUF(minloc, long_double_int, <) #if OMPI_HAVE_FORTRAN_REAL8 && OMPI_HAVE_FORTRAN_COMPLEX16 #define COMPLEX16(name) ompi_op_base_##name##_fortran_complex16 #define COMPLEX16_3BUFF(name) ompi_op_base_3buff_##name##_fortran_complex16 +#elif HAVE_DOUBLE__COMPLEX +#define COMPLEX16(name) ompi_op_base_##name##_c_double__complex +#define COMPLEX16_3BUFF(name) ompi_op_base_3buff_##name##_c_double__complex #else #define COMPLEX16(name) NULL #define COMPLEX16_3BUFF(name) NULL @@ -1568,38 +1611,74 @@ LOC_FUNC_3BUF(minloc, long_double_int, <) #if OMPI_HAVE_FORTRAN_REAL16 && OMPI_REAL16_MATCHES_C && OMPI_HAVE_FORTRAN_COMPLEX32 #define COMPLEX32(name) ompi_op_base_##name##_fortran_complex32 #define COMPLEX32_3BUFF(name) ompi_op_base_3buff_##name##_fortran_complex32 +#elif HAVE_LONG_DOUBLE__COMPLEX +#define COMPLEX32(name) ompi_op_base_##name##_c_long_double__complex +#define COMPLEX32_3BUFF(name) ompi_op_base_3buff_##name##_c_long_double__complex #else #define COMPLEX32(name) NULL #define COMPLEX32_3BUFF(name) NULL #endif +#if HAVE_FLOAT__COMPLEX +#define C_FLOAT__COMPLEX(name) ompi_op_base_##name##_c_float__complex +#define C_FLOAT__COMPLEX_3BUFF(name) ompi_op_base_3buff_##name##_c_float__complex +#else +#define C_FLOAT__COMPLEX(name) NULL +#define C_FLOAT__COMPLEX_3BUFF(name) NULL +#endif +#if HAVE_DOUBLE__COMPLEX +#define C_DOUBLE__COMPLEX(name) ompi_op_base_##name##_c_double__complex +#define C_DOUBLE__COMPLEX_3BUFF(name) ompi_op_base_3buff_##name##_c_double__complex +#else +#define C_DOUBLE__COMPLEX(name) NULL +#define C_DOUBLE__COMPLEX_3BUFF(name) NULL +#endif +#if HAVE_LONG_DOUBLE__COMPLEX +#define C_LONG_DOUBLE__COMPLEX(name) ompi_op_base_##name##_c_long_double__complex +#define C_LONG_DOUBLE__COMPLEX_3BUFF(name) ompi_op_base_3buff_##name##_c_long_double__complex +#else +#define C_LONG_DOUBLE__COMPLEX(name) NULL +#define C_LONG_DOUBLE__COMPLEX_3BUFF(name) NULL +#endif #define COMPLEX(name) \ - COMPLEX_PLAIN(name), /* OMPI_OP_BASE_TYPE_COMPLEX */ \ - COMPLEX_DOUBLE(name), /* OMPI_OP_BASE_TYPE_DOUBLE_COMPLEX */ \ - COMPLEX8(name), /* OMPI_OP_BASE_TYPE_COMPLEX8 */ \ - COMPLEX16(name), /* OMPI_OP_BASE_TYPE_COMPLEX16 */ \ - COMPLEX32(name) /* OMPI_OP_BASE_TYPE_COMPLEX32 */ + COMPLEX_PLAIN(name), /* OMPI_OP_BASE_TYPE_COMPLEX */ \ + COMPLEX_DOUBLE(name), /* OMPI_OP_BASE_TYPE_DOUBLE_COMPLEX */ \ + COMPLEX8(name), /* OMPI_OP_BASE_TYPE_COMPLEX8 */ \ + COMPLEX16(name), /* OMPI_OP_BASE_TYPE_COMPLEX16 */ \ + COMPLEX32(name), /* OMPI_OP_BASE_TYPE_COMPLEX32 */ \ + C_FLOAT__COMPLEX(name), /* OMPI_OP_BASE_TYPE_C_FLOAT__COMPLEX */ \ + C_DOUBLE__COMPLEX(name), /* OMPI_OP_BASE_TYPE_C_DOUBLE__COMPLEX */ \ + C_LONG_DOUBLE__COMPLEX(name) /* OMPI_OP_BASE_TYPE_C_LONG_DOUBLE__COMPLEX */ #define COMPLEX_3BUFF(name) \ - COMPLEX_PLAIN_3BUFF(name), /* OMPI_OP_BASE_TYPE_COMPLEX */ \ - COMPLEX_DOUBLE_3BUFF(name), /* OMPI_OP_BASE_TYPE_DOUBLE_COMPLEX */ \ - COMPLEX8_3BUFF(name), /* OMPI_OP_BASE_TYPE_COMPLEX8 */ \ - COMPLEX16_3BUFF(name), /* OMPI_OP_BASE_TYPE_COMPLEX16 */ \ - COMPLEX32_3BUFF(name) /* OMPI_OP_BASE_TYPE_COMPLEX32 */ + COMPLEX_PLAIN_3BUFF(name), /* OMPI_OP_BASE_TYPE_COMPLEX */ \ + COMPLEX_DOUBLE_3BUFF(name), /* OMPI_OP_BASE_TYPE_DOUBLE_COMPLEX */ \ + COMPLEX8_3BUFF(name), /* OMPI_OP_BASE_TYPE_COMPLEX8 */ \ + COMPLEX16_3BUFF(name), /* OMPI_OP_BASE_TYPE_COMPLEX16 */ \ + COMPLEX32_3BUFF(name), /* OMPI_OP_BASE_TYPE_COMPLEX32 */ \ + C_FLOAT__COMPLEX_3BUFF(name), /* OMPI_OP_BASE_TYPE_C_FLOAT__COMPLEX */ \ + C_DOUBLE__COMPLEX_3BUFF(name), /* OMPI_OP_BASE_TYPE_C_DOUBLE__COMPLEX*/ \ + C_LONG_DOUBLE__COMPLEX_3BUFF(name) /* OMPI_OP_BASE_TYPE_C_LONG_DOUBLE__COMPLEX*/ #define COMPLEX_NULL \ NULL, /* OMPI_OP_BASE_TYPE_COMPLEX */ \ NULL, /* OMPI_OP_BASE_TYPE_DOUBLE_COMPLEX */ \ NULL, /* OMPI_OP_BASE_TYPE_COMPLEX8 */ \ NULL, /* OMPI_OP_BASE_TYPE_COMPLEX16 */ \ - NULL /* OMPI_OP_BASE_TYPE_COMPLEX32 */ + NULL, /* OMPI_OP_BASE_TYPE_COMPLEX32 */ \ + NULL, /* OMPI_OP_BASE_TYPE_C_FLOAT__COMPLEX */ \ + NULL, /* OMPI_OP_BASE_TYPE_C_DOUBLE__COMPLEX */ \ + NULL /* OMPI_OP_BASE_TYPE_C_LONG_DOUBLE__COMPLEX */ #define COMPLEX_NULL_3BUFF \ NULL, /* OMPI_OP_BASE_TYPE_COMPLEX */ \ NULL, /* OMPI_OP_BASE_TYPE_DOUBLE_COMPLEX */ \ NULL, /* OMPI_OP_BASE_TYPE_COMPLEX8 */ \ NULL, /* OMPI_OP_BASE_TYPE_COMPLEX16 */ \ - NULL /* OMPI_OP_BASE_TYPE_COMPLEX32 */ + NULL, /* OMPI_OP_BASE_TYPE_COMPLEX32 */ \ + NULL, /* OMPI_OP_BASE_TYPE_C_FLOAT__COMPLEX */ \ + NULL, /* OMPI_OP_BASE_TYPE_C_DOUBLE__COMPLEX */ \ + NULL /* OMPI_OP_BASE_TYPE_C_LONG_DOUBLE__COMPLEX */ /** Byte ****************************************************************/ diff --git a/ompi/mca/op/op.h b/ompi/mca/op/op.h index b411a27c5d..6df82804e1 100644 --- a/ompi/mca/op/op.h +++ b/ompi/mca/op/op.h @@ -163,6 +163,14 @@ enum { /** Complex32 */ OMPI_OP_BASE_TYPE_COMPLEX32, + /** C Complex */ + /* float _Complex */ + OMPI_OP_BASE_TYPE_C_FLOAT__COMPLEX, + /* double _Complex */ + OMPI_OP_BASE_TYPE_C_DOUBLE__COMPLEX, + /* long double _Complex */ + OMPI_OP_BASE_TYPE_C_LONG_DOUBLE__COMPLEX, + /** Byte */ OMPI_OP_BASE_TYPE_BYTE, diff --git a/ompi/op/op.c b/ompi/op/op.c index c7a5fc95e0..72c506d538 100644 --- a/ompi/op/op.c +++ b/ompi/op/op.c @@ -180,10 +180,10 @@ int ompi_op_init(void) #warning Unsupported definition for MPI_OFFSET #endif ompi_op_ddt_map[OMPI_DATATYPE_MPI_C_BOOL] = OMPI_OP_BASE_TYPE_BOOL; - ompi_op_ddt_map[OMPI_DATATYPE_MPI_C_COMPLEX] = OMPI_OP_BASE_TYPE_COMPLEX8; - ompi_op_ddt_map[OMPI_DATATYPE_MPI_C_FLOAT_COMPLEX] = OMPI_OP_BASE_TYPE_COMPLEX8; - ompi_op_ddt_map[OMPI_DATATYPE_MPI_C_DOUBLE_COMPLEX] = OMPI_OP_BASE_TYPE_COMPLEX16; - ompi_op_ddt_map[OMPI_DATATYPE_MPI_C_LONG_DOUBLE_COMPLEX] = OMPI_OP_BASE_TYPE_COMPLEX32; + ompi_op_ddt_map[OMPI_DATATYPE_MPI_C_COMPLEX] = OMPI_OP_BASE_TYPE_C_FLOAT__COMPLEX; + ompi_op_ddt_map[OMPI_DATATYPE_MPI_C_FLOAT_COMPLEX] = OMPI_OP_BASE_TYPE_C_FLOAT__COMPLEX; + ompi_op_ddt_map[OMPI_DATATYPE_MPI_C_DOUBLE_COMPLEX] = OMPI_OP_BASE_TYPE_C_DOUBLE__COMPLEX; + ompi_op_ddt_map[OMPI_DATATYPE_MPI_C_LONG_DOUBLE_COMPLEX] = OMPI_OP_BASE_TYPE_C_LONG_DOUBLE__COMPLEX; /* MPI 3.0 datatypes */ #if OMPI_MPI_COUNT_SIZE == 4 diff --git a/opal/datatype/opal_datatype_internal.h b/opal/datatype/opal_datatype_internal.h index 36da9b7bd1..9275aa3a2e 100644 --- a/opal/datatype/opal_datatype_internal.h +++ b/opal/datatype/opal_datatype_internal.h @@ -434,9 +434,9 @@ struct opal_datatype_t; * http://predef.sourceforge.net/prestd.html for more info. */ -#define OPAL_USE_FLOAT__COMPLEX (0 && HAVE_FLOAT__COMPLEX) -#define OPAL_USE_DOUBLE__COMPLEX (0 && HAVE_DOUBLE__COMPLEX) -#define OPAL_USE_LONG_DOUBLE__COMPLEX (0 && HAVE_LONG_DOUBLE__COMPLEX) +#define OPAL_USE_FLOAT__COMPLEX HAVE_FLOAT__COMPLEX +#define OPAL_USE_DOUBLE__COMPLEX HAVE_DOUBLE__COMPLEX +#define OPAL_USE_LONG_DOUBLE__COMPLEX HAVE_LONG_DOUBLE__COMPLEX #if OPAL_USE_FLOAT__COMPLEX && (SIZEOF_FLOAT__COMPLEX == 8) #define OPAL_DATATYPE_INITIALIZER_COMPLEX8(FLAGS) OPAL_DATATYPE_INIT_BASIC_DATATYPE( float _Complex, OPAL_ALIGNMENT_FLOAT_COMPLEX, COMPLEX8, (FLAGS) )