comparison libinterp/corefcn/sparse-xpow.cc @ 31227:0dec459a4064

sparse-xpow.cc: Performance tweak for threshold selection
author Arun Giridhar <arungiridhar@gmail.com>
date Wed, 14 Sep 2022 09:59:31 -0400
parents 44cf6bbeeca9
children a026fb2be108
comparison
equal deleted inserted replaced
31226:44cf6bbeeca9 31227:0dec459a4064
130 // and use squaring for exponents larger than that. 130 // and use squaring for exponents larger than that.
131 // 131 //
132 // FIXME: Improve this threshold calculation. 132 // FIXME: Improve this threshold calculation.
133 133
134 uint64_t sparsity = atmp.numel() / atmp.nnz(); // reciprocal of density 134 uint64_t sparsity = atmp.numel() / atmp.nnz(); // reciprocal of density
135 int threshold = (sparsity >= 10000) ? 40 135 int threshold = (sparsity >= 1000) ? 40
136 : (sparsity >= 1000) ? 30 136 : (sparsity >= 100) ? 20
137 : (sparsity >= 100) ? 20
138 : 3; 137 : 3;
139 138
140 if (btmp > threshold) // use squaring technique 139 if (btmp > threshold) // use squaring technique
141 { 140 {
142 while (btmp > 0) 141 while (btmp > 0)
218 // for more details. 217 // for more details.
219 // 218 //
220 // FIXME: Improve this threshold calculation. 219 // FIXME: Improve this threshold calculation.
221 220
222 uint64_t sparsity = atmp.numel() / atmp.nnz(); // reciprocal of density 221 uint64_t sparsity = atmp.numel() / atmp.nnz(); // reciprocal of density
223 int threshold = (sparsity >= 10000) ? 40 222 int threshold = (sparsity >= 1000) ? 40
224 : (sparsity >= 1000) ? 30 223 : (sparsity >= 100) ? 20
225 : (sparsity >= 100) ? 20
226 : 3; 224 : 3;
227 225
228 if (btmp > threshold) // use squaring technique 226 if (btmp > threshold) // use squaring technique
229 { 227 {
230 while (btmp > 0) 228 while (btmp > 0)