Skip to content

Commit 7809e9a

Browse files
author
Zachary DeBruine
committed
Fix CRAN pretest failures: clang 21 errors/warnings + Windows byte ambiguity
- krylov.hpp: Remove erroneous .template on topRows(k) runtime calls - dense_spz_loader.hpp, spz_loader.hpp: Fix member initializer order (-Wreorder) - speckled_cv.hpp: Explicit cast uint64_t to double (-Wimplicit-const-int-float-conversion) - spmv.hpp: Fix undefined 'n' variable, guard with #ifdef _OPENMP - fused_nnls.hpp: Suppress unused 'threads' parameter in non-OpenMP paths - fit_cv.hpp: Remove unused variables (actual_threads, t_conv_us) - deflation.hpp: Remove dead k_computed assignment - sparsepress_v2.hpp: Remove unused private fields, suppress num_threads warning - fit_cpu.hpp: Fix %ld format with long long args on Windows (use int cast) - platform.hpp, platform_io.hpp: Fix std::byte vs rpcndr.h byte ambiguity on MinGW - Makevars.win: Add -Wno-ignored-attributes to suppress Eigen SSE noise
1 parent ab7fa45 commit 7809e9a

15 files changed

Lines changed: 117 additions & 30 deletions

File tree

inst/build_config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ cuda_version=
44
cuda_home=
55
nvcc_path=
66
gpu_arch=
7-
build_date=2026-03-14T14:03:24Z
7+
build_date=2026-03-14T16:07:22Z

inst/include/FactorNet/core/platform.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,16 @@
1616
#include <string>
1717

1818
#if defined(_WIN32)
19+
// Workaround for MinGW C++17+: std::byte (from <cstddef>) conflicts
20+
// with rpcndr.h "typedef unsigned char byte;" inside <windows.h>.
21+
// Temporarily rename the Windows byte to avoid the ambiguity.
22+
#define WIN32_LEAN_AND_MEAN
23+
#ifndef NOMINMAX
24+
#define NOMINMAX
25+
#endif
26+
#define byte win_byte_override
1927
#include <windows.h>
28+
#undef byte
2029
#elif defined(__APPLE__)
2130
#include <sys/sysctl.h>
2231
#include <unistd.h>

inst/include/FactorNet/io/dense_spz_loader.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class DenseSpzLoader : public DataLoader<Scalar> {
5252
*/
5353
explicit DenseSpzLoader(const std::string& path,
5454
bool require_transpose = true)
55-
: fwd_idx_(0), trans_idx_(0), in_core_(false)
55+
: in_core_(false), fwd_idx_(0), trans_idx_(0)
5656
{
5757
reader_ = std::make_unique<streampress::FileReader>(path);
5858
file_size_ = reader_->file_size();

inst/include/FactorNet/io/spz_loader.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class SpzLoader : public DataLoader<Scalar> {
5555
* @param require_transpose If true (default), throw if file lacks transpose section
5656
*/
5757
explicit SpzLoader(const std::string& path, bool require_transpose = true)
58-
: fwd_idx_(0), trans_idx_(0), in_core_(false)
58+
: in_core_(false), fwd_idx_(0), trans_idx_(0)
5959
{
6060
reader_ = std::make_unique<streampress::FileReader>(path);
6161
file_size_ = reader_->file_size();
@@ -303,7 +303,7 @@ class SpzLoader : public DataLoader<Scalar> {
303303
? header_.metadata_offset
304304
: file_size_ - streampress::v2::FOOTER_SIZE;
305305

306-
uint64_t trans_section_size = trans_end - trans_start;
306+
(void)(trans_end - trans_start); // trans_section_size unused but validates range
307307

308308
// Read the full file from offset 0 to trans_end into a buffer
309309
// so TransposeChunkReader can parse it (it needs header + transpose data)

inst/include/FactorNet/nmf/fit_cpu.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1813,9 +1813,9 @@ ::FactorNet::NMFResult<Scalar> nmf_fit(
18131813
// --- Timer report ---
18141814
_t_end = std::chrono::high_resolution_clock::now();
18151815
if (config.verbose) {
1816-
auto us = [](auto a, auto b) { return std::chrono::duration_cast<std::chrono::microseconds>(b - a).count(); };
1817-
Rprintf("[iter %d] gram_h=%ldus rhs_h=%ldus nnls_h=%ldus norm_h=%ldus | "
1818-
"gram_w=%ldus rhs_w=%ldus nnls_w=%ldus norm_w=%ldus | loss=%ldus | total=%ldus\n",
1816+
auto us = [](auto a, auto b) { return static_cast<int>(std::chrono::duration_cast<std::chrono::microseconds>(b - a).count()); };
1817+
Rprintf("[iter %d] gram_h=%dus rhs_h=%dus nnls_h=%dus norm_h=%dus | "
1818+
"gram_w=%dus rhs_w=%dus nnls_w=%dus norm_w=%dus | loss=%dus | total=%dus\n",
18191819
iter, us(_t_gram_h, _t_rhs_h), us(_t_rhs_h, _t_nnls_h),
18201820
us(_t_nnls_h, _t_norm_h), us(_t_norm_h, _t_gram_w),
18211821
us(_t_gram_w, _t_rhs_w), us(_t_rhs_w, _t_nnls_w),

inst/include/FactorNet/nmf/fit_cv.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -364,16 +364,15 @@ ::FactorNet::NMFResult<Scalar> nmf_fit_cv(
364364
? config.threads
365365
: omp_get_max_threads();
366366
#else
367-
const int actual_threads = 1;
368-
#endif
369367
(void)n_threads;
368+
#endif
370369

371370
// ------------------------------------------------------------------
372371
// 5. Iteration loop
373372
// ------------------------------------------------------------------
374373

375374
// Timing accumulators (microseconds) for profiling
376-
int64_t t_h_update_us = 0, t_w_update_us = 0, t_loss_us = 0, t_conv_us = 0;
375+
int64_t t_h_update_us = 0, t_w_update_us = 0, t_loss_us = 0;
377376
auto tick = []() { return std::chrono::high_resolution_clock::now(); };
378377
auto elapsed_us = [](auto start, auto end) {
379378
return std::chrono::duration_cast<std::chrono::microseconds>(end - start).count();

inst/include/FactorNet/nmf/speckled_cv.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class LazySpeckledMask {
8484
h = (h ^ (h >> 30)) * 0xbf58476d1ce4e5b9ULL;
8585
h = (h ^ (h >> 27)) * 0x94d049bb133111ebULL;
8686
h ^= h >> 31;
87-
uint64_t threshold = static_cast<uint64_t>(col_subsample_frac_ * 0xFFFFFFFFFFFFFFFFULL);
87+
uint64_t threshold = static_cast<uint64_t>(col_subsample_frac_ * static_cast<double>(0xFFFFFFFFFFFFFFFFULL));
8888
return h < threshold;
8989
}
9090

@@ -98,7 +98,7 @@ class LazySpeckledMask {
9898
h = (h ^ (h >> 30)) * 0xbf58476d1ce4e5b9ULL;
9999
h = (h ^ (h >> 27)) * 0x94d049bb133111ebULL;
100100
h ^= h >> 31;
101-
uint64_t threshold = static_cast<uint64_t>(row_subsample_frac_ * 0xFFFFFFFFFFFFFFFFULL);
101+
uint64_t threshold = static_cast<uint64_t>(row_subsample_frac_ * static_cast<double>(0xFFFFFFFFFFFFFFFFULL));
102102
return h < threshold;
103103
}
104104

inst/include/FactorNet/primitives/cpu/fused_nnls.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ inline void fused_rhs_nnls_sparse(
9393
#ifdef _OPENMP
9494
int n_threads = (threads > 0) ? threads : omp_get_max_threads();
9595
#else
96-
int n_threads = 1;
96+
int n_threads = 1; // NOLINT(misc-const-correctness)
97+
(void)threads;
9798
#endif
9899

99100
const bool has_L1 = (L1 > Scalar(0));
@@ -175,6 +176,7 @@ inline void fused_rhs_cholesky_sparse(
175176
int n_threads = (threads > 0) ? threads : omp_get_max_threads();
176177
#else
177178
int n_threads = 1;
179+
(void)threads;
178180
#endif
179181

180182
// Pre-factorize G once — O(k³), amortized over n columns

inst/include/FactorNet/svd/deflation.hpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -619,8 +619,6 @@ SVDResult<Scalar> deflation_svd(const MatrixType& A,
619619
col_weights.setOnes();
620620
}
621621

622-
int k_computed = 0;
623-
624622
for (int k = 0; k < k_max; ++k) {
625623
SVD_CHECK_INTERRUPT();
626624

@@ -865,7 +863,6 @@ SVDResult<Scalar> deflation_svd(const MatrixType& A,
865863
U_all.col(k) = u;
866864
d_all(k) = sigma;
867865
V_all.col(k) = v;
868-
k_computed = k + 1;
869866

870867
result.iters_per_factor.push_back(iter);
871868

inst/include/FactorNet/svd/krylov.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,12 +228,12 @@ void extract_svd_from_factors(
228228

229229
DenseMatrix<Scalar> Q_w = qr_w.householderQ() *
230230
DenseMatrix<Scalar>::Identity(W.rows(), k);
231-
DenseMatrix<Scalar> R_w = qr_w.matrixQR().template topRows(k)
231+
DenseMatrix<Scalar> R_w = qr_w.matrixQR().topRows(k)
232232
.template triangularView<Eigen::Upper>();
233233

234234
DenseMatrix<Scalar> Q_h = qr_h.householderQ() *
235235
DenseMatrix<Scalar>::Identity(H.rows(), k);
236-
DenseMatrix<Scalar> R_h = qr_h.matrixQR().template topRows(k)
236+
DenseMatrix<Scalar> R_h = qr_h.matrixQR().topRows(k)
237237
.template triangularView<Eigen::Upper>();
238238

239239
// Small SVD of R_w · R_h' (k × k)

0 commit comments

Comments
 (0)