Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused variables, duplicate code #730

Merged
merged 1 commit into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/C-interface/bml_parallel.c
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ bml_mpi_recv_matrix(
break;
default:
LOG_ERROR("unknown matrix type\n");
return NULL;
break;
}
}
Expand Down
2 changes: 0 additions & 2 deletions src/C-interface/csr/bml_allocate_csr.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ csr_noinit_table(
int i, lwr;
const int alloc_size =
INIT_SLOT_STORAGE_SIZE >= tsize ? INIT_SLOT_STORAGE_SIZE : tsize;
static int powers[] =
{ 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18 };
static int powersof2[] =
{ 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768,
65536, 131072, 262144
Expand Down
1 change: 1 addition & 0 deletions src/C-interface/csr/bml_normalize_csr.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ bml_accumulate_offdiag_csr(
#endif
default:
LOG_ERROR("unknown precision\n");
return NULL;
break;
}
}
Expand Down
1 change: 1 addition & 0 deletions src/C-interface/csr/bml_parallel_csr.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ bml_mpi_recv_matrix_csr(
#endif
default:
LOG_ERROR("unknown precision\n");
return NULL;
break;
}
}
Expand Down
1 change: 0 additions & 1 deletion src/C-interface/csr/bml_threshold_csr_typed.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ void TYPED_FUNC(
const int annz = A->data_[i]->NNZ_;
for (int pos = 0; pos < annz; pos++)
{
const int j = cols[pos];
if (is_above_threshold(vals[pos], threshold))
{
if (rlen < pos)
Expand Down
1 change: 0 additions & 1 deletion src/C-interface/dense/bml_allocate_dense.c
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,6 @@ bml_update_domain_dense(
{
bml_domain_t *A_domain = A->domain;

int myRank = bml_getMyRank();
int nprocs = bml_getNRanks();

for (int i = 0; i < nprocs; i++)
Expand Down
1 change: 1 addition & 0 deletions src/C-interface/dense/bml_normalize_dense.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ bml_accumulate_offdiag_dense(
#endif
default:
LOG_ERROR("unknown precision\n");
return NULL;
break;
}
}
Expand Down
1 change: 1 addition & 0 deletions src/C-interface/dense/bml_parallel_dense.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ bml_mpi_recv_matrix_dense(
#endif
default:
LOG_ERROR("unknown precision\n");
return NULL;
break;
}
}
Expand Down
2 changes: 0 additions & 2 deletions src/C-interface/dense/bml_parallel_dense_typed.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ void TYPED_FUNC(
bml_matrix_dense_t * A)
{
#ifdef BML_USE_MPI
int myRank = bml_getMyRank();

int N = A->N;

REAL_T *A_matrix = A->matrix;
Expand Down
5 changes: 4 additions & 1 deletion src/C-interface/dense/bml_utilities_dense_typed.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ void TYPED_FUNC(
char header1[20], header2[20], header3[20], header4[20], header5[20];
int hdimx, nnz, irow, icol;
int values_read;
double real_part, imaginary_part;
double real_part;
#if (defined(SINGLE_COMPLEX) || defined(DOUBLE_COMPLEX))
double imaginary_part;
#endif

int N = A->N;

Expand Down
2 changes: 0 additions & 2 deletions src/C-interface/distributed2d/bml_allocate_distributed2d.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@

/* MPI communicator for all the distributed2d matrices */
static MPI_Comm s_comm = MPI_COMM_NULL;
static MPI_Comm r_comm = MPI_COMM_NULL;
static MPI_Comm c_comm = MPI_COMM_NULL;

void
bml_setcomm_distributed2d(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,8 @@ void TYPED_FUNC(
int ione = 1;
int izero = 0;
int np0 = NUMROC(&m, &mb, &my_prow, &izero, &np_rows);
int nq0 = NUMROC(&m, &mb, &my_pcol, &izero, &np_cols);
#if defined(SINGLE_REAL) || defined(DOUBLE_REAL)
int nq0 = NUMROC(&m, &mb, &my_pcol, &izero, &np_cols);
int lwork = MAX(1 + 6 * m + 2 * np0 * nq0,
3 * m + MAX(mb * (np0 + 1), 3 * mb)) + 2 * m;
#else
Expand Down
1 change: 1 addition & 0 deletions src/C-interface/ellblock/bml_normalize_ellblock.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ bml_accumulate_offdiag_ellblock(
#endif
default:
LOG_ERROR("unknown precision\n");
return NULL;
break;
}
}
Expand Down
1 change: 1 addition & 0 deletions src/C-interface/ellblock/bml_parallel_ellblock.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ bml_mpi_recv_matrix_ellblock(
#endif
default:
LOG_ERROR("unknown precision\n");
return NULL;
break;
}
}
Expand Down
2 changes: 0 additions & 2 deletions src/C-interface/ellblock/bml_threshold_ellblock_typed.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,6 @@ void TYPED_FUNC(
int *A_nnzb = A->nnzb;
int *bsize = A->bsize;

int rlen;

for (int ib = 0; ib < NB; ib++)
{
for (int jp = 0; jp < A_nnzb[ib]; jp++)
Expand Down
2 changes: 0 additions & 2 deletions src/C-interface/ellpack/bml_add_ellpack_typed.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,6 @@ double TYPED_FUNC(
int *B_nnz = B->nnz;
int *B_index = B->index;

int ind, ind2;

REAL_T *A_value = (REAL_T *) A->value;
REAL_T *B_value = (REAL_T *) B->value;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ void TYPED_FUNC(
int A_M = A->M;
int l;
int ll;
int j;
REAL_T *A_value = (REAL_T *) A->value;
int *A_index = A->index;
int *A_nnz = A->nnz;
Expand Down
1 change: 0 additions & 1 deletion src/C-interface/ellpack/bml_allocate_ellpack.c
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,6 @@ bml_update_domain_ellpack(
{
bml_domain_t *A_domain = A->domain;

int myRank = bml_getMyRank();
int nprocs = bml_getNRanks();

for (int i = 0; i < nprocs; i++)
Expand Down
4 changes: 2 additions & 2 deletions src/C-interface/ellpack/bml_allocate_ellpack_typed.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ void TYPED_FUNC(
#else
memset(A->nnz, 0, A->N * sizeof(int));
memset(A->index, 0, A->N * A->M * sizeof(int));
memset(A->value, 0.0, A->N * A->M * sizeof(REAL_T));
memset(A_value, 0.0, A->N * A->M * sizeof(REAL_T));
#endif

#endif // conditional for offload
Expand Down Expand Up @@ -226,12 +226,12 @@ bml_matrix_ellpack_t *TYPED_FUNC(
A->csrRowPtr = bml_allocate_memory(sizeof(int) * (N + 1));
A->csrVal = bml_allocate_memory(sizeof(REAL_T) * N * M);
#endif
REAL_T *A_value = A->value;

A->domain = bml_default_domain(N, M, distrib_mode);
A->domain2 = bml_default_domain(N, M, distrib_mode);

#if defined(USE_OMP_OFFLOAD)
REAL_T *A_value = A->value;
int *A_nnz = A->nnz;
int *A_index = A->index;
int NM = N * M;
Expand Down
2 changes: 1 addition & 1 deletion src/C-interface/ellpack/bml_getters_ellpack_typed.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void *TYPED_FUNC(
}
for (int j_index = 0; j_index < A->nnz[i]; j_index++)
{
if (A->index[ROWMAJOR(i, j_index, A->N, A->M)] == j)
if (A_index[ROWMAJOR(i, j_index, A->N, A->M)] == j)
{
return &A_value[ROWMAJOR(i, j_index, A->N, A->M)];
}
Expand Down
2 changes: 0 additions & 2 deletions src/C-interface/ellpack/bml_introspection_ellpack_typed.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ double TYPED_FUNC(
double threshold)
{
int nnzs = 0;
int i;
int j;
double sparsity;
REAL_T *A_value = (REAL_T *) A->value;
int A_N = A->N;
Expand Down
1 change: 1 addition & 0 deletions src/C-interface/ellpack/bml_parallel_ellpack.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ bml_mpi_recv_matrix_ellpack(
#endif
default:
LOG_ERROR("unknown precision\n");
return NULL;
break;
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/C-interface/ellpack/bml_parallel_ellpack_typed.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ void TYPED_FUNC(
bml_allGatherVParallel_ellpack) (
bml_matrix_ellpack_t * A)
{
int myRank = bml_getMyRank();
int nRanks = bml_getNRanks();
#ifdef BML_USE_MPI
//int myRank = bml_getMyRank();
//int nRanks = bml_getNRanks();

int N = A->N;
int M = A->M;
Expand All @@ -43,7 +44,6 @@ void TYPED_FUNC(

REAL_T *A_value = (REAL_T *) A->value;

#ifdef BML_USE_MPI
/*
for (int i = 0; i < nRanks; i++)
{
Expand Down
67 changes: 13 additions & 54 deletions src/C-interface/ellpack/bml_scale_ellpack_typed.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,47 +27,13 @@
*/
bml_matrix_ellpack_t *TYPED_FUNC(
bml_scale_ellpack_new) (
void *_scale_factor,
void *scale_factor,
bml_matrix_ellpack_t * A)
{
REAL_T *scale_factor = _scale_factor;
bml_matrix_ellpack_t *B = TYPED_FUNC(bml_copy_ellpack_new) (A);

REAL_T *B_value = B->value;
int myRank = bml_getMyRank();
int nElems = B->domain->localRowExtent[myRank] * B->M;
int startIndex = B->domain->localDispl[myRank];
int inc = 1;

int N = A->N;
int M = A->M;

int *A_nnz = A->nnz;
int *A_index = A->index;
REAL_T *A_value = A->value;

int *B_nnz = B->nnz;
int *B_index = B->index;
REAL_T scale = *scale_factor;
#ifdef USE_OMP_OFFLOAD
#pragma omp target teams distribute parallel for collapse(2)
for (int i = 0; i < N; i++)
{
for (int j = 0; j < M; j++)
{
B_value[ROWMAJOR(i, j, M, N)] =
scale * A_value[ROWMAJOR(i, j, M, N)];
}
}
#else // offload conditional
TYPED_FUNC(bml_scale_ellpack)(scale_factor, A, B);

#ifdef NOBLAS
LOG_ERROR("No BLAS library");
#else
C_BLAS(SCAL) (&nElems, scale_factor, &(B_value[startIndex]), &inc);
#endif

#endif // offload conditional
return B;
}

Expand All @@ -84,43 +50,38 @@ void TYPED_FUNC(
bml_matrix_ellpack_t * A,
bml_matrix_ellpack_t * B)
{
// copy necessary so that B has the same structure as A
if (A != B)
{
TYPED_FUNC(bml_copy_ellpack) (A, B);
}

REAL_T *scale_factor = _scale_factor;
REAL_T *B_value = B->value;
int myRank = bml_getMyRank();
int nElems = B->domain->localRowExtent[myRank] * B->M;
int startIndex = B->domain->localDispl[myRank];
int inc = 1;

int N = A->N;
int M = A->M;

int *A_nnz = A->nnz;
int *A_index = A->index;
REAL_T *A_value = A->value;

int *B_nnz = B->nnz;
int *B_index = B->index;
REAL_T scale = *scale_factor;
#ifdef USE_OMP_OFFLOAD
REAL_T scale = *scale_factor;
#pragma omp target teams distribute parallel for collapse(2)
for (int i = 0; i < N; i++)
{
for (int j = 0; j < M; j++)
{
B_value[ROWMAJOR(i, j, M, N)] =
scale * A_value[ROWMAJOR(i, j, M, N)];
scale * B_value[ROWMAJOR(i, j, M, N)];
}
}
#else // offload conditional

#ifdef NOBLAS
LOG_ERROR("No BLAS library");
#else
int myRank = bml_getMyRank();
int nElems = B->domain->localRowExtent[myRank] * B->M;
int startIndex = B->domain->localDispl[myRank];
int inc = 1;
C_BLAS(SCAL) (&nElems, scale_factor, &(B_value[startIndex]), &inc);
#endif

Expand All @@ -134,17 +95,11 @@ void TYPED_FUNC(
{
REAL_T *scale_factor = _scale_factor;
REAL_T *A_value = A->value;
int myRank = bml_getMyRank();
int number_elements = A->domain->localRowExtent[myRank] * A->M;
int startIndex = A->domain->localDispl[myRank];
int inc = 1;

#ifdef USE_OMP_OFFLOAD
int N = A->N;
int M = A->M;

int *A_nnz = A->nnz;
int *A_index = A->index;
REAL_T scale = *scale_factor;
size_t MbyN = N * M;
#pragma omp target teams distribute parallel for map(to:MbyN,scale)
Expand All @@ -157,6 +112,10 @@ void TYPED_FUNC(
#ifdef NOBLAS
LOG_ERROR("No BLAS library");
#else
int myRank = bml_getMyRank();
int number_elements = A->domain->localRowExtent[myRank] * A->M;
int startIndex = A->domain->localDispl[myRank];
int inc = 1;
C_BLAS(SCAL) (&number_elements, scale_factor, &(A_value[startIndex]),
&inc);
#endif
Expand Down
3 changes: 0 additions & 3 deletions src/C-interface/ellpack/bml_setters_ellpack_typed.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,12 @@ void TYPED_FUNC(
{
int A_N = A->N;
int A_M = A->M;
int l;
int ll;

REAL_T *A_value = (REAL_T *) A->value;
int *A_index = A->index;
int *A_nnz = A->nnz;

#ifdef USE_OMP_OFFLOAD
//#pragma omp target
#pragma omp target update from(A_nnz[:A_N], A_index[:A_N*A_M], A_value[:A_N*A_M])
#endif
A_value[ROWMAJOR(i, A_nnz[i], A_N, A_M)] = *((REAL_T *) element);
Expand Down
4 changes: 2 additions & 2 deletions src/C-interface/ellpack/bml_trace_ellpack_typed.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ double TYPED_FUNC(
int myRank = bml_getMyRank();
int rowMin = A_localRowMin[myRank];
int rowMax = A_localRowMax[myRank];
int numrows = rowMax - rowMin;

#ifdef USE_OMP_OFFLOAD
int numrows = rowMax - rowMin;
REAL_T *diag;
diag = (REAL_T *) calloc(numrows, sizeof(REAL_T));
#pragma omp target enter data map(to:diag[:numrows])
Expand Down Expand Up @@ -130,10 +130,10 @@ double TYPED_FUNC(
int B_N = B->N;
int B_M = B->M;

#ifdef USE_OMP_OFFLOAD
REAL_T *B_value = (REAL_T *) B->value;
int *B_index = (int *) B->index;
int *B_nnz = (int *) B->nnz;
#ifdef USE_OMP_OFFLOAD
#pragma omp target update from(A_nnz[:A_N], A_index[:A_N*A_M], A_value[:A_N*A_M])
#pragma omp target update from(B_nnz[:B_N], B_index[:B_N*B_M], B_value[:B_N*B_M])
#endif
Expand Down
Loading