change some var names

This commit is contained in:
Ruipeng Li 2022-05-26 19:54:32 -07:00
parent 17bc61ed48
commit 875180594d
17 changed files with 48 additions and 44 deletions

View File

@ -86,9 +86,9 @@ hypreDevice_CSRSpGemm(hypre_CSRMatrix *A,
HYPRE_Int *d_rc = hypre_TAlloc(HYPRE_Int, m, HYPRE_MEMORY_DEVICE);
const HYPRE_Int alg = hypre_HandleSpgemmAlgorithm(hypre_handle());
if (hypre_HandleSpgemmAlgorithmNumBin(hypre_handle()) == 0)
if (hypre_HandleSpgemmNumBin(hypre_handle()) == 0)
{
hypreDevice_CSRSpGemmBinnedGetMaxNumBlocks();
hypreDevice_CSRSpGemmBinnedGetBlockNumDim();
}
if (alg == 1)

View File

@ -399,7 +399,7 @@ HYPRE_Int hypre_spgemm_symbolic_max_num_blocks( HYPRE_Int multiProcessorCount, H
template <HYPRE_Int SHMEM_HASH_SIZE, HYPRE_Int GROUP_SIZE>
HYPRE_Int hypre_spgemm_numerical_max_num_blocks( HYPRE_Int multiProcessorCount, HYPRE_Int *num_blocks_ptr, HYPRE_Int *block_size_ptr );
HYPRE_Int hypreDevice_CSRSpGemmBinnedGetMaxNumBlocks();
HYPRE_Int hypreDevice_CSRSpGemmBinnedGetBlockNumDim();
template <HYPRE_Int GROUP_SIZE> HYPRE_Int hypreDevice_CSRSpGemmNumerPostCopy( HYPRE_Int m,
HYPRE_Int *d_rc, HYPRE_Int *nnzC, HYPRE_Int **d_ic, HYPRE_Int **d_jc, HYPRE_Complex **d_c);

View File

@ -10,13 +10,13 @@
#include "csr_spgemm_device.h"
HYPRE_Int hypreDevice_CSRSpGemmBinnedGetMaxNumBlocks()
HYPRE_Int hypreDevice_CSRSpGemmBinnedGetBlockNumDim()
{
hypre_int multiProcessorCount = 0;
/* bins 1, 2, ..., num_bins, are effective; 0 is reserved for empty rows */
const HYPRE_Int num_bins = 10;
hypre_HandleSpgemmAlgorithmNumBin(hypre_handle()) = num_bins;
hypre_HandleSpgemmNumBin(hypre_handle()) = num_bins;
#if defined(HYPRE_USING_CUDA)
cudaDeviceGetAttribute(&multiProcessorCount, cudaDevAttrMultiProcessorCount, hypre_HandleDevice(hypre_handle()));
@ -26,7 +26,7 @@ HYPRE_Int hypreDevice_CSRSpGemmBinnedGetMaxNumBlocks()
hipDeviceGetAttribute(&multiProcessorCount, hipDeviceAttributeMultiprocessorCount, hypre_HandleDevice(hypre_handle()));
#endif
auto max_nblocks = hypre_HandleSpgemmAlgorithmMaxNumBlocks(hypre_handle());
auto max_nblocks = hypre_HandleSpgemmBlockNumDim(hypre_handle());
for (HYPRE_Int i = 0; i < num_bins + 1; i++)
{

View File

@ -115,7 +115,7 @@ hypreDevice_CSRSpGemmNumerWithRownnzUpperboundBinned( HYPRE_Int m,
HYPRE_Int *d_rind = hypre_TAlloc(HYPRE_Int, m, HYPRE_MEMORY_DEVICE);
HYPRE_Int h_bin_ptr[HYPRE_SPGEMM_MAX_NBIN + 1];
HYPRE_Int num_bins = hypre_HandleSpgemmAlgorithmNumBin(hypre_handle());
HYPRE_Int num_bins = hypre_HandleSpgemmNumBin(hypre_handle());
const char s = 8, t = 2;
#if defined(HYPRE_USING_CUDA)
const char u = num_bins;
@ -198,7 +198,7 @@ hypreDevice_CSRSpGemmNumerWithRownnzUpperbound( HYPRE_Int m,
HYPRE_Real t1 = hypre_MPI_Wtime();
#endif
const HYPRE_Int binned = hypre_HandleSpgemmAlgorithmBinned(hypre_handle());
const HYPRE_Int binned = hypre_HandleSpgemmBinned(hypre_handle());
if (binned)
{

View File

@ -461,7 +461,7 @@ hypre_spgemm_numerical_with_rownnz( HYPRE_Int m,
dim3 bDim(BDIMX, BDIMY, num_groups_per_block);
hypre_assert(bDim.x * bDim.y == GROUP_SIZE);
// grid dimension (number of blocks)
const HYPRE_Int num_blocks = hypre_min( hypre_HandleSpgemmAlgorithmMaxNumBlocks(hypre_handle())[1][BIN],
const HYPRE_Int num_blocks = hypre_min( hypre_HandleSpgemmBlockNumDim(hypre_handle())[1][BIN],
(m + bDim.z - 1) / bDim.z );
dim3 gDim( num_blocks );
// number of active groups

View File

@ -67,7 +67,7 @@ hypreDevice_CSRSpGemmRownnzUpperboundBinned( HYPRE_Int m,
/* Binning (bins 3-10) with d_rc */
HYPRE_Int h_bin_ptr[HYPRE_SPGEMM_MAX_NBIN + 1];
const char s = 32, t = 3, u = hypre_HandleSpgemmAlgorithmNumBin(hypre_handle());
const char s = 32, t = 3, u = hypre_HandleSpgemmNumBin(hypre_handle());
HYPRE_Int *d_rind = hypre_TAlloc(HYPRE_Int, m, HYPRE_MEMORY_DEVICE);
@ -121,7 +121,7 @@ hypreDevice_CSRSpGemmRownnzUpperbound( HYPRE_Int m,
char *d_rf = hypre_TAlloc(char, m, HYPRE_MEMORY_DEVICE);
const HYPRE_Int binned = hypre_HandleSpgemmAlgorithmBinned(hypre_handle());
const HYPRE_Int binned = hypre_HandleSpgemmBinned(hypre_handle());
if (binned)
{
@ -303,7 +303,7 @@ hypreDevice_CSRSpGemmRownnzBinned( HYPRE_Int m,
hypre_assert(new_end - d_rind == num_failed_rows);
/* Binning (bins 6-10) with d_rc which is a **rownnz-bound** now */
const char t = 6, u = hypre_HandleSpgemmAlgorithmNumBin(hypre_handle());
const char t = 6, u = hypre_HandleSpgemmNumBin(hypre_handle());
hypre_SpGemmCreateBins(num_failed_rows, s, t, u, d_rc, true, d_rind, h_bin_ptr);
@ -351,7 +351,7 @@ hypreDevice_CSRSpGemmRownnz( HYPRE_Int m,
HYPRE_Real t1 = hypre_MPI_Wtime();
#endif
const HYPRE_Int binned = hypre_HandleSpgemmAlgorithmBinned(hypre_handle());
const HYPRE_Int binned = hypre_HandleSpgemmBinned(hypre_handle());
if (binned)
{

View File

@ -355,7 +355,7 @@ hypre_spgemm_symbolic_rownnz( HYPRE_Int m,
dim3 bDim(BDIMX, BDIMY, num_groups_per_block);
hypre_assert(bDim.x * bDim.y == GROUP_SIZE);
// grid dimension (number of blocks)
const HYPRE_Int num_blocks = hypre_min( hypre_HandleSpgemmAlgorithmMaxNumBlocks(hypre_handle())[0][BIN],
const HYPRE_Int num_blocks = hypre_min( hypre_HandleSpgemmBlockNumDim(hypre_handle())[0][BIN],
(m + bDim.z - 1) / bDim.z );
dim3 gDim( num_blocks );
// number of active groups

View File

@ -230,7 +230,7 @@ HYPRE_Int hypre_SpGemmCreateBins( HYPRE_Int m,
HYPRE_Real t1 = hypre_MPI_Wtime();
#endif
HYPRE_Int num_bins = hypre_HandleSpgemmAlgorithmNumBin(hypre_handle());
HYPRE_Int num_bins = hypre_HandleSpgemmNumBin(hypre_handle());
HYPRE_Int *d_bin_ptr = hypre_TAlloc(HYPRE_Int, num_bins + 1, HYPRE_MEMORY_DEVICE);
/* assume there are no more than 127 = 2^7-1 bins, which should be enough */

View File

@ -2369,7 +2369,7 @@ main( hypre_int argc,
/* use vendor implementation for SpGEMM */
ierr = HYPRE_SetSpGemmUseVendor(spgemm_use_vendor); hypre_assert(ierr == 0);
ierr = hypre_SetSpGemmAlgorithm(spgemm_alg); hypre_assert(ierr == 0);
ierr = hypre_SetSpGemmAlgorithmBinned(spgemm_alg_binned); hypre_assert(ierr == 0);
ierr = hypre_SetSpGemmBinned(spgemm_alg_binned); hypre_assert(ierr == 0);
ierr = hypre_SetSpGemmRownnzEstimateMethod(spgemm_rowest_mtd); hypre_assert(ierr == 0);
if (spgemm_rowest_nsamples > 0) { ierr = hypre_SetSpGemmRownnzEstimateNSamples(spgemm_rowest_nsamples); hypre_assert(ierr == 0); }
if (spgemm_rowest_mult > 0.0) { ierr = hypre_SetSpGemmRownnzEstimateMultFactor(spgemm_rowest_mult); hypre_assert(ierr == 0); }

View File

@ -1018,7 +1018,7 @@ main( hypre_int argc,
hypre_assert(errcode == 0);
errcode = hypre_SetSpGemmAlgorithm(spgemm_alg);
hypre_assert(errcode == 0);
ierr = hypre_SetSpGemmAlgorithmBinned(spgemm_alg_binned);
ierr = hypre_SetSpGemmBinned(spgemm_alg_binned);
hypre_assert(ierr == 0);
/*-----------------------------------------------------------

View File

@ -1364,9 +1364,9 @@ typedef struct
#define hypre_HandleSpMVUseVendor(hypre_handle) hypre_DeviceDataSpMVUseVendor(hypre_HandleDeviceData(hypre_handle))
#define hypre_HandleSpTransUseVendor(hypre_handle) hypre_DeviceDataSpTransUseVendor(hypre_HandleDeviceData(hypre_handle))
#define hypre_HandleSpgemmAlgorithm(hypre_handle) hypre_DeviceDataSpgemmAlgorithm(hypre_HandleDeviceData(hypre_handle))
#define hypre_HandleSpgemmAlgorithmBinned(hypre_handle) hypre_DeviceDataSpgemmAlgorithmBinned(hypre_HandleDeviceData(hypre_handle))
#define hypre_HandleSpgemmAlgorithmNumBin(hypre_handle) hypre_DeviceDataSpgemmAlgorithmNumBin(hypre_HandleDeviceData(hypre_handle))
#define hypre_HandleSpgemmAlgorithmMaxNumBlocks(hypre_handle) hypre_DeviceDataSpgemmAlgorithmMaxNumBlocks(hypre_HandleDeviceData(hypre_handle))
#define hypre_HandleSpgemmBinned(hypre_handle) hypre_DeviceDataSpgemmBinned(hypre_HandleDeviceData(hypre_handle))
#define hypre_HandleSpgemmNumBin(hypre_handle) hypre_DeviceDataSpgemmNumBin(hypre_HandleDeviceData(hypre_handle))
#define hypre_HandleSpgemmBlockNumDim(hypre_handle) hypre_DeviceDataSpgemmBlockNumDim(hypre_HandleDeviceData(hypre_handle))
#define hypre_HandleSpgemmRownnzEstimateMethod(hypre_handle) hypre_DeviceDataSpgemmRownnzEstimateMethod(hypre_HandleDeviceData(hypre_handle))
#define hypre_HandleSpgemmRownnzEstimateNsamples(hypre_handle) hypre_DeviceDataSpgemmRownnzEstimateNsamples(hypre_HandleDeviceData(hypre_handle))
#define hypre_HandleSpgemmRownnzEstimateMultFactor(hypre_handle) hypre_DeviceDataSpgemmRownnzEstimateMultFactor(hypre_HandleDeviceData(hypre_handle))
@ -1847,7 +1847,7 @@ HYPRE_Int hypre_SetSpTransUseVendor( HYPRE_Int use_vendor );
HYPRE_Int hypre_SetSpMVUseVendor( HYPRE_Int use_vendor );
HYPRE_Int hypre_SetSpGemmUseVendor( HYPRE_Int use_vendor );
HYPRE_Int hypre_SetSpGemmAlgorithm( HYPRE_Int value );
HYPRE_Int hypre_SetSpGemmAlgorithmBinned( HYPRE_Int value );
HYPRE_Int hypre_SetSpGemmBinned( HYPRE_Int value );
HYPRE_Int hypre_SetSpGemmRownnzEstimateMethod( HYPRE_Int value );
HYPRE_Int hypre_SetSpGemmRownnzEstimateNSamples( HYPRE_Int value );
HYPRE_Int hypre_SetSpGemmRownnzEstimateMultFactor( HYPRE_Real value );

View File

@ -530,9 +530,11 @@ struct hypre_DeviceData
HYPRE_Int struct_comm_send_buffer_size;
/* device spgemm options */
HYPRE_Int spgemm_algorithm;
HYPRE_Int spgemm_algorithm_binned;
HYPRE_Int spgemm_algorithm_num_bin;
HYPRE_Int spgemm_algorithm_max_num_blocks[4][HYPRE_SPGEMM_MAX_NBIN + 1];
HYPRE_Int spgemm_binned;
HYPRE_Int spgemm_num_bin;
/* for bin i: ([0][i], [2][i]) = (max #block to launch, block dimension) for symbl
* ([1][i], [3][i]) = (max #block to launch, block dimension) for numer */
HYPRE_Int spgemm_block_num_dim[4][HYPRE_SPGEMM_MAX_NBIN + 1];
HYPRE_Int spgemm_rownnz_estimate_method;
HYPRE_Int spgemm_rownnz_estimate_nsamples;
float spgemm_rownnz_estimate_mult_factor;
@ -563,9 +565,9 @@ struct hypre_DeviceData
#define hypre_DeviceDataSpMVUseVendor(data) ((data) -> spmv_use_vendor)
#define hypre_DeviceDataSpTransUseVendor(data) ((data) -> sptrans_use_vendor)
#define hypre_DeviceDataSpgemmAlgorithm(data) ((data) -> spgemm_algorithm)
#define hypre_DeviceDataSpgemmAlgorithmBinned(data) ((data) -> spgemm_algorithm_binned)
#define hypre_DeviceDataSpgemmAlgorithmNumBin(data) ((data) -> spgemm_algorithm_num_bin)
#define hypre_DeviceDataSpgemmAlgorithmMaxNumBlocks(data) ((data) -> spgemm_algorithm_max_num_blocks)
#define hypre_DeviceDataSpgemmBinned(data) ((data) -> spgemm_binned)
#define hypre_DeviceDataSpgemmNumBin(data) ((data) -> spgemm_num_bin)
#define hypre_DeviceDataSpgemmBlockNumDim(data) ((data) -> spgemm_block_num_dim)
#define hypre_DeviceDataSpgemmRownnzEstimateMethod(data) ((data) -> spgemm_rownnz_estimate_method)
#define hypre_DeviceDataSpgemmRownnzEstimateNsamples(data) ((data) -> spgemm_rownnz_estimate_nsamples)
#define hypre_DeviceDataSpgemmRownnzEstimateMultFactor(data) ((data) -> spgemm_rownnz_estimate_mult_factor)

View File

@ -41,14 +41,14 @@ hypre_DeviceDataCreate()
hypre_DeviceDataSpTransUseVendor(data) = 0;
#endif
const HYPRE_Int Nsamples = 64;
const HYPRE_Real sigma = 1.0 / sqrt(Nsamples - 2.0);
const HYPRE_Real multfactor = 1.0 / (1.0 - 3.0 * sigma);
hypre_DeviceDataSpgemmAlgorithm(data) = 1;
hypre_DeviceDataSpgemmAlgorithmBinned(data) = 0;
hypre_DeviceDataSpgemmAlgorithmNumBin(data) = 0;
hypre_DeviceDataSpgemmBinned(data) = 0;
hypre_DeviceDataSpgemmNumBin(data) = 0;
/* 1: naive overestimate, 2: naive underestimate, 3: Cohen's algorithm */
hypre_DeviceDataSpgemmRownnzEstimateMethod(data) = 3;
const HYPRE_Int Nsamples = 64;
const HYPRE_Real sigma = 1.0 / sqrt(Nsamples - 2.0);
const HYPRE_Real multfactor = 1.0 / (1.0 - 3.0 * sigma);
hypre_DeviceDataSpgemmRownnzEstimateNsamples(data) = Nsamples;
hypre_DeviceDataSpgemmRownnzEstimateMultFactor(data) = multfactor;

View File

@ -473,9 +473,11 @@ struct hypre_DeviceData
HYPRE_Int struct_comm_send_buffer_size;
/* device spgemm options */
HYPRE_Int spgemm_algorithm;
HYPRE_Int spgemm_algorithm_binned;
HYPRE_Int spgemm_algorithm_num_bin;
HYPRE_Int spgemm_algorithm_max_num_blocks[4][HYPRE_SPGEMM_MAX_NBIN + 1];
HYPRE_Int spgemm_binned;
HYPRE_Int spgemm_num_bin;
/* for bin i: ([0][i], [2][i]) = (max #block to launch, block dimension) for symbl
* ([1][i], [3][i]) = (max #block to launch, block dimension) for numer */
HYPRE_Int spgemm_block_num_dim[4][HYPRE_SPGEMM_MAX_NBIN + 1];
HYPRE_Int spgemm_rownnz_estimate_method;
HYPRE_Int spgemm_rownnz_estimate_nsamples;
float spgemm_rownnz_estimate_mult_factor;
@ -506,9 +508,9 @@ struct hypre_DeviceData
#define hypre_DeviceDataSpMVUseVendor(data) ((data) -> spmv_use_vendor)
#define hypre_DeviceDataSpTransUseVendor(data) ((data) -> sptrans_use_vendor)
#define hypre_DeviceDataSpgemmAlgorithm(data) ((data) -> spgemm_algorithm)
#define hypre_DeviceDataSpgemmAlgorithmBinned(data) ((data) -> spgemm_algorithm_binned)
#define hypre_DeviceDataSpgemmAlgorithmNumBin(data) ((data) -> spgemm_algorithm_num_bin)
#define hypre_DeviceDataSpgemmAlgorithmMaxNumBlocks(data) ((data) -> spgemm_algorithm_max_num_blocks)
#define hypre_DeviceDataSpgemmBinned(data) ((data) -> spgemm_binned)
#define hypre_DeviceDataSpgemmNumBin(data) ((data) -> spgemm_num_bin)
#define hypre_DeviceDataSpgemmBlockNumDim(data) ((data) -> spgemm_block_num_dim)
#define hypre_DeviceDataSpgemmRownnzEstimateMethod(data) ((data) -> spgemm_rownnz_estimate_method)
#define hypre_DeviceDataSpgemmRownnzEstimateNsamples(data) ((data) -> spgemm_rownnz_estimate_nsamples)
#define hypre_DeviceDataSpgemmRownnzEstimateMultFactor(data) ((data) -> spgemm_rownnz_estimate_mult_factor)

View File

@ -61,10 +61,10 @@ hypre_SetSpGemmAlgorithm( HYPRE_Int value )
}
HYPRE_Int
hypre_SetSpGemmAlgorithmBinned( HYPRE_Int value )
hypre_SetSpGemmBinned( HYPRE_Int value )
{
#if defined(HYPRE_USING_GPU)
hypre_HandleSpgemmAlgorithmBinned(hypre_handle()) = value;
hypre_HandleSpgemmBinned(hypre_handle()) = value;
#endif
return hypre_error_flag;
}

View File

@ -79,9 +79,9 @@ typedef struct
#define hypre_HandleSpMVUseVendor(hypre_handle) hypre_DeviceDataSpMVUseVendor(hypre_HandleDeviceData(hypre_handle))
#define hypre_HandleSpTransUseVendor(hypre_handle) hypre_DeviceDataSpTransUseVendor(hypre_HandleDeviceData(hypre_handle))
#define hypre_HandleSpgemmAlgorithm(hypre_handle) hypre_DeviceDataSpgemmAlgorithm(hypre_HandleDeviceData(hypre_handle))
#define hypre_HandleSpgemmAlgorithmBinned(hypre_handle) hypre_DeviceDataSpgemmAlgorithmBinned(hypre_HandleDeviceData(hypre_handle))
#define hypre_HandleSpgemmAlgorithmNumBin(hypre_handle) hypre_DeviceDataSpgemmAlgorithmNumBin(hypre_HandleDeviceData(hypre_handle))
#define hypre_HandleSpgemmAlgorithmMaxNumBlocks(hypre_handle) hypre_DeviceDataSpgemmAlgorithmMaxNumBlocks(hypre_HandleDeviceData(hypre_handle))
#define hypre_HandleSpgemmBinned(hypre_handle) hypre_DeviceDataSpgemmBinned(hypre_HandleDeviceData(hypre_handle))
#define hypre_HandleSpgemmNumBin(hypre_handle) hypre_DeviceDataSpgemmNumBin(hypre_HandleDeviceData(hypre_handle))
#define hypre_HandleSpgemmBlockNumDim(hypre_handle) hypre_DeviceDataSpgemmBlockNumDim(hypre_HandleDeviceData(hypre_handle))
#define hypre_HandleSpgemmRownnzEstimateMethod(hypre_handle) hypre_DeviceDataSpgemmRownnzEstimateMethod(hypre_HandleDeviceData(hypre_handle))
#define hypre_HandleSpgemmRownnzEstimateNsamples(hypre_handle) hypre_DeviceDataSpgemmRownnzEstimateNsamples(hypre_HandleDeviceData(hypre_handle))
#define hypre_HandleSpgemmRownnzEstimateMultFactor(hypre_handle) hypre_DeviceDataSpgemmRownnzEstimateMultFactor(hypre_HandleDeviceData(hypre_handle))

View File

@ -345,7 +345,7 @@ HYPRE_Int hypre_SetSpTransUseVendor( HYPRE_Int use_vendor );
HYPRE_Int hypre_SetSpMVUseVendor( HYPRE_Int use_vendor );
HYPRE_Int hypre_SetSpGemmUseVendor( HYPRE_Int use_vendor );
HYPRE_Int hypre_SetSpGemmAlgorithm( HYPRE_Int value );
HYPRE_Int hypre_SetSpGemmAlgorithmBinned( HYPRE_Int value );
HYPRE_Int hypre_SetSpGemmBinned( HYPRE_Int value );
HYPRE_Int hypre_SetSpGemmRownnzEstimateMethod( HYPRE_Int value );
HYPRE_Int hypre_SetSpGemmRownnzEstimateNSamples( HYPRE_Int value );
HYPRE_Int hypre_SetSpGemmRownnzEstimateMultFactor( HYPRE_Real value );