Zoltan2
Zoltan2_TestHelpers.hpp
Go to the documentation of this file.
00001 // @HEADER
00002 //
00003 // ***********************************************************************
00004 //
00005 //   Zoltan2: A package of combinatorial algorithms for scientific computing
00006 //                  Copyright 2012 Sandia Corporation
00007 //
00008 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
00009 // the U.S. Government retains certain rights in this software.
00010 //
00011 // Redistribution and use in source and binary forms, with or without
00012 // modification, are permitted provided that the following conditions are
00013 // met:
00014 //
00015 // 1. Redistributions of source code must retain the above copyright
00016 // notice, this list of conditions and the following disclaimer.
00017 //
00018 // 2. Redistributions in binary form must reproduce the above copyright
00019 // notice, this list of conditions and the following disclaimer in the
00020 // documentation and/or other materials provided with the distribution.
00021 //
00022 // 3. Neither the name of the Corporation nor the names of the
00023 // contributors may be used to endorse or promote products derived from
00024 // this software without specific prior written permission.
00025 //
00026 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00027 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00028 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00029 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00030 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00031 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00032 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00033 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00034 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00035 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00036 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00037 //
00038 // Questions? Contact Karen Devine      (kddevin@sandia.gov)
00039 //                    Erik Boman        (egboman@sandia.gov)
00040 //                    Siva Rajamanickam (srajama@sandia.gov)
00041 //
00042 // ***********************************************************************
00043 //
00044 // @HEADER
00045 
00049 #ifndef ZOLTAN2_TESTHELPERS_HPP
00050 #define ZOLTAN2_TESTHELPERS_HPP
00051 
00052 #include <Zoltan2_Util.hpp>
00053 #include <iostream>
00054 
00055 typedef KokkosClassic::DefaultNode::DefaultNodeType znode_t;
00056 
00057 // The path to the directory of test data
00058 
00059 #define STR_VALUE(path) #path
00060 #define PATH_NAME(path) STR_VALUE(path)
00061 
00062 #ifdef Z2_DATA_DIR
00063   std::string testDataFilePath(PATH_NAME(Z2_DATA_DIR));
00064 #else
00065   std::string testDataFilePath(".");
00066 #endif
00067 
00068 // The path to the Zoltan1 test directory.  We use
00069 // some of their data for testing.
00070 
00071 #ifdef Z1_TEST_DIR
00072   std::string zoltanTestDirectory(PATH_NAME(Z1_TEST_DIR));
00073 #else
00074   std::string zoltanTestDirectory(".");
00075 #endif
00076 
00077 //
00078 // If Tpetra is compiled with explicit instantiation,
00079 // then we will use these types in our tests.
00080 //
00081 // Epetra uses int, int, double data types.  If we
00082 // are using these data types, then we can test 
00083 // cases of Epetra user input.
00084 //
00085 
00086 // TODO:  KDD 8/13/14
00087 // Global definitions of types gno_t, lno_t, zgid_t and 
00088 // scalar_t can cause bugs in the code.  If a class fails to define these 
00089 // types, but this file is included before the class file, the types
00090 // from Zoltan2_TestHelpers.hpp will be used in the class.  Compilation in
00091 // user programs (without Zoltan2_TestHelpers.hpp) would then fail.  An
00092 // example of this bug was in the GeometricGenerator class, which used
00093 // scalar_t without defining it.
00094 // In this "fix," I changed gno_t, lno_t, zgid_t, scalar_t, and node_t to zgno_t,
00095 // zlno_t, zzgid_t, zscalar_t and znode_t in Zoltan2_TestHelpers.hpp.  This
00096 // change is not the best fix; a better fix would remove the global
00097 // definitions, but that would require more work.  (An even better change
00098 // would use the Teuchos test framework to cycle through various options,
00099 // but that would require even more work and should be delayed until we
00100 // revamp the testing.)
00101 
00102 
00103 #if defined HAVE_ZOLTAN2_INST_FLOAT_INT_LONG
00104 
00105 typedef int zlno_t;
00106 typedef long zgno_t;
00107 typedef unsigned long zzgid_t;
00108 typedef float zscalar_t;
00109 
00110 #elif defined HAVE_ZOLTAN2_INST_DOUBLE_INT_LONG
00111 
00112 typedef int zlno_t;
00113 typedef long zgno_t;
00114 typedef unsigned long zzgid_t;
00115 typedef double zscalar_t;
00116 
00117 #elif defined HAVE_ZOLTAN2_INST_FLOAT_INT_INT
00118 
00119 typedef int zlno_t;
00120 typedef int zgno_t;
00121 typedef unsigned int zzgid_t;
00122 typedef float zscalar_t;
00123 
00124 #elif defined HAVE_ZOLTAN2_INST_DOUBLE_INT_INT
00125 
00126 typedef int zlno_t;
00127 typedef int zgno_t;
00128 typedef unsigned int zzgid_t;
00129 typedef double zscalar_t;
00130 #define HAVE_EPETRA_DATA_TYPES
00131 
00132 #elif defined TEST_STK_DATA_TYPES
00133 
00134 typedef ssize_t zlno_t;
00135 typedef size_t  zgno_t;
00136 typedef size_t  zzgid_t;
00137 typedef double  zscalar_t;
00138 
00139 #else
00140 
00141 typedef int zlno_t;
00142 typedef int zgno_t;
00143 typedef unsigned int zzgid_t;
00144 typedef double zscalar_t;
00145 #define HAVE_EPETRA_DATA_TYPES
00146 
00147 #endif
00148 
00149 #define MEMORY_CHECK(iPrint, msg) \
00150   if (iPrint){ \
00151     long kb = Zoltan2::getProcessKilobytes(); \
00152     std::cout.width(10); \
00153     std::cout.fill('*'); \
00154     std::cout << kb << " KB, " << msg << std::endl; \
00155     std::cout.width(0); \
00156     std::cout.fill(' '); \
00157   }
00158 
00159 #include <ErrorHandlingForTests.hpp>  
00160 #include <UserInputForTests.hpp>
00161 #include <PrintData.hpp>
00162 
00163 #endif