Commit d4bc436b authored by Kirill Terekhov's avatar Kirill Terekhov
Browse files

prepare switch for 64-bit integer indexes

parent bdc7a7e5
...@@ -18,6 +18,9 @@ option(USE_MPI2 "Use MPI-2 extensions, useful if your MPI library warns you to u ...@@ -18,6 +18,9 @@ option(USE_MPI2 "Use MPI-2 extensions, useful if your MPI library warns you to u
option(USE_OMP "Compile with OpenMP support (experimental)" OFF) option(USE_OMP "Compile with OpenMP support (experimental)" OFF)
option(USE_OPENCL "Use OpenCL where possible (experimental)" OFF) option(USE_OPENCL "Use OpenCL where possible (experimental)" OFF)
option(USE_INT64 "Use 64-bit integer types (use for large problems)" OFF)
option(USE_FP64 "Use 64-bit floating-point types (usually on)" ON)
option(USE_MESH "Compile mesh capabilities" ON) option(USE_MESH "Compile mesh capabilities" ON)
option(USE_SOLVER "Compile solver capabilities" ON) option(USE_SOLVER "Compile solver capabilities" ON)
option(USE_PARTITIONER "Compile partitioner capabilities" ON) option(USE_PARTITIONER "Compile partitioner capabilities" ON)
......
...@@ -36,6 +36,9 @@ ...@@ -36,6 +36,9 @@
//#define USE_MPI_P2P //use (probably) more effective mpi-2 algorithms //#define USE_MPI_P2P //use (probably) more effective mpi-2 algorithms
//#define USE_MPI_FILE //use MPI_File_xxx functionality //#define USE_MPI_FILE //use MPI_File_xxx functionality
//#define USE_MPI2 //set of your version produce warnings //#define USE_MPI2 //set of your version produce warnings
//#define USE_INT64
#define USE_FP64
#endif //INMOST_OPTIONS_CMAKE_INCLUDED #endif //INMOST_OPTIONS_CMAKE_INCLUDED
...@@ -132,10 +135,13 @@ ...@@ -132,10 +135,13 @@
#define INMOST_MPI_Comm int #define INMOST_MPI_Comm int
#define INMOST_MPI_Group int #define INMOST_MPI_Group int
#define INMOST_MPI_COMM_WORLD 0 #define INMOST_MPI_COMM_WORLD 0
#define INMOST_MPI_COMM_SELF 0 #define INMOST_MPI_COMM_SELF 0
#define INMOST_MPI_BYTE 0 #define INMOST_MPI_BYTE 0
#define INMOST_MPI_INT 0 #define INMOST_MPI_INT 0
#define INMOST_MPI_INT64_T 0
#define INMOST_MPI_UINT64_T 0
#define INMOST_MPI_DOUBLE 0 #define INMOST_MPI_DOUBLE 0
#define INMOST_MPI_FLOAT 0
#define INMOST_MPI_UNSIGNED 0 #define INMOST_MPI_UNSIGNED 0
#define INMOST_MPI_UNSIGNEDL 0 #define INMOST_MPI_UNSIGNEDL 0
#define INMOST_MPI_UNSIGNEDLL 0 #define INMOST_MPI_UNSIGNEDLL 0
...@@ -151,7 +157,10 @@ ...@@ -151,7 +157,10 @@
#define INMOST_MPI_COMM_SELF MPI_COMM_SELF #define INMOST_MPI_COMM_SELF MPI_COMM_SELF
#define INMOST_MPI_BYTE MPI_BYTE #define INMOST_MPI_BYTE MPI_BYTE
#define INMOST_MPI_INT MPI_INT #define INMOST_MPI_INT MPI_INT
#define INMOST_MPI_INT64_T MPI_INT64_T
#define INMOST_MPI_UINT64_T MPI_UINT64_T
#define INMOST_MPI_DOUBLE MPI_DOUBLE #define INMOST_MPI_DOUBLE MPI_DOUBLE
#define INMOST_MPI_FLOAT MPI_FLOAT
#define INMOST_MPI_UNSIGNED MPI_UNSIGNED #define INMOST_MPI_UNSIGNED MPI_UNSIGNED
#define INMOST_MPI_UNSIGNEDL MPI_UNSIGNED_LONG #define INMOST_MPI_UNSIGNEDL MPI_UNSIGNED_LONG
#define INMOST_MPI_UNSIGNEDLL MPI_UNSIGNED_LONG_LONG #define INMOST_MPI_UNSIGNEDLL MPI_UNSIGNED_LONG_LONG
...@@ -169,24 +178,45 @@ ...@@ -169,24 +178,45 @@
#define INMOST_MPI_SIZE int //in case MPI standard changes and compiler gives tons of warnings #define INMOST_MPI_SIZE int //in case MPI standard changes and compiler gives tons of warnings
#define INMOST_DATA_INTEGER_TYPE int
#define INMOST_DATA_REAL_TYPE double
#define INMOST_DATA_BULK_TYPE unsigned char //this should be one byte long #define INMOST_DATA_BULK_TYPE unsigned char //this should be one byte long
#define INMOST_MPI_DATA_BULK_TYPE INMOST_MPI_BYTE
#define INMOST_MPI_DATA_INTEGER_TYPE INMOST_MPI_INT #if defined(USE_FP64)
#define INMOST_DATA_REAL_TYPE double
#define INMOST_MPI_DATA_REAL_TYPE INMOST_MPI_DOUBLE #define INMOST_MPI_DATA_REAL_TYPE INMOST_MPI_DOUBLE
#define INMOST_MPI_DATA_BULK_TYPE INMOST_MPI_BYTE #else //USE_FP64
#define INMOST_DATA_REAL_TYPE float
#define INMOST_MPI_DATA_REAL_TYPE INMOST_MPI_FLOAT
#endif //USE_FP64
#if defined(USE_INT64)
#define INMOST_DATA_INTEGER_TYPE int64_t
#define INMOST_DATA_ENUM_TYPE uint64_t
#define INMOST_DATA_BIG_ENUM_TYPE uint64_t
#ifndef UINT64_MAX
#define UINT64_MAX ULLONG_MAX
#endif //UINT64_MAX
#define ENUMUNDEF UINT64_MAX
#define BIGENUMUNDEF UINT64_MAX
#define INMOST_MPI_DATA_INTEGER_TYPE INMOST_MPI_INT64_T
#define INMOST_MPI_DATA_ENUM_TYPE INMOST_MPI_UINT64_T
#define INMOST_MPI_DATA_BIG_ENUM_TYPE INMOST_MPI_UINT64_T
#else //USE_INT64
#define INMOST_DATA_INTEGER_TYPE int
#define INMOST_DATA_ENUM_TYPE unsigned int #define INMOST_DATA_ENUM_TYPE unsigned int
#define ENUMUNDEF UINT_MAX
#define INMOST_DATA_BIG_ENUM_TYPE unsigned long long #define INMOST_DATA_BIG_ENUM_TYPE unsigned long long
#define BIGENUMUNDEF ULLONG_MAX
#define ENUMUNDEF UINT_MAX
#define BIGENUMUNDEF ULLONG_MAX
#define INMOST_MPI_DATA_INTEGER_TYPE INMOST_MPI_INT
#define INMOST_MPI_DATA_ENUM_TYPE INMOST_MPI_UNSIGNED #define INMOST_MPI_DATA_ENUM_TYPE INMOST_MPI_UNSIGNED
#define INMOST_MPI_DATA_BIG_ENUM_TYPE INMOST_MPI_UNSIGNEDLL #define INMOST_MPI_DATA_BIG_ENUM_TYPE INMOST_MPI_UNSIGNEDLL
#endif //USE_INT64
/// Cross-platform timer that return current time in seconds. /// Cross-platform timer that return current time in seconds.
/// The timer is similar to MPI_Wtime() and omp_get_wtime() but is independent on both flags USE_MPI and USE_OMP. /// The timer is similar to MPI_Wtime() and omp_get_wtime() but is independent on both flags USE_MPI and USE_OMP.
......
...@@ -65,7 +65,7 @@ namespace INMOST ...@@ -65,7 +65,7 @@ namespace INMOST
/// Number of chars to hold all private markers, total number (MarkerFields * bits_per_char). /// Number of chars to hold all private markers, total number (MarkerFields * bits_per_char).
static const INMOST_DATA_ENUM_TYPE MarkerFieldsPrivate = 4; static const INMOST_DATA_ENUM_TYPE MarkerFieldsPrivate = 4;
/// Last bit indicate whether the marker is private. /// Last bit indicate whether the marker is private.
static const INMOST_DATA_ENUM_TYPE MarkerPrivateBit = 1 << (sizeof(INMOST_DATA_ENUM_TYPE)*8-1); static const INMOST_DATA_ENUM_TYPE MarkerPrivateBit = static_cast<INMOST_DATA_ENUM_TYPE>(1) << (sizeof(INMOST_DATA_ENUM_TYPE)*8-1);
/// Bit mask to obtain marker mask within MarkerType. /// Bit mask to obtain marker mask within MarkerType.
static const INMOST_DATA_ENUM_TYPE MarkerMask = static_cast<INMOST_DATA_BULK_TYPE>(-1); static const INMOST_DATA_ENUM_TYPE MarkerMask = static_cast<INMOST_DATA_BULK_TYPE>(-1);
/// sizeof(char) * bits_per_char. /// sizeof(char) * bits_per_char.
...@@ -80,7 +80,7 @@ namespace INMOST ...@@ -80,7 +80,7 @@ namespace INMOST
typedef INMOST_DATA_ENUM_TYPE HandleType; typedef INMOST_DATA_ENUM_TYPE HandleType;
static const INMOST_DATA_ENUM_TYPE handle_etype_bits = 3; static const INMOST_DATA_ENUM_TYPE handle_etype_bits = 3;
static const INMOST_DATA_ENUM_TYPE handle_etype_shift = sizeof(HandleType)*8-handle_etype_bits; static const INMOST_DATA_ENUM_TYPE handle_etype_shift = sizeof(HandleType)*8-handle_etype_bits;
static const INMOST_DATA_ENUM_TYPE handle_id_mask = (1 << handle_etype_shift)-1; static const INMOST_DATA_ENUM_TYPE handle_id_mask = (static_cast<INMOST_DATA_ENUM_TYPE>(1) << handle_etype_shift)-1;
static const INMOST_DATA_ENUM_TYPE chunk_bits_elems = 13; static const INMOST_DATA_ENUM_TYPE chunk_bits_elems = 13;
static const INMOST_DATA_ENUM_TYPE chunk_bits_empty = 8; static const INMOST_DATA_ENUM_TYPE chunk_bits_empty = 8;
......
...@@ -2858,6 +2858,13 @@ namespace INMOST ...@@ -2858,6 +2858,13 @@ namespace INMOST
/// @param input Value on current processor /// @param input Value on current processor
/// @return Sum over all processors /// @return Sum over all processors
real Integrate (real input); real Integrate (real input);
/// Integrate unsigned integer value over all processors.
///
/// Collective operation.
///
/// @param input Value on current processor
/// @return Sum over all processors
enumerator Integrate (enumerator input);
/// Integrate integer value over all processors. /// Integrate integer value over all processors.
/// ///
/// Collective operation. /// Collective operation.
...@@ -2873,6 +2880,14 @@ namespace INMOST ...@@ -2873,6 +2880,14 @@ namespace INMOST
/// @param size Size of the array. /// @param size Size of the array.
/// @return sum over all processors. /// @return sum over all processors.
void Integrate (real * input, integer size); void Integrate (real * input, integer size);
/// Integrate an array of unsigned integer values over all processors.
///
/// Collective operation.
///
/// @param input An array of values on current processor.
/// @param size Size of the array.
/// @return Sum over all processors.
void Integrate (enumerator * input, integer size);
/// Integrate an array of integer values over all processors. /// Integrate an array of integer values over all processors.
/// ///
/// Collective operation. /// Collective operation.
......
...@@ -37,5 +37,7 @@ ...@@ -37,5 +37,7 @@
#cmakedefine USE_MPI_FILE //use functionality for parallel files #cmakedefine USE_MPI_FILE //use functionality for parallel files
#cmakedefine USE_MPI2 //use mpi-2 extensions #cmakedefine USE_MPI2 //use mpi-2 extensions
#cmakedefine USE_INT64 // switch to 64-bit integer types
#cmakedefine USE_FP64 // switch to 64-bit floating-point types (usually on)
#endif //INMOST_OPTIONS_CMAKE_INCLUDED #endif //INMOST_OPTIONS_CMAKE_INCLUDED
...@@ -2825,11 +2825,11 @@ namespace INMOST ...@@ -2825,11 +2825,11 @@ namespace INMOST
int numnode = 0; int numnode = 0;
for (int i = 0; i < dims[0] + 1; i++) for (int i = 0; i < dims[0] + 1; i++)
{ {
Storage::integer pif = std::min(dims[0] - 1, i), pib = std::max(i - 1, 0); Storage::integer pif = std::min<Storage::integer>(dims[0] - 1, i), pib = std::max(i - 1, 0);
y = 0.0; y = 0.0;
for (int j = 0; j < dims[1] + 1; j++) for (int j = 0; j < dims[1] + 1; j++)
{ {
Storage::integer pjf = std::min(dims[1] - 1, j), pjb = std::max(j - 1, 0); Storage::integer pjf = std::min<Storage::integer>(dims[1] - 1, j), pjb = std::max(j - 1, 0);
z = ( z = (
tops[ECL_IJK_DATA(pib, pjb, 0)] + tops[ECL_IJK_DATA(pib, pjb, 0)] +
tops[ECL_IJK_DATA(pib, pjf, 0)] + tops[ECL_IJK_DATA(pib, pjf, 0)] +
...@@ -2844,7 +2844,7 @@ namespace INMOST ...@@ -2844,7 +2844,7 @@ namespace INMOST
)*0.25; )*0.25;
for (int k = 0; k < dims[2] + 1; k++) for (int k = 0; k < dims[2] + 1; k++)
{ {
Storage::integer pkf = std::min(dims[2] - 1, k), pkb = std::max(k - 1, 0); Storage::integer pkf = std::min<Storage::integer>(dims[2] - 1, k), pkb = std::max(k - 1, 0);
bool create = true; bool create = true;
if (!actnum.empty()) if (!actnum.empty())
{ {
......
...@@ -233,7 +233,10 @@ namespace INMOST ...@@ -233,7 +233,10 @@ namespace INMOST
template<typename EType> template<typename EType>
void Mesh::base_iterator<EType>::Print() void Mesh::base_iterator<EType>::Print()
{ {
printf("Number: %10d CurrentType %x types %x\n",lid,etype,types); std::cout << "Number: " << lid << " CurrentType " << ElementTypeName(etype) << " types ";
for(ElementType et = NODE; et != LastElementType(); et = NextElementType(et) ) if( et & types ) std::cout << ElementTypeName(et) << " ";
std::cout << std::endl;
//printf("Number: %10d CurrentType %x types %x\n",lid,etype,types);
} }
Storage::integer Mesh::NextLocalIDIter(ElementType etype, integer lid) const Storage::integer Mesh::NextLocalIDIter(ElementType etype, integer lid) const
......
...@@ -869,7 +869,18 @@ namespace INMOST ...@@ -869,7 +869,18 @@ namespace INMOST
return output; return output;
} }
Storage::enumerator Mesh::Integrate(Storage::enumerator input)
{
ENTER_FUNC();
Storage::enumerator output = input;
#if defined(USE_MPI)
REPORT_MPI(MPI_Allreduce(&input,&output,1,INMOST_MPI_DATA_ENUM_TYPE,MPI_SUM,comm));
#else//USE_MPI
(void) input;
#endif//USE_MPI
EXIT_FUNC();
return output;
}
Storage::integer Mesh::Integrate(Storage::integer input) Storage::integer Mesh::Integrate(Storage::integer input)
...@@ -915,6 +926,21 @@ namespace INMOST ...@@ -915,6 +926,21 @@ namespace INMOST
EXIT_FUNC(); EXIT_FUNC();
} }
void Mesh::Integrate(Storage::enumerator * input, Storage::integer size)
{
ENTER_FUNC();
#if defined(USE_MPI)
static dynarray<Storage::enumerator,64> temp;
temp.resize(size);
memcpy(temp.data(),input,sizeof(Storage::enumerator)*size);
REPORT_MPI(MPI_Allreduce(temp.data(),input,size,INMOST_MPI_DATA_ENUM_TYPE,MPI_SUM,comm));
#else//USE_MPI
(void) input;
(void) size;
#endif//USE_MPI
EXIT_FUNC();
}
Storage::integer Mesh::ExclusiveSum(Storage::integer input) Storage::integer Mesh::ExclusiveSum(Storage::integer input)
{ {
ENTER_FUNC(); ENTER_FUNC();
...@@ -1754,7 +1780,7 @@ namespace INMOST ...@@ -1754,7 +1780,7 @@ namespace INMOST
v.push_back(mpirank); v.push_back(mpirank);
} }
else else
owner = std::min(mpirank,v[0]); owner = std::min<Storage::integer>(mpirank,v[0]);
it->IntegerDF(tag_owner) = owner; it->IntegerDF(tag_owner) = owner;
...@@ -2075,7 +2101,7 @@ namespace INMOST ...@@ -2075,7 +2101,7 @@ namespace INMOST
pr.push_back(mpirank); pr.push_back(mpirank);
} }
else else
owner = std::min(mpirank,pr[0]); owner = std::min<Storage::integer>(mpirank,pr[0]);
it->IntegerDF(tag_owner) = owner; it->IntegerDF(tag_owner) = owner;
if( mpirank == owner ) if( mpirank == owner )
{ {
...@@ -2334,7 +2360,7 @@ namespace INMOST ...@@ -2334,7 +2360,7 @@ namespace INMOST
//std::cout << GetProcessorRank() << " start " << ElementTypeName(mask) << std::endl; //std::cout << GetProcessorRank() << " start " << ElementTypeName(mask) << std::endl;
//if( mask & CELL ) //if( mask & CELL )
//{ //{
int cnt = 0; INMOST_DATA_ENUM_TYPE cnt = 0;
for(const HandleType * it = ghost; it != ghost + num; it++) for(const HandleType * it = ghost; it != ghost + num; it++)
if( (GetHandleElementType(*it) & mask) && GetStatus(*it) == Element::Ghost ) if( (GetHandleElementType(*it) & mask) && GetStatus(*it) == Element::Ghost )
{ {
......
...@@ -224,7 +224,7 @@ namespace INMOST { ...@@ -224,7 +224,7 @@ namespace INMOST {
INMOST::to_string(this->PreconditionerTime() + this->IterationsTime()); INMOST::to_string(this->PreconditionerTime() + this->IterationsTime());
} }
INMOST_DATA_REAL_TYPE Solver::Condest(INMOST_DATA_REAL_TYPE tol, unsigned int maxits) { INMOST_DATA_REAL_TYPE Solver::Condest(INMOST_DATA_REAL_TYPE tol, INMOST_DATA_ENUM_TYPE maxits) {
if (!solver->isMatrixSet()) throw MatrixNotSetInSolver; if (!solver->isMatrixSet()) throw MatrixNotSetInSolver;
return solver->Condest(tol, maxits); return solver->Condest(tol, maxits);
} }
......
...@@ -2864,7 +2864,7 @@ swap_algorithm: ...@@ -2864,7 +2864,7 @@ swap_algorithm:
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
tt = Timer(); tt = Timer();
if ((1.0 * nzA / std::max(1u,(wend - wbeg)*(wend - wbeg))) > 0.75 && (1.0*(wend - wbeg)) / (1.0 * std::max(1u,moend - mobeg)) > 0.1) if ((1.0 * nzA / std::max<INMOST_DATA_ENUM_TYPE>(1,(wend - wbeg)*(wend - wbeg))) > 0.75 && (1.0*(wend - wbeg)) / (1.0 * std::max<INMOST_DATA_ENUM_TYPE>(1,moend - mobeg)) > 0.1)
{ {
std::cout << "Try to sparsify schur complement!!!" << std::endl; std::cout << "Try to sparsify schur complement!!!" << std::endl;
std::cout << "Sparsity: " << 1.0 * nzA / ((wend - wbeg)*(wend - wbeg)) << std::endl; std::cout << "Sparsity: " << 1.0 * nzA / ((wend - wbeg)*(wend - wbeg)) << std::endl;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment