1 /* 2 * Copyright (c) 2004-2008 The Trustees of Indiana University and Indiana 3 * University Research and Technology 4 * Corporation. All rights reserved. 5 * Copyright (c) 2004-2005 The University of Tennessee and The University 6 * of Tennessee Research Foundation. All rights 7 * reserved. 8 * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, 9 * University of Stuttgart. All rights reserved. 10 * Copyright (c) 2004-2005 The Regents of the University of California. 11 * All rights reserved. 12 * Copyright (c) 2008-2009 Cisco Systems, Inc. All rights reserved. 13 * $COPYRIGHT$ 14 * 15 * Additional copyrights may follow 16 * 17 * $HEADER$ 18 */ 19 20 #ifndef MCA_OP_EXAMPLE_EXPORT_H 21 #define MCA_OP_EXAMPLE_EXPORT_H 22 23 #include "ompi_config.h" 24 25 #include "ompi/mca/mca.h" 26 #include "opal/class/opal_object.h" 27 28 #include "ompi/mca/op/op.h" 29 30 BEGIN_C_DECLS 31 32 /** 33 * Derive a struct from the base op component struct, allowing us to 34 * cache some component-specific information on our well-known 35 * component struct. 36 */ 37 typedef struct { 38 /** The base op component struct */ 39 ompi_op_base_component_1_0_0_t super; 40 41 /* What follows is example-component-specific cached information. We 42 tend to use this scheme (caching information on the example 43 component itself) instead of lots of individual global 44 variables for the component. The following data fields are 45 examples; replace them with whatever is relevant for your 46 component. */ 47 48 /** A simple boolean indicating that the hardware is available. */ 49 bool hardware_available; 50 51 /** A simple boolean indicating whether double precision is 52 supported. */ 53 bool double_supported; 54 } ompi_op_example_component_t; 55 56 /** 57 * Derive a struct from the base op module struct, allowing us to 58 * cache some module-specific information for BXOR. Note that 59 * information that should be shared across all modules should be put 60 * on the example component. 61 */ 62 typedef struct { 63 ompi_op_base_module_1_0_0_t super; 64 65 /* Just like the ompi_op_example_component_t, this struct is meant to 66 cache information on a per-module basis. What follows are 67 examples; replace them with whatever is relevant for your 68 component/module. Keep in mind that there will be one distinct 69 module for each MPI_Op; you may want to have different data 70 cached on the module, depending on the MPI_Op that it is 71 supporting. */ 72 double some_bxor_data; 73 } ompi_op_example_module_bxor_t; 74 75 /** 76 * To use OMPI's OBJ system, you have to declare each "class". 77 */ 78 OBJ_CLASS_DECLARATION(ompi_op_example_module_bxor_t); 79 80 /** 81 * Globally exported variable. Note that it is a *example* component 82 * (defined above), which has the ompi_op_base_component_t as its 83 * first member. Hence, the MCA/op framework will find the data that 84 * it expects in the first memory locations, but then the component 85 * itself can cache additional information after that that can be used 86 * by both the component and modules. 87 */ 88 OMPI_DECLSPEC extern ompi_op_example_component_t 89 mca_op_example_component; 90 91 /** 92 * Setup for MPI_MAX and return a module. 93 */ 94 OMPI_DECLSPEC ompi_op_base_module_t * 95 ompi_op_example_setup_max(ompi_op_t *op); 96 97 /** 98 * Setup for MPI_BXOR and return a module. 99 */ 100 OMPI_DECLSPEC ompi_op_base_module_t * 101 ompi_op_example_setup_bxor(ompi_op_t *op); 102 103 END_C_DECLS 104 105 #endif /* MCA_OP_EXAMPLE_EXPORT_H */