2019-07-08 10:26:24 +08:00
|
|
|
/******************************************************************************
|
2022-04-06 07:19:51 +08:00
|
|
|
* Copyright (c) 1998 Lawrence Livermore National Security, LLC and other
|
2019-07-08 10:26:24 +08:00
|
|
|
* HYPRE Project Developers. See the top-level COPYRIGHT file for details.
|
1998-10-16 07:41:53 +08:00
|
|
|
*
|
2019-07-08 10:26:24 +08:00
|
|
|
* SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
|
|
|
|
******************************************************************************/
|
2006-07-28 07:26:57 +08:00
|
|
|
|
1998-10-16 07:41:53 +08:00
|
|
|
/******************************************************************************
|
|
|
|
|
*
|
|
|
|
|
* Header file for HYPRE_utilities library
|
|
|
|
|
*
|
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#ifndef HYPRE_UTILITIES_HEADER
|
|
|
|
|
#define HYPRE_UTILITIES_HEADER
|
|
|
|
|
|
1999-09-03 02:21:43 +08:00
|
|
|
#include <HYPRE_config.h>
|
|
|
|
|
|
1998-10-16 07:41:53 +08:00
|
|
|
#ifndef HYPRE_SEQUENTIAL
|
|
|
|
|
#include "mpi.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
2015-12-11 09:44:00 +08:00
|
|
|
#ifdef HYPRE_USING_OPENMP
|
1999-06-16 07:56:19 +08:00
|
|
|
#include <omp.h>
|
2015-12-11 09:44:00 +08:00
|
|
|
#endif
|
1999-06-16 07:56:19 +08:00
|
|
|
|
1998-10-16 07:41:53 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
|
2010-12-21 03:27:44 +08:00
|
|
|
/*--------------------------------------------------------------------------
|
|
|
|
|
* Big int stuff
|
|
|
|
|
*--------------------------------------------------------------------------*/
|
|
|
|
|
|
2019-03-05 03:40:58 +08:00
|
|
|
#if defined(HYPRE_BIGINT)
|
2019-02-16 07:04:27 +08:00
|
|
|
typedef long long int HYPRE_BigInt;
|
2010-12-21 03:27:44 +08:00
|
|
|
typedef long long int HYPRE_Int;
|
2019-02-16 07:04:27 +08:00
|
|
|
#define HYPRE_MPI_BIG_INT MPI_LONG_LONG_INT
|
2010-12-21 03:27:44 +08:00
|
|
|
#define HYPRE_MPI_INT MPI_LONG_LONG_INT
|
2020-02-07 05:56:03 +08:00
|
|
|
|
2019-03-05 03:40:58 +08:00
|
|
|
#elif defined(HYPRE_MIXEDINT)
|
2019-02-16 07:04:27 +08:00
|
|
|
typedef long long int HYPRE_BigInt;
|
|
|
|
|
typedef int HYPRE_Int;
|
|
|
|
|
#define HYPRE_MPI_BIG_INT MPI_LONG_LONG_INT
|
|
|
|
|
#define HYPRE_MPI_INT MPI_INT
|
2017-01-27 09:26:28 +08:00
|
|
|
|
|
|
|
|
#else /* default */
|
2019-02-16 07:04:27 +08:00
|
|
|
typedef int HYPRE_BigInt;
|
2010-12-21 03:27:44 +08:00
|
|
|
typedef int HYPRE_Int;
|
2019-02-16 07:04:27 +08:00
|
|
|
#define HYPRE_MPI_BIG_INT MPI_INT
|
2010-12-21 03:27:44 +08:00
|
|
|
#define HYPRE_MPI_INT MPI_INT
|
1999-02-11 00:47:41 +08:00
|
|
|
#endif
|
|
|
|
|
|
2013-10-12 03:48:06 +08:00
|
|
|
/*--------------------------------------------------------------------------
|
2017-01-27 09:26:28 +08:00
|
|
|
* Real and Complex types
|
2013-10-12 03:48:06 +08:00
|
|
|
*--------------------------------------------------------------------------*/
|
|
|
|
|
|
2017-03-18 04:54:47 +08:00
|
|
|
#include <float.h>
|
|
|
|
|
|
2017-05-16 08:37:19 +08:00
|
|
|
#if defined(HYPRE_SINGLE)
|
2017-01-27 09:26:28 +08:00
|
|
|
typedef float HYPRE_Real;
|
2017-03-16 08:22:01 +08:00
|
|
|
#define HYPRE_REAL_MAX FLT_MAX
|
|
|
|
|
#define HYPRE_REAL_MIN FLT_MIN
|
|
|
|
|
#define HYPRE_REAL_EPSILON FLT_EPSILON
|
2017-04-08 01:49:07 +08:00
|
|
|
#define HYPRE_REAL_MIN_EXP FLT_MIN_EXP
|
2017-01-27 09:26:28 +08:00
|
|
|
#define HYPRE_MPI_REAL MPI_FLOAT
|
|
|
|
|
|
2017-05-16 08:37:19 +08:00
|
|
|
#elif defined(HYPRE_LONG_DOUBLE)
|
2017-01-27 09:26:28 +08:00
|
|
|
typedef long double HYPRE_Real;
|
2017-03-16 08:22:01 +08:00
|
|
|
#define HYPRE_REAL_MAX LDBL_MAX
|
|
|
|
|
#define HYPRE_REAL_MIN LDBL_MIN
|
|
|
|
|
#define HYPRE_REAL_EPSILON LDBL_EPSILON
|
2017-04-08 01:49:07 +08:00
|
|
|
#define HYPRE_REAL_MIN_EXP DBL_MIN_EXP
|
2017-01-27 09:26:28 +08:00
|
|
|
#define HYPRE_MPI_REAL MPI_LONG_DOUBLE
|
|
|
|
|
|
|
|
|
|
#else /* default */
|
2013-10-12 03:48:06 +08:00
|
|
|
typedef double HYPRE_Real;
|
2017-03-16 08:22:01 +08:00
|
|
|
#define HYPRE_REAL_MAX DBL_MAX
|
|
|
|
|
#define HYPRE_REAL_MIN DBL_MIN
|
|
|
|
|
#define HYPRE_REAL_EPSILON DBL_EPSILON
|
2017-04-08 01:49:07 +08:00
|
|
|
#define HYPRE_REAL_MIN_EXP DBL_MIN_EXP
|
2013-10-12 03:48:06 +08:00
|
|
|
#define HYPRE_MPI_REAL MPI_DOUBLE
|
2017-01-27 09:26:28 +08:00
|
|
|
#endif
|
2013-10-12 03:48:06 +08:00
|
|
|
|
2017-05-16 08:37:19 +08:00
|
|
|
#if defined(HYPRE_COMPLEX)
|
2013-10-12 03:48:06 +08:00
|
|
|
typedef double _Complex HYPRE_Complex;
|
|
|
|
|
#define HYPRE_MPI_COMPLEX MPI_C_DOUBLE_COMPLEX /* or MPI_LONG_DOUBLE ? */
|
2017-01-27 09:26:28 +08:00
|
|
|
|
|
|
|
|
#else /* default */
|
2013-10-12 03:48:06 +08:00
|
|
|
typedef HYPRE_Real HYPRE_Complex;
|
|
|
|
|
#define HYPRE_MPI_COMPLEX HYPRE_MPI_REAL
|
|
|
|
|
#endif
|
|
|
|
|
|
1998-10-16 07:41:53 +08:00
|
|
|
/*--------------------------------------------------------------------------
|
2010-12-21 03:27:44 +08:00
|
|
|
* Sequential MPI stuff
|
1998-10-16 07:41:53 +08:00
|
|
|
*--------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
#ifdef HYPRE_SEQUENTIAL
|
2010-12-21 03:27:44 +08:00
|
|
|
typedef HYPRE_Int MPI_Comm;
|
1998-10-16 07:41:53 +08:00
|
|
|
#endif
|
|
|
|
|
|
2007-11-15 04:56:21 +08:00
|
|
|
/*--------------------------------------------------------------------------
|
|
|
|
|
* HYPRE error codes
|
|
|
|
|
*--------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
#define HYPRE_ERROR_GENERIC 1 /* generic error */
|
|
|
|
|
#define HYPRE_ERROR_MEMORY 2 /* unable to allocate memory */
|
|
|
|
|
#define HYPRE_ERROR_ARG 4 /* argument error */
|
|
|
|
|
/* bits 4-8 are reserved for the index of the argument error */
|
|
|
|
|
#define HYPRE_ERROR_CONV 256 /* method did not converge as expected */
|
|
|
|
|
|
2020-06-03 01:05:01 +08:00
|
|
|
/*--------------------------------------------------------------------------
|
|
|
|
|
* HYPRE init/finalize
|
|
|
|
|
*--------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
HYPRE_Int HYPRE_Init();
|
|
|
|
|
HYPRE_Int HYPRE_Finalize();
|
|
|
|
|
|
1998-10-16 07:41:53 +08:00
|
|
|
/*--------------------------------------------------------------------------
|
2006-02-07 07:49:24 +08:00
|
|
|
* HYPRE error user functions
|
1998-10-16 07:41:53 +08:00
|
|
|
*--------------------------------------------------------------------------*/
|
|
|
|
|
|
2006-02-07 07:49:24 +08:00
|
|
|
/* Return the current hypre error flag */
|
2010-12-21 03:27:44 +08:00
|
|
|
HYPRE_Int HYPRE_GetError();
|
2006-09-14 04:46:11 +08:00
|
|
|
|
|
|
|
|
/* Check if the given error flag contains the given error code */
|
2010-12-21 03:27:44 +08:00
|
|
|
HYPRE_Int HYPRE_CheckError(HYPRE_Int hypre_ierr, HYPRE_Int hypre_error_code);
|
2006-09-14 04:46:11 +08:00
|
|
|
|
|
|
|
|
/* Return the index of the argument (counting from 1) where
|
|
|
|
|
argument error (HYPRE_ERROR_ARG) has occured */
|
2010-12-21 03:27:44 +08:00
|
|
|
HYPRE_Int HYPRE_GetErrorArg();
|
2006-02-07 07:49:24 +08:00
|
|
|
|
2006-09-14 04:46:11 +08:00
|
|
|
/* Describe the given error flag in the given string */
|
2010-12-21 03:27:44 +08:00
|
|
|
void HYPRE_DescribeError(HYPRE_Int hypre_ierr, char *descr);
|
2006-09-14 04:46:11 +08:00
|
|
|
|
2007-10-09 05:51:32 +08:00
|
|
|
/* Clears the hypre error flag */
|
2010-12-21 03:27:44 +08:00
|
|
|
HYPRE_Int HYPRE_ClearAllErrors();
|
2007-10-09 05:51:32 +08:00
|
|
|
|
|
|
|
|
/* Clears the given error code from the hypre error flag */
|
2010-12-21 03:27:44 +08:00
|
|
|
HYPRE_Int HYPRE_ClearError(HYPRE_Int hypre_error_code);
|
2007-10-09 05:51:32 +08:00
|
|
|
|
2021-02-10 03:19:05 +08:00
|
|
|
/* Print GPU information */
|
|
|
|
|
HYPRE_Int HYPRE_PrintDeviceInfo();
|
|
|
|
|
|
2018-10-12 09:26:41 +08:00
|
|
|
/*--------------------------------------------------------------------------
|
|
|
|
|
* HYPRE Version routines
|
|
|
|
|
*--------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
/* RDF: This macro is used by the FEI code. Want to eventually remove. */
|
|
|
|
|
#define HYPRE_VERSION "HYPRE_RELEASE_NAME Date Compiled: " __DATE__ " " __TIME__
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Allocates and returns a string with version number information in it.
|
|
|
|
|
**/
|
|
|
|
|
HYPRE_Int
|
|
|
|
|
HYPRE_Version( char **version_ptr );
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns version number information in integer form. Use 'NULL' for values
|
|
|
|
|
* not needed. The argument {\tt single} is a single sortable integer
|
|
|
|
|
* representation of the release number.
|
|
|
|
|
**/
|
|
|
|
|
HYPRE_Int
|
|
|
|
|
HYPRE_VersionNumber( HYPRE_Int *major_ptr,
|
|
|
|
|
HYPRE_Int *minor_ptr,
|
|
|
|
|
HYPRE_Int *patch_ptr,
|
|
|
|
|
HYPRE_Int *single_ptr );
|
|
|
|
|
|
2010-03-19 04:15:28 +08:00
|
|
|
/*--------------------------------------------------------------------------
|
|
|
|
|
* HYPRE AP user functions
|
|
|
|
|
*--------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
/*Checks whether the AP is on */
|
2010-12-21 03:27:44 +08:00
|
|
|
HYPRE_Int HYPRE_AssumedPartitionCheck();
|
2010-03-19 04:15:28 +08:00
|
|
|
|
2021-02-04 04:31:25 +08:00
|
|
|
/*--------------------------------------------------------------------------
|
|
|
|
|
* HYPRE memory location
|
|
|
|
|
*--------------------------------------------------------------------------*/
|
|
|
|
|
|
2020-02-25 14:16:18 +08:00
|
|
|
typedef enum _HYPRE_MemoryLocation
|
2020-02-07 05:56:03 +08:00
|
|
|
{
|
2020-02-25 14:16:18 +08:00
|
|
|
HYPRE_MEMORY_UNDEFINED = -1,
|
2021-11-09 11:26:59 +08:00
|
|
|
HYPRE_MEMORY_HOST,
|
2020-02-25 14:16:18 +08:00
|
|
|
HYPRE_MEMORY_DEVICE
|
2020-02-07 05:56:03 +08:00
|
|
|
} HYPRE_MemoryLocation;
|
2010-03-19 04:15:28 +08:00
|
|
|
|
2021-02-04 04:31:25 +08:00
|
|
|
HYPRE_Int HYPRE_SetMemoryLocation(HYPRE_MemoryLocation memory_location);
|
|
|
|
|
HYPRE_Int HYPRE_GetMemoryLocation(HYPRE_MemoryLocation *memory_location);
|
|
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
|
|
/*--------------------------------------------------------------------------
|
|
|
|
|
* HYPRE execution policy
|
|
|
|
|
*--------------------------------------------------------------------------*/
|
|
|
|
|
|
2020-03-27 08:00:30 +08:00
|
|
|
typedef enum _HYPRE_ExecutionPolicy
|
2020-02-25 14:16:18 +08:00
|
|
|
{
|
|
|
|
|
HYPRE_EXEC_UNDEFINED = -1,
|
2021-11-09 11:26:59 +08:00
|
|
|
HYPRE_EXEC_HOST,
|
2020-02-25 14:16:18 +08:00
|
|
|
HYPRE_EXEC_DEVICE
|
2020-03-27 08:00:30 +08:00
|
|
|
} HYPRE_ExecutionPolicy;
|
2020-02-25 14:16:18 +08:00
|
|
|
|
2021-02-04 04:31:25 +08:00
|
|
|
HYPRE_Int HYPRE_SetExecutionPolicy(HYPRE_ExecutionPolicy exec_policy);
|
|
|
|
|
HYPRE_Int HYPRE_GetExecutionPolicy(HYPRE_ExecutionPolicy *exec_policy);
|
2021-05-25 08:16:35 +08:00
|
|
|
HYPRE_Int HYPRE_SetStructExecutionPolicy(HYPRE_ExecutionPolicy exec_policy);
|
|
|
|
|
HYPRE_Int HYPRE_GetStructExecutionPolicy(HYPRE_ExecutionPolicy *exec_policy);
|
2021-02-04 04:31:25 +08:00
|
|
|
|
|
|
|
|
/*--------------------------------------------------------------------------
|
|
|
|
|
* HYPRE UMPIRE
|
|
|
|
|
*--------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
HYPRE_Int HYPRE_SetUmpireDevicePoolSize(size_t nbytes);
|
|
|
|
|
HYPRE_Int HYPRE_SetUmpireUMPoolSize(size_t nbytes);
|
|
|
|
|
HYPRE_Int HYPRE_SetUmpireHostPoolSize(size_t nbytes);
|
|
|
|
|
HYPRE_Int HYPRE_SetUmpirePinnedPoolSize(size_t nbytes);
|
|
|
|
|
HYPRE_Int HYPRE_SetUmpireDevicePoolName(const char *pool_name);
|
|
|
|
|
HYPRE_Int HYPRE_SetUmpireUMPoolName(const char *pool_name);
|
|
|
|
|
HYPRE_Int HYPRE_SetUmpireHostPoolName(const char *pool_name);
|
|
|
|
|
HYPRE_Int HYPRE_SetUmpirePinnedPoolName(const char *pool_name);
|
|
|
|
|
|
|
|
|
|
/*--------------------------------------------------------------------------
|
|
|
|
|
* HYPRE GPU memory pool
|
|
|
|
|
*--------------------------------------------------------------------------*/
|
|
|
|
|
|
2021-11-09 11:26:59 +08:00
|
|
|
HYPRE_Int HYPRE_SetGPUMemoryPoolSize(HYPRE_Int bin_growth, HYPRE_Int min_bin, HYPRE_Int max_bin,
|
|
|
|
|
size_t max_cached_bytes);
|
2021-02-04 04:31:25 +08:00
|
|
|
|
2021-05-25 08:16:35 +08:00
|
|
|
/*--------------------------------------------------------------------------
|
|
|
|
|
* HYPRE handle
|
|
|
|
|
*--------------------------------------------------------------------------*/
|
|
|
|
|
|
2022-05-25 04:27:32 +08:00
|
|
|
HYPRE_Int HYPRE_SetSpTransUseVendor( HYPRE_Int use_vendor );
|
|
|
|
|
HYPRE_Int HYPRE_SetSpMVUseVendor( HYPRE_Int use_vendor );
|
2022-05-10 06:24:44 +08:00
|
|
|
/* Backwards compatibility with HYPRE_SetSpGemmUseCusparse() */
|
|
|
|
|
#define HYPRE_SetSpGemmUseCusparse(use_vendor) HYPRE_SetSpGemmUseVendor(use_vendor)
|
|
|
|
|
HYPRE_Int HYPRE_SetSpGemmUseVendor( HYPRE_Int use_vendor );
|
2021-05-25 08:16:35 +08:00
|
|
|
HYPRE_Int HYPRE_SetUseGpuRand( HYPRE_Int use_curand );
|
|
|
|
|
|
1998-10-16 07:41:53 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#endif
|