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

Fixes build and tests on Windows #1519

Open
wants to merge 19 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
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
2 changes: 1 addition & 1 deletion .uberenv_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"spack_packages_path": ["scripts/spack/radiuss-spack-configs/packages", "scripts/spack/packages"],
"spack_concretizer": "clingo",
"vcpkg_url": "https://github.com/microsoft/vcpkg",
"vcpkg_commit": "898b728edc5e0d12b50015f9cd18247c4257a3eb",
"vcpkg_commit": "d5ec528843d29e3a52d745a64b469f810b2cedbf",
"vcpkg_triplet": "x64-windows",
"vcpkg_ports_path": "scripts/vcpkg_ports"
}
2 changes: 2 additions & 0 deletions scripts/vcpkg_ports/umpire/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ vcpkg_from_github(
REF v2024.07.0
SHA512 c29c39b74641485e81bfaebc9eb2c36a2404e7866848d50f4dc6c576f03bf0ec3989d21ee0f8c573e40c11ad6c279054feefaf50ff7dcc2eb617c4ac60b8520d
HEAD_REF develop
PATCHES v2024.07.0-chrono-include.patch
)


vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
FEATURES
openmp ENABLE_OPENMP
Expand Down
12 changes: 12 additions & 0 deletions scripts/vcpkg_ports/umpire/v2024.07.0-chrono-include.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/src/umpire/event/event.hpp b/src/umpire/event/event.hpp
index 03f0d37..db84c1c 100644
--- a/src/umpire/event/event.hpp
+++ b/src/umpire/event/event.hpp
@@ -7,6 +7,7 @@
#ifndef UMPIRE_event_HPP
#define UMPIRE_event_HPP

+#include <chrono>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@davidbeckingsale -- My local machine did not need this on Windows, but our CI needed this for [email protected].
I saw that it was recently added to umpire@develop -- LLNL/Umpire#934

#include <cstdint>
#include <map>
#include <sstream>
6 changes: 3 additions & 3 deletions src/axom/config.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
/*
* Axom source location
*/
#define AXOM_SRC_DIR "@AXOM_SRC_DIR@"
#define AXOM_BIN_DIR "@AXOM_BIN_DIR@"
#cmakedefine AXOM_DATA_DIR "@AXOM_DATA_DIR@"
#define AXOM_SRC_DIR "@AXOM_SRC_DIR_NATIVE@"
#define AXOM_BIN_DIR "@AXOM_BIN_DIR_NATIVE@"
#cmakedefine AXOM_DATA_DIR "@AXOM_DATA_DIR_NATIVE@"

/*
* Platform specific definitions
Expand Down
8 changes: 6 additions & 2 deletions src/axom/core/Macros.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,12 @@
* \brief Macro used to silence UndefinedBehaviorSanitizer errors
* when compiling and linking with -fsanitize=undefined
*/
#if __has_attribute(no_sanitize_undefined)
#define AXOM_SUPPRESS_UBSAN __attribute__((no_sanitize_undefined))
#if defined(__has_attribute)
#if __has_attribute(no_sanitize_undefined)
#define AXOM_SUPPRESS_UBSAN __attribute__((no_sanitize_undefined))
#else
#define AXOM_SUPPRESS_UBSAN
#endif
#else
#define AXOM_SUPPRESS_UBSAN
#endif
Expand Down
2 changes: 2 additions & 0 deletions src/axom/core/memory_management.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,8 @@ inline MemorySpace getAllocatorSpace(int allocatorId)
default:
return MemorySpace::Dynamic;
}
#else
return MemorySpace::Dynamic;
#endif
}

Expand Down
40 changes: 40 additions & 0 deletions src/axom/core/tests/core_utilities.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include "axom/config.hpp"
#include "axom/core/utilities/Utilities.hpp"
#include "axom/core/utilities/Sorting.hpp"

#include <algorithm>
#include <random>
Expand Down Expand Up @@ -77,3 +78,42 @@ TEST(core_utilities, insertion_sort_doubles)
}
}
}

TEST(core_utilities, qsort_sort_double)
{
constexpr int NUM_ITERS = 1000;
constexpr int MAX_SIZE = 100;

// Run this for a few iterations to test that sorting works on different random shuffles.
for(int n = 1; n < MAX_SIZE; ++n)
{
std::vector<double> vec;
vec.resize(n);

for(int iter = 0; iter < NUM_ITERS; iter++)
{
// Fill it with random doubles in the range of [0, 1024)
std::generate_n(vec.data(), n, []() -> double {
return axom::utilities::random_real(0., 1024.);
});

// sort the first two iterations in descending/ascending order
if(iter == 0)
{
std::sort(vec.begin(), vec.end(), [](int a, int b) { return a > b; });
}
else if(iter == 1)
{
std::sort(vec.begin(), vec.end(), [](int a, int b) { return a < b; });
}

axom::utilities::Sorting<double, MAX_SIZE>::qsort(vec.data(), n);
}

// Check that the results are sorted
for(int i = 1; i < n; i++)
{
EXPECT_TRUE(vec[i - 1] <= vec[i]) << "data not sorted!";
}
}
}
22 changes: 21 additions & 1 deletion src/axom/core/utilities/Sorting.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ struct Sorting

if(low < high)
{
int pivot_index = partition(values, low, high);
const int pivot_index = partition(values, low, high);

stack[stack_count][0] = low;
stack[stack_count][1] = pivot_index - 1;
Expand All @@ -105,6 +105,26 @@ struct Sorting
AXOM_HOST_DEVICE
static int partition(T *values, int low, int high)
{
// Median-of-three pivot selection
const int mid = low + (high - low) / 2;

// Find the median of values[low], values[mid], values[high]
if(values[low] > values[mid])
{
axom::utilities::swap(values[low], values[mid]);
}
if(values[low] > values[high])
{
axom::utilities::swap(values[low], values[high]);
}
if(values[mid] > values[high])
{
axom::utilities::swap(values[mid], values[high]);
}

// Use the median as the pivot
axom::utilities::swap(values[mid], values[high]);

const T pivot = values[high];
int i = low - 1;
for(int j = low; j < high; j++)
Expand Down
158 changes: 80 additions & 78 deletions src/axom/mir/clipping/ClipCases.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
//---------------------------------------------------------------------------
// Axom modifications
// NOTE: The values for EA-EL and N0-N3 were reduced.
// NOTE: We're using AXOM_MIR_EXPORT instead of VISIT_VTK_LIGHT_API througout
// clang-format off
//#include <visit_vtk_light_exports.h>
#define VISIT_VTK_LIGHT_API

#include "axom/export/mir.h"

#include <cstdlib>
namespace axom {
namespace mir {
Expand Down Expand Up @@ -88,87 +90,87 @@ namespace visit {
#define NOCOLOR 122

// Tables
extern VISIT_VTK_LIGHT_API int numClipCasesHex;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing the export macro. I don't know how I overlooked that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(there were a lot of files :) )

extern VISIT_VTK_LIGHT_API int numClipShapesHex[256];
extern VISIT_VTK_LIGHT_API int startClipShapesHex[256];
extern VISIT_VTK_LIGHT_API unsigned char clipShapesHex[];

extern VISIT_VTK_LIGHT_API int numClipCasesVox;
extern VISIT_VTK_LIGHT_API int numClipShapesVox[256];
extern VISIT_VTK_LIGHT_API int startClipShapesVox[256];
extern VISIT_VTK_LIGHT_API unsigned char clipShapesVox[];

extern VISIT_VTK_LIGHT_API int numClipCasesWdg;
extern VISIT_VTK_LIGHT_API int numClipShapesWdg[64];
extern VISIT_VTK_LIGHT_API int startClipShapesWdg[64];
extern VISIT_VTK_LIGHT_API unsigned char clipShapesWdg[];

extern VISIT_VTK_LIGHT_API int numClipCasesPyr;
extern VISIT_VTK_LIGHT_API int numClipShapesPyr[32];
extern VISIT_VTK_LIGHT_API int startClipShapesPyr[32];
extern VISIT_VTK_LIGHT_API unsigned char clipShapesPyr[];

extern VISIT_VTK_LIGHT_API int numClipCasesTet;
extern VISIT_VTK_LIGHT_API int numClipShapesTet[16];
extern VISIT_VTK_LIGHT_API int startClipShapesTet[16];
extern VISIT_VTK_LIGHT_API unsigned char clipShapesTet[];

extern VISIT_VTK_LIGHT_API int numClipCasesQua;
extern VISIT_VTK_LIGHT_API int numClipShapesQua[16];
extern VISIT_VTK_LIGHT_API int startClipShapesQua[16];
extern VISIT_VTK_LIGHT_API unsigned char clipShapesQua[];

extern VISIT_VTK_LIGHT_API int numClipCasesPix;
extern VISIT_VTK_LIGHT_API int numClipShapesPix[16];
extern VISIT_VTK_LIGHT_API int startClipShapesPix[16];
extern VISIT_VTK_LIGHT_API unsigned char clipShapesPix[];

extern VISIT_VTK_LIGHT_API int numClipCasesTri;
extern VISIT_VTK_LIGHT_API int numClipShapesTri[8];
extern VISIT_VTK_LIGHT_API int startClipShapesTri[8];
extern VISIT_VTK_LIGHT_API unsigned char clipShapesTri[];

extern VISIT_VTK_LIGHT_API int numClipCasesLin;
extern VISIT_VTK_LIGHT_API int numClipShapesLin[4];
extern VISIT_VTK_LIGHT_API int startClipShapesLin[4];
extern VISIT_VTK_LIGHT_API unsigned char clipShapesLin[];

extern VISIT_VTK_LIGHT_API int numClipCasesVtx;
extern VISIT_VTK_LIGHT_API int numClipShapesVtx[2];
extern VISIT_VTK_LIGHT_API int startClipShapesVtx[2];
extern VISIT_VTK_LIGHT_API unsigned char clipShapesVtx[];

extern VISIT_VTK_LIGHT_API int numClipCasesPoly5;
extern VISIT_VTK_LIGHT_API int numClipShapesPoly5[32];
extern VISIT_VTK_LIGHT_API int startClipShapesPoly5[32];
extern VISIT_VTK_LIGHT_API unsigned char clipShapesPoly5[];

extern VISIT_VTK_LIGHT_API int numClipCasesPoly6;
extern VISIT_VTK_LIGHT_API int numClipShapesPoly6[64];
extern VISIT_VTK_LIGHT_API int startClipShapesPoly6[64];
extern VISIT_VTK_LIGHT_API unsigned char clipShapesPoly6[];

extern VISIT_VTK_LIGHT_API int numClipCasesPoly7;
extern VISIT_VTK_LIGHT_API int numClipShapesPoly7[128];
extern VISIT_VTK_LIGHT_API int startClipShapesPoly7[128];
extern VISIT_VTK_LIGHT_API unsigned char clipShapesPoly7[];

extern VISIT_VTK_LIGHT_API int numClipCasesPoly8;
extern VISIT_VTK_LIGHT_API int numClipShapesPoly8[256];
extern VISIT_VTK_LIGHT_API int startClipShapesPoly8[256];
extern VISIT_VTK_LIGHT_API unsigned char clipShapesPoly8[];
extern AXOM_MIR_EXPORT int numClipCasesHex;
extern AXOM_MIR_EXPORT int numClipShapesHex[256];
extern AXOM_MIR_EXPORT int startClipShapesHex[256];
extern AXOM_MIR_EXPORT unsigned char clipShapesHex[];

extern AXOM_MIR_EXPORT int numClipCasesVox;
extern AXOM_MIR_EXPORT int numClipShapesVox[256];
extern AXOM_MIR_EXPORT int startClipShapesVox[256];
extern AXOM_MIR_EXPORT unsigned char clipShapesVox[];

extern AXOM_MIR_EXPORT int numClipCasesWdg;
extern AXOM_MIR_EXPORT int numClipShapesWdg[64];
extern AXOM_MIR_EXPORT int startClipShapesWdg[64];
extern AXOM_MIR_EXPORT unsigned char clipShapesWdg[];

extern AXOM_MIR_EXPORT int numClipCasesPyr;
extern AXOM_MIR_EXPORT int numClipShapesPyr[32];
extern AXOM_MIR_EXPORT int startClipShapesPyr[32];
extern AXOM_MIR_EXPORT unsigned char clipShapesPyr[];

extern AXOM_MIR_EXPORT int numClipCasesTet;
extern AXOM_MIR_EXPORT int numClipShapesTet[16];
extern AXOM_MIR_EXPORT int startClipShapesTet[16];
extern AXOM_MIR_EXPORT unsigned char clipShapesTet[];

extern AXOM_MIR_EXPORT int numClipCasesQua;
extern AXOM_MIR_EXPORT int numClipShapesQua[16];
extern AXOM_MIR_EXPORT int startClipShapesQua[16];
extern AXOM_MIR_EXPORT unsigned char clipShapesQua[];

extern AXOM_MIR_EXPORT int numClipCasesPix;
extern AXOM_MIR_EXPORT int numClipShapesPix[16];
extern AXOM_MIR_EXPORT int startClipShapesPix[16];
extern AXOM_MIR_EXPORT unsigned char clipShapesPix[];

extern AXOM_MIR_EXPORT int numClipCasesTri;
extern AXOM_MIR_EXPORT int numClipShapesTri[8];
extern AXOM_MIR_EXPORT int startClipShapesTri[8];
extern AXOM_MIR_EXPORT unsigned char clipShapesTri[];

extern AXOM_MIR_EXPORT int numClipCasesLin;
extern AXOM_MIR_EXPORT int numClipShapesLin[4];
extern AXOM_MIR_EXPORT int startClipShapesLin[4];
extern AXOM_MIR_EXPORT unsigned char clipShapesLin[];

extern AXOM_MIR_EXPORT int numClipCasesVtx;
extern AXOM_MIR_EXPORT int numClipShapesVtx[2];
extern AXOM_MIR_EXPORT int startClipShapesVtx[2];
extern AXOM_MIR_EXPORT unsigned char clipShapesVtx[];

extern AXOM_MIR_EXPORT int numClipCasesPoly5;
extern AXOM_MIR_EXPORT int numClipShapesPoly5[32];
extern AXOM_MIR_EXPORT int startClipShapesPoly5[32];
extern AXOM_MIR_EXPORT unsigned char clipShapesPoly5[];

extern AXOM_MIR_EXPORT int numClipCasesPoly6;
extern AXOM_MIR_EXPORT int numClipShapesPoly6[64];
extern AXOM_MIR_EXPORT int startClipShapesPoly6[64];
extern AXOM_MIR_EXPORT unsigned char clipShapesPoly6[];

extern AXOM_MIR_EXPORT int numClipCasesPoly7;
extern AXOM_MIR_EXPORT int numClipShapesPoly7[128];
extern AXOM_MIR_EXPORT int startClipShapesPoly7[128];
extern AXOM_MIR_EXPORT unsigned char clipShapesPoly7[];

extern AXOM_MIR_EXPORT int numClipCasesPoly8;
extern AXOM_MIR_EXPORT int numClipShapesPoly8[256];
extern AXOM_MIR_EXPORT int startClipShapesPoly8[256];
extern AXOM_MIR_EXPORT unsigned char clipShapesPoly8[];

//---------------------------------------------------------------------------
// Axom modifications
#define ST_MIN ST_TET
#define ST_MAX (ST_PNT + 1)
#undef VISIT_VTK_LIGHT_API
extern const size_t clipShapesTriSize;
extern const size_t clipShapesQuaSize;
extern const size_t clipShapesTetSize;
extern const size_t clipShapesPyrSize;
extern const size_t clipShapesWdgSize;
extern const size_t clipShapesHexSize;

extern AXOM_MIR_EXPORT const size_t clipShapesTriSize;
extern AXOM_MIR_EXPORT const size_t clipShapesQuaSize;
extern AXOM_MIR_EXPORT const size_t clipShapesTetSize;
extern AXOM_MIR_EXPORT const size_t clipShapesPyrSize;
extern AXOM_MIR_EXPORT const size_t clipShapesWdgSize;
extern AXOM_MIR_EXPORT const size_t clipShapesHexSize;
} // namespace visit
} // namespace clipping
} // namespace mir
Expand Down
6 changes: 3 additions & 3 deletions src/axom/mir/tests/mir_clipfield.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ std::vector<int> permute(const std::vector<int> &input)
std::iota(indices.begin(), indices.end(), 0);
for(size_t i = 0; i < input.size(); i++)
{
order[i] = drand48();
order[i] = axom::utilities::random_real(0., 1.);
}
std::sort(indices.begin(), indices.end(), [&](int a, int b) {
return order[a] < order[b];
Expand All @@ -292,12 +292,12 @@ std::vector<int> makeUnsortedArray(int n)

std::vector<int> makeRandomArray(int n)
{
constexpr int largestId = 1 << 28;
constexpr double largestId = static_cast<double>(1 << 28);
std::vector<int> values;
values.resize(n);
for(int i = 0; i < n; i++)
{
values[i] = static_cast<int>(largestId * drand48());
values[i] = static_cast<int>(axom::utilities::random_real(0., largestId));
}
return permute(values);
}
Expand Down
28 changes: 14 additions & 14 deletions src/axom/mir/tests/mir_views.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,26 +34,26 @@ std::string baselineDirectory()

TEST(mir_views, shape2conduitName)
{
EXPECT_EQ(axom::mir::views::LineShape<int>::name(), "line");
EXPECT_EQ(axom::mir::views::LineShape<long>::name(), "line");
EXPECT_STREQ(axom::mir::views::LineShape<int>::name(), "line");
EXPECT_STREQ(axom::mir::views::LineShape<long>::name(), "line");

EXPECT_EQ(axom::mir::views::TriShape<int>::name(), "tri");
EXPECT_EQ(axom::mir::views::TriShape<long>::name(), "tri");
EXPECT_STREQ(axom::mir::views::TriShape<int>::name(), "tri");
EXPECT_STREQ(axom::mir::views::TriShape<long>::name(), "tri");

EXPECT_EQ(axom::mir::views::QuadShape<int>::name(), "quad");
EXPECT_EQ(axom::mir::views::QuadShape<long>::name(), "quad");
EXPECT_STREQ(axom::mir::views::QuadShape<int>::name(), "quad");
EXPECT_STREQ(axom::mir::views::QuadShape<long>::name(), "quad");

EXPECT_EQ(axom::mir::views::TetShape<int>::name(), "tet");
EXPECT_EQ(axom::mir::views::TetShape<long>::name(), "tet");
EXPECT_STREQ(axom::mir::views::TetShape<int>::name(), "tet");
EXPECT_STREQ(axom::mir::views::TetShape<long>::name(), "tet");

EXPECT_EQ(axom::mir::views::PyramidShape<int>::name(), "pyramid");
EXPECT_EQ(axom::mir::views::PyramidShape<long>::name(), "pyramid");
EXPECT_STREQ(axom::mir::views::PyramidShape<int>::name(), "pyramid");
EXPECT_STREQ(axom::mir::views::PyramidShape<long>::name(), "pyramid");

EXPECT_EQ(axom::mir::views::WedgeShape<int>::name(), "wedge");
EXPECT_EQ(axom::mir::views::WedgeShape<long>::name(), "wedge");
EXPECT_STREQ(axom::mir::views::WedgeShape<int>::name(), "wedge");
EXPECT_STREQ(axom::mir::views::WedgeShape<long>::name(), "wedge");

EXPECT_EQ(axom::mir::views::HexShape<int>::name(), "hex");
EXPECT_EQ(axom::mir::views::HexShape<long>::name(), "hex");
EXPECT_STREQ(axom::mir::views::HexShape<int>::name(), "hex");
EXPECT_STREQ(axom::mir::views::HexShape<long>::name(), "hex");
}

//------------------------------------------------------------------------------
Expand Down
Loading