Skip to content

Commit 228d970

Browse files
committed
address clang compiler warnings and minor issues / memory leaks for non-core tests and examples
1 parent 1cb531f commit 228d970

File tree

14 files changed

+49
-521
lines changed

14 files changed

+49
-521
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ TESTS = bivar_function bivar_transform ccsdt_map_test ccsdt_t3_to_t2 dft diag_ct
4141

4242
BENCHMARKS = bench_contraction bench_nosym_transp bench_redistribution model_trainer
4343

44-
SCALAPACK_TESTS = nonsq_pgemm_test nonsq_pgemm_bench hosvd qr svd
44+
SCALAPACK_TESTS = hosvd qr svd
4545

4646
STUDIES = fast_diagram fast_3mm fast_sym fast_sym_4D \
4747
fast_tensor_ctr fast_sy_as_as_tensor_ctr fast_as_as_sy_tensor_ctr

configure

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -565,13 +565,14 @@ fi
565565

566566
if [ "x$LIB_PATH" = "x" ]; then
567567
LIB_PATH=""
568-
fi
569-
570-
if [ "x$LD_LIB_PATH" = "x" ]; then
568+
elif [ "x$LD_LIB_PATH" = "x" ]; then
571569
echo "LD_LIB_PATH was unspecified but LIB_PATH was, setting LD_LIB_PATH=$LIB_PATH."
572570
LD_LIB_PATH=$LIB_PATH
573571
fi
574-
if [ "x$LD_LIBS" = "x" ]; then
572+
573+
if [ "x$LIBS" = "x" ]; then
574+
LIBS=""
575+
elif [ "x$LD_LIBS" = "x" ]; then
575576
echo "LD_LIBS was unspecified but LIBS was, setting LD_LIBS=$LIBS."
576577
LD_LIBS=$LIBS
577578
fi

examples/ao_mo_transf.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ char* getCmdOption(char ** begin,
215215
}
216216

217217
int main(int argc, char ** argv){
218-
int m, n, k, bench, bench_io;
218+
int m, n, k, bench;
219219
int const in_num = argc;
220220
char ** input_str = argv;
221221

examples/block_sparse.cxx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ Matrix<> flatten_block_sparse_matrix(Matrix< Tensor<> > A, std::vector<int> rang
4949
ends[1] = range_pfx[i]+ranges[i];
5050
flatA.slice(offs,ends,0.0,A_blks[b],zeros,A_blks[b].lens,1.0);
5151
}
52+
free(blk_inds);
53+
delete [] A_blks;
5254
return flatA;
5355

5456
}
@@ -118,15 +120,17 @@ int block_sparse(std::vector<int> ranges, World & dw){
118120
A_blks[i].d.fill_random(0,1);
119121
}
120122
A.write(nblk,A_blks);
121-
int64_t B_blk_inds[nblk];
122-
Tensor<> B_blks[nblk];
123+
int64_t * B_blk_inds = new int64_t[nblk];
124+
Tensor<> * B_blks = new Tensor<>[nblk];
123125
for (int64_t i=0; i<nblk; i++){
124126
int64_t j = rand()%nblk;
125127
B_blk_inds[i] = i + j*nblk;
126128
B_blks[i] = Matrix<>(ranges[i],ranges[j],dw);
127129
B_blks[i].fill_random(1.,1.);
128130
}
129131
B.write(nblk,B_blk_inds,B_blks);
132+
delete [] B_blks;
133+
delete [] B_blk_inds;
130134
Matrix< Tensor<> > C(nblk, nblk, SP, self_world, tmon);
131135

132136
C["ij"] = Function< Tensor<> >(

examples/btwn_central.cxx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -347,12 +347,10 @@ int main(int argc, char ** argv){
347347
if (test < 0) test = 0;
348348
} else test = 0;
349349
if (getCmdOption(input_str, input_str+in_num, "-sp_B")){
350-
sp_B = atoi(getCmdOption(input_str, input_str+in_num, "-sp_B"));
351-
if (sp_B < 0 || sp_B > 1) sp_B = 1;
350+
sp_B = (bool)atoi(getCmdOption(input_str, input_str+in_num, "-sp_B"));
352351
} else sp_B = 1;
353352
if (getCmdOption(input_str, input_str+in_num, "-sp_C")){
354-
sp_C = atoi(getCmdOption(input_str, input_str+in_num, "-sp_C"));
355-
if (sp_C < 0 || sp_C > 1) sp_C = 1;
353+
sp_C = (bool)atoi(getCmdOption(input_str, input_str+in_num, "-sp_C"));
356354
} else sp_C = 1;
357355

358356

scalapack_tests/conj.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22
#define __CONJ_H__
33

44
template <typename dtype>
5-
Matrix<dtype> conj(Matrix<dtype> & A){
5+
CTF::Matrix<dtype> conj(CTF::Matrix<dtype> & A){
66
return A;
77
}
88
template <>
9-
Matrix< std::complex<float> > conj(Matrix< std::complex<float> > & A){
10-
Matrix< std::complex<float> > B(A);
11-
B["ij"] = Function< std::complex<float>>([](std::complex<float> a){ return std::conj(a); })(A["ij"]);
9+
CTF::Matrix< std::complex<float> > conj(CTF::Matrix< std::complex<float> > & A){
10+
CTF::Matrix< std::complex<float> > B(A);
11+
B["ij"] = CTF::Function< std::complex<float>>([](std::complex<float> a){ return std::conj(a); })(A["ij"]);
1212
return B;
1313
}
1414
template <>
15-
Matrix<std::complex<double>> conj(Matrix<std::complex<double>> & A){
16-
Matrix<std::complex<double>> B(A);
17-
B["ij"] = Function<std::complex<double>>([](std::complex<double> a){ return std::conj(a); })(A["ij"]);
15+
CTF::Matrix<std::complex<double>> conj(CTF::Matrix<std::complex<double>> & A){
16+
CTF::Matrix<std::complex<double>> B(A);
17+
B["ij"] = CTF::Function<std::complex<double>>([](std::complex<double> a){ return std::conj(a); })(A["ij"]);
1818
return B;
1919
}
2020
#endif

scalapack_tests/hosvd.cxx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ Tensor<> get_core_tensor(Tensor<>& T, std::vector< Matrix <> > factor_matrices,
135135
char matrix_arg[3];
136136
matrix_arg[0] = 'a';
137137
matrix_arg[2] = '\0';
138-
Matrix<double> transpose();
139138
for (int i = 0; i < T.order; i++) {
140139
core_arg[i] = 'a';
141140
matrix_arg[1] = arg[i];
@@ -192,7 +191,6 @@ Tensor<> get_core_tensor_hooi(Tensor<>& T, std::vector< Matrix <> > factor_matri
192191
char matrix_arg[3];
193192
matrix_arg[0] = 'a';
194193
matrix_arg[2] = '\0';
195-
Matrix<double> transpose();
196194
for (int i = 0; i < T.order; i++) {
197195
if (i != j) {
198196
core_arg[i] = 'a';

0 commit comments

Comments
 (0)