Skip to content

Commit 002ded4

Browse files
committed
Fix build errors and warnings when building with MSVC
1 parent a373091 commit 002ded4

14 files changed

+48
-44
lines changed

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,14 @@ OPTION(ENABLE_PYTHON_EMBED "Enable embedded PYTHON interpreter when ENABLE_PYTHO
6060
OPTION(ENABLE_PHYSICS_UTILS "Enable PYTHON physics specific tools" OFF)
6161
OPTION(FLOAT_TYPE "C++ data type used for floating-point values" OFF)
6262
OPTION(INDEX_TYPE "C++ data type used for tensor indices" OFF)
63-
OPTION(ENABLE_GCP "Enable experimental GCP code" ON)
63+
OPTION(ENABLE_GCP "Enable GCP code" ON)
6464
OPTION(ENABLE_LAPACK "Enable BLAS/LAPACK. Only required for CPU (cuBLAS/cuSolver are used on Cuda and rocBLAS/rocSolver on HIP)." ON)
6565
OPTION(ENABLE_TRILINOS "Enable use of Trilinos packages" OFF)
6666
OPTION(ENABLE_TEUCHOS "Enable Teuchos utilities" ON)
6767
OPTION(ENABLE_TPETRA "Enable Tpetra distributed parallelism" ON)
6868
OPTION(ENABLE_ROL "Enable ROL optimization package" ON)
6969
OPTION(ENABLE_SEACAS "Enable SEACAS tools" ON)
70+
OPTION(ENABLE_REAL_TIME_CLOCK "Enable real-time clock for timing (disable if you get linking errors related to WinMM.lib on windows)" ON)
7071
OPTION(ENABLE_CMAKE_TIMERS "Enable timers for each compile/link step" OFF)
7172
OPTION(PYGENTEN_PIP "Indicate pyGenTen is being built through pip" OFF)
7273
OPTION(PYGENTEN_MPI "Enable MPI in pyGenTen when being built through pip" OFF)

cmake/ConfigureBuildType.cmake

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,19 @@ ENDIF (CMAKE_VERBOSE_MAKEFILE)
102102

103103
#---- Real time timers are enabled if system libraries can be found.
104104
#---- The GenTen_SystemTimer class is informed thru HAVE_REALTIME_CLOCK.
105-
SET (HAVE_REALTIME_CLOCK TRUE)
106-
IF (WIN32)
107-
FIND_LIBRARY (WINMM_LIBRARY winmm ${WIN32_LIBRARY_SEARCHPATHS})
108-
IF (NOT WINMM_LIBRARY)
109-
MESSAGE (STATUS "GenTen: Could not find WinMM.lib, timers disabled.")
110-
SET (HAVE_REALTIME_CLOCK FALSE)
111-
ELSE (NOT WINMM_LIBRARY)
112-
#TBD...have to test this; probably need it linked with executables
105+
IF (ENABLE_REAL_TIME_CLOCK)
106+
SET (HAVE_REALTIME_CLOCK TRUE)
107+
IF (WIN32)
108+
FIND_LIBRARY (WINMM_LIBRARY winmm)
109+
IF (WINMM_LIBRARY)
110+
MESSAGE (STATUS "GenTen: Found WinMM.lib: ${WINMM_LIBRARY}, real time clock timers enabled.")
113111
SET (OPSYS_LIBRARIES ${OPSYS_LIBRARIES} ${WINMM_LIBRARY})
114-
ENDIF (NOT WINMM_LIBRARY)
115-
ENDIF (WIN32)
112+
ELSE (WINMM_LIBRARY)
113+
MESSAGE (STATUS "GenTen: Could not find WinMM.lib, real time clock timers disabled.")
114+
SET (HAVE_REALTIME_CLOCK FALSE)
115+
ENDIF (WINMM_LIBRARY)
116+
ENDIF (WIN32)
117+
ELSE (ENABLE_REAL_TIME_CLOCK)
118+
SET (HAVE_REALTIME_CLOCK FALSE)
119+
MESSAGE (STATUS "GenTen: Real time clock timers disabled.")
120+
ENDIF (ENABLE_REAL_TIME_CLOCK)

performance/Genten_CpAlsRandomKtensor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ int run_cpals(const Genten::IndxArray& cFacDims_host,
167167
for (ttb_indx i = 0; i < perfInfo.size(); i++)
168168
{
169169
printf (" %2lu: fit = %.6e, resnorm = %.2e, time = %.3f secs\n",
170-
perfInfo[i].iteration, perfInfo[i].fit,
170+
unsigned long(perfInfo[i].iteration), perfInfo[i].fit,
171171
perfInfo[i].residual, perfInfo[i].cum_time);
172172
}
173173

src/Genten_FacMatrix.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,7 +1122,7 @@ void colNorms_kernel(
11221122
Kernel::policy(m),
11231123
KOKKOS_LAMBDA(TeamMember team)
11241124
{
1125-
ColNormsKernel_Inf<ExecSpace,ViewType,NormT,RowBlockSize,ColBlockSize,TeamSize,VectorSize> kernel(data, norms, team);
1125+
Kernel kernel(data, norms, team);
11261126
for (unsigned j_block=0; j_block<n; j_block+=ColBlockSize) {
11271127
if (j_block+ColBlockSize <= n)
11281128
kernel.template run<ColBlockSize>(j_block, ColBlockSize);
@@ -1146,7 +1146,7 @@ void colNorms_kernel(
11461146
Kernel::policy(m),
11471147
KOKKOS_LAMBDA(TeamMember team)
11481148
{
1149-
ColNormsKernel_1<ExecSpace,ViewType,NormT,RowBlockSize,ColBlockSize,TeamSize,VectorSize> kernel(data, norms, team);
1149+
Kernel kernel(data, norms, team);
11501150
for (unsigned j_block=0; j_block<n; j_block+=ColBlockSize) {
11511151
if (j_block+ColBlockSize <= n)
11521152
kernel.template run<ColBlockSize>(j_block, ColBlockSize);
@@ -1169,7 +1169,7 @@ void colNorms_kernel(
11691169
Kernel::policy(m),
11701170
KOKKOS_LAMBDA(TeamMember team)
11711171
{
1172-
ColNormsKernel_2<ExecSpace,ViewType,NormT,RowBlockSize,ColBlockSize,TeamSize,VectorSize> kernel(data, norms, team);
1172+
Kernel kernel(data, norms, team);
11731173
for (unsigned j_block=0; j_block<n; j_block+=ColBlockSize) {
11741174
if (j_block+ColBlockSize <= n)
11751175
kernel.template run<ColBlockSize>(j_block, ColBlockSize);
@@ -1358,7 +1358,7 @@ void colSums_kernel(
13581358
Kernel::policy(m),
13591359
KOKKOS_LAMBDA(TeamMember team)
13601360
{
1361-
ColSumsKernel<ExecSpace,ViewType,SumT,RowBlockSize,ColBlockSize,TeamSize,VectorSize> kernel(data, sums, team);
1361+
Kernel kernel(data, sums, team);
13621362
for (unsigned j_block=0; j_block<n; j_block+=ColBlockSize) {
13631363
if (j_block+ColBlockSize <= n)
13641364
kernel.template run<ColBlockSize>(j_block, ColBlockSize);
@@ -1474,7 +1474,7 @@ void colScale_kernel(const ViewType& data, const Genten::ArrayT<ExecSpace>& v)
14741474
Kokkos::parallel_for("Genten::FacMatrix::colScale_kernel",
14751475
Kernel::policy(m), KOKKOS_LAMBDA(TeamMember team)
14761476
{
1477-
ColScaleKernel<ExecSpace,ViewType,ColBlockSize,RowBlockSize,TeamSize,VectorSize> kernel(data, v, team);
1477+
Kernel kernel(data, v, team);
14781478
for (unsigned j_block=0; j_block<n; j_block+=ColBlockSize) {
14791479
if (j_block+ColBlockSize <= n)
14801480
kernel.template run<ColBlockSize>(j_block, ColBlockSize);
@@ -1568,11 +1568,13 @@ rowScale(const Genten::ArrayT<ExecSpace> & v, bool inverse) const
15681568

15691569
// Only called by Ben Allan's parallel test code. It appears he uses the Linux
15701570
// random number generator in a special way.
1571-
#if !defined(_WIN32)
15721571
template <typename ExecSpace>
15731572
void Genten::FacMatrixT<ExecSpace>::
15741573
scaleRandomElements(ttb_real fraction, ttb_real scale, bool columnwise) const
15751574
{
1575+
#if defined(_WIN32)
1576+
Genten::error("Genten::FacMatrix::scaleRandomElements - not implemented on Windows");
1577+
#else
15761578
const ttb_indx nrows = data.extent(0);
15771579
const ttb_indx ncols = data.extent(1);
15781580
auto data_1d = make_data_1d();
@@ -1614,8 +1616,8 @@ scaleRandomElements(ttb_real fraction, ttb_real scale, bool columnwise) const
16141616
}
16151617
}
16161618
}
1619+
#endif
16171620
}
1618-
#endif
16191621

16201622
// TODO: This function really should be removed and replaced with a ktensor norm function, because that's kind of how it's used.
16211623
template <typename ExecSpace>
@@ -3143,7 +3145,7 @@ ttb_real mat_innerprod_kernel(const MatViewType& x, const MatViewType& y,
31433145
Kernel::policy(m),
31443146
KOKKOS_LAMBDA(TeamMember team, ttb_real& d)
31453147
{
3146-
MatInnerProdKernel<ExecSpace,MatViewType,WeightViewType,RowBlockSize,ColBlockSize,TeamSize,VectorSize> kernel(x, y, w, team);
3148+
Kernel kernel(x, y, w, team);
31473149
for (unsigned j_block=0; j_block<n; j_block+=ColBlockSize) {
31483150
if (j_block+ColBlockSize <= n)
31493151
kernel.template run<ColBlockSize>(j_block, ColBlockSize, d);

src/Genten_GCP_SemiStratifiedSampler.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ namespace Genten {
197197
rand_pool = rand_pool_;
198198

199199
// Sort/hash tensor if necessary for faster sampling
200-
if (printitn > 0) {
200+
if (printitn) {
201201
if (algParams.hash)
202202
out << "Hashing tensor for faster sampling...";
203203
else
@@ -210,7 +210,7 @@ namespace Genten {
210210
else if (!X.isSorted())
211211
X.sort();
212212
timer.stop(0);
213-
if (printitn > 0)
213+
if (printitn)
214214
out << timer.getTotalTime(0) << " seconds" << std::endl;
215215
}
216216

src/Genten_GCP_StratifiedSampler.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ namespace Genten {
201201
rand_pool = rand_pool_;
202202

203203
// Sort/hash tensor if necessary for faster sampling
204-
if (printitn > 0) {
204+
if (printitn) {
205205
if (algParams.hash)
206206
out << "Hashing tensor for faster sampling...";
207207
else
@@ -214,7 +214,7 @@ namespace Genten {
214214
else if (!X.isSorted())
215215
X.sort();
216216
timer.stop(0);
217-
if (printitn > 0)
217+
if (printitn)
218218
out << timer.getTotalTime(0) << " seconds" << std::endl;
219219
}
220220

src/Genten_GCP_UniformSampler.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ namespace Genten {
177177
rand_pool = rand_pool_;
178178

179179
// Sort/hash tensor if necessary for faster sampling
180-
if (printitn > 0) {
180+
if (printitn) {
181181
if (algParams.hash)
182182
out << "Hashing tensor for faster sampling...";
183183
else
@@ -190,7 +190,7 @@ namespace Genten {
190190
else if (!X.isSorted())
191191
X.sort();
192192
timer.stop(0);
193-
if (printitn > 0)
193+
if (printitn)
194194
out << timer.getTotalTime(0) << " seconds" << std::endl;
195195
}
196196

src/Genten_JSON_Schema.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -462,8 +462,8 @@ static nlohmann::json json_schema = R"(
462462
"default": 0.0
463463
}
464464
}
465-
},
466-
"gcp-opt": {
465+
},)"
466+
R"("gcp-opt": {
467467
"type": "object",
468468
"description": "GCP-OPT decomposition algorithm",
469469
"additionalProperties": false,
@@ -778,8 +778,8 @@ static nlohmann::json json_schema = R"(
778778
"$ref": "#/definitions/goal"
779779
}
780780
}
781-
},
782-
"gcp-fed": {
781+
},)"
782+
R"("gcp-fed": {
783783
"type": "object",
784784
"description": "GCP decomposition algorithm based on federated learning",
785785
"additionalProperties": false,

src/Genten_Ktensor.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,6 @@ setRandomUniform (const bool bUseMatlabRNG,
173173

174174

175175
// Only called by Ben Allan's parallel test code.
176-
#if !defined(_WIN32)
177176
template <typename ExecSpace>
178177
void Genten::KtensorImpl<ExecSpace>::
179178
scaleRandomElements(ttb_real fraction, ttb_real scale, bool columnwise) const
@@ -182,7 +181,6 @@ scaleRandomElements(ttb_real fraction, ttb_real scale, bool columnwise) const
182181
data[i].scaleRandomElements(fraction, scale, columnwise);
183182
}
184183
}
185-
#endif
186184

187185
template <typename ExecSpace>
188186
void Genten::KtensorImpl<ExecSpace>::

src/Genten_MTTKRP.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ void orig_kokkos_mttkrp_kernel(const SptensorImpl<ExecSpace>& X,
689689
if (i >= nnz)
690690
return;
691691

692-
MTTKRP_OrigKokkosKernelBlock<ExecSpace, FacBlockSize, TeamSize, VectorSize> kernel(X, u, n, v, i, team);
692+
Kernel kernel(X, u, n, v, i, team);
693693

694694
for (unsigned j=0; j<nc; j+=FacBlockSize) {
695695
if (j+FacBlockSize <= nc)

0 commit comments

Comments
 (0)