Skip to content
Snippets Groups Projects
Commit c78989f4 authored by Jaswant Panchumarti (Kitware)'s avatar Jaswant Panchumarti (Kitware)
Browse files

Merge branch 'bump-docker-img' into 'main'

Bump dockcross/web-wasm:20240812-60fa1b0

See merge request vtk/vtk-wasm-sdk!10
parents 350664b1 556ec871
No related branches found
No related tags found
No related merge requests found
FROM docker.io/dockcross/web-wasm:20240529-0dade71
FROM docker.io/dockcross/web-wasm:20240812-60fa1b0
LABEL maintainer="Jaswant Panchumarti jaswant.panchumarti@kitware.com"
ARG BUILD_DATE
......@@ -30,6 +30,9 @@ RUN cmake --version && \
-DCMAKE_CROSSCOMPILING_EMULATOR=$PWD/.gitlab/node/bin/node \
-DCMAKE_C_COMPILER_LAUNCHER=$SCCACHE_MOUNTPOINT \
-DCMAKE_CXX_COMPILER_LAUNCHER=$SCCACHE_MOUNTPOINT \
-DCMAKE_C_FLAGS=-Wno-limited-postlink-optimizations \
-DCMAKE_CXX_FLAGS=-Wno-limited-postlink-optimizations \
-DCMAKE_EXE_LINKER_FLAGS=-Wno-limited-postlink-optimizations \
-S $PWD \
-B /VTK-build \
-G "Ninja Multi-Config" \
......
......@@ -70,7 +70,7 @@ readonly vtk_version
cd "$current_dir"
# Use podman to avoid having to do docker-in-docker shenanigans.
docker="podman --storage-driver=vfs"
docker="podman"
readonly docker
# Construct image tags from vtk_version and date.
......
......@@ -17,7 +17,7 @@ image_build_tag="$( cat "$script_dir/TAG" )"
readonly image_build_tag
# Use podman to avoid having to do docker-in-docker shenanigans.
docker="podman --storage-driver=vfs"
docker="podman"
readonly docker
$docker image load -i "$script_dir/vtk-wasm-sdk-emscripten.tar"
......
......@@ -16,7 +16,7 @@ else
fi
# Use podman to avoid having to do docker-in-docker shenanigans.
docker="podman --storage-driver=vfs"
docker="podman"
readonly docker
$docker image load -i "$script_dir/vtk-wasm-sdk-emscripten.tar"
......
......@@ -26,29 +26,13 @@ execute_process(
WORKING_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}")
if (${CMAKE_SIZEOF_VOID_P} EQUAL 8)
# Ensure that we can allocate upto ~16GB in wasm64 builds
add_test(
NAME "basic-wasm64-test"
COMMAND "${CMAKE_CURRENT_LIST_DIR}/node/bin/node" "--experimental-wasm-memory64" "$<TARGET_FILE:main>" "1431368000" "1")
# Ensure that we cannot allocate more than ~16GB in wasm64 builds
add_test(
NAME "basic-wasm64-expect-oom-test"
COMMAND "${CMAKE_CURRENT_LIST_DIR}/node/bin/node" "--experimental-wasm-memory64" "$<TARGET_FILE:main>" "2000000000" "1")
set_tests_properties("basic-wasm64-expect-oom-test"
PROPERTIES
WILL_FAIL TRUE)
COMMAND "${CMAKE_CURRENT_LIST_DIR}/node/bin/node" "--experimental-wasm-memory64" "$<TARGET_FILE:main>" "64" "0")
else ()
# Ensure that we can allocate upto ~2GB in wasm32 builds
add_test(
NAME "basic-wasm32-test"
COMMAND "${CMAKE_CURRENT_LIST_DIR}/node/bin/node" "$<TARGET_FILE:main>" "178921000" "1")
# Ensure that we cannot allocate more than ~2GB in wasm32 builds
add_test(
NAME "basic-wasm32-expect-oom-test"
COMMAND "${CMAKE_CURRENT_LIST_DIR}/node/bin/node" "$<TARGET_FILE:main>" "180000000" "1")
set_tests_properties("basic-wasm32-expect-oom-test"
PROPERTIES
WILL_FAIL TRUE)
COMMAND "${CMAKE_CURRENT_LIST_DIR}/node/bin/node" "$<TARGET_FILE:main>" "32" "0")
endif ()
if (ENABLE_THREADS)
......@@ -56,10 +40,10 @@ if (ENABLE_THREADS)
if (${CMAKE_SIZEOF_VOID_P} EQUAL 8)
add_test(
NAME "basic-wasm64-threads"
COMMAND "${CMAKE_CURRENT_LIST_DIR}/node/bin/node" "--experimental-wasm-memory64" "$<TARGET_FILE:main>" "1000" "${num_threads}")
COMMAND "${CMAKE_CURRENT_LIST_DIR}/node/bin/node" "--experimental-wasm-memory64" "$<TARGET_FILE:main>" "64" "${num_threads}")
else ()
add_test(
NAME "basic-wasm32-threads"
COMMAND "${CMAKE_CURRENT_LIST_DIR}/node/bin/node" "$<TARGET_FILE:main>" "1000" "${num_threads}")
COMMAND "${CMAKE_CURRENT_LIST_DIR}/node/bin/node" "$<TARGET_FILE:main>" "32" "${num_threads}")
endif ()
endif ()
// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill
// Lorensen SPDX-License-Identifier: BSD-3-Clause
/**
* Simple C++ program which exercises basic memory allocation and threads in
* VTK. This code is imported from
* VTK/Common/DataModel/Testing/Cxx/TestSMPFeatures.cxx
* Simple C++ program which exercises basic pointer size, creating and joining
* threads.
*/
#include "vtkFloatArray.h"
#include "vtkMath.h"
#include "vtkNew.h"
#include "vtkPoints.h"
#include "vtkSMPTools.h"
#include <array>
#include <cstdlib>
#include <iostream>
#include <thread>
#include <vector>
namespace {
// Compute bounds of a set of points.
using BoundsArray = std::array<double, 6>;
using TLS = vtkSMPThreadLocal<BoundsArray>;
struct BoundsFunctor {
vtkFloatArray *Pts;
BoundsArray Bounds;
TLS LocalBounds;
BoundsFunctor(vtkFloatArray *pts) : Pts(pts) {}
// Initialize thread local storage
void Initialize() {
// The first call to .Local() will create the array,
// all others will return the same.
std::array<double, 6> &bds = this->LocalBounds.Local();
bds[0] = VTK_DOUBLE_MAX;
bds[1] = -VTK_DOUBLE_MAX;
bds[2] = VTK_DOUBLE_MAX;
bds[3] = -VTK_DOUBLE_MAX;
bds[4] = VTK_DOUBLE_MAX;
bds[5] = -VTK_DOUBLE_MAX;
}
// Process the range of points [begin,end)
void operator()(vtkIdType begin, vtkIdType end) {
BoundsArray &lbounds = this->LocalBounds.Local();
float *x = this->Pts->GetPointer(3 * begin);
for (vtkIdType i = begin; i < end; i++) {
lbounds[0] = (x[0] < lbounds[0] ? x[0] : lbounds[0]);
lbounds[1] = (x[0] > lbounds[1] ? x[0] : lbounds[1]);
lbounds[2] = (x[1] < lbounds[2] ? x[1] : lbounds[2]);
lbounds[3] = (x[1] > lbounds[3] ? x[1] : lbounds[3]);
lbounds[4] = (x[2] < lbounds[4] ? x[2] : lbounds[4]);
lbounds[5] = (x[2] > lbounds[5] ? x[2] : lbounds[5]);
x += 3;
}
}
// Composite / combine the thread local storage into a global result.
void Reduce() {
this->Bounds[0] = VTK_DOUBLE_MAX;
this->Bounds[1] = -VTK_DOUBLE_MAX;
this->Bounds[2] = VTK_DOUBLE_MAX;
this->Bounds[3] = -VTK_DOUBLE_MAX;
this->Bounds[4] = VTK_DOUBLE_MAX;
this->Bounds[5] = -VTK_DOUBLE_MAX;
#include <vtkSmartPointer.h>
#include <vtkTypeUInt32Array.h>
using TLSIter = TLS::iterator;
TLSIter end = this->LocalBounds.end();
for (TLSIter itr = this->LocalBounds.begin(); itr != end; ++itr) {
BoundsArray &lBounds = *itr;
this->Bounds[0] =
(this->Bounds[0] < lBounds[0] ? this->Bounds[0] : lBounds[0]);
this->Bounds[1] =
(this->Bounds[1] > lBounds[1] ? this->Bounds[1] : lBounds[1]);
this->Bounds[2] =
(this->Bounds[2] < lBounds[2] ? this->Bounds[2] : lBounds[2]);
this->Bounds[3] =
(this->Bounds[3] > lBounds[3] ? this->Bounds[3] : lBounds[3]);
this->Bounds[4] =
(this->Bounds[4] < lBounds[4] ? this->Bounds[4] : lBounds[4]);
this->Bounds[5] =
(this->Bounds[5] > lBounds[5] ? this->Bounds[5] : lBounds[5]);
}
}
}; // BoundsFunctor
} // namespace
auto main(int argc, char *argv[]) -> int {
if (argc < 3) {
std::cerr << "Usage: " << argv[0]
<< " <number of points> <number of threads>\n";
std::cerr << "Usage: " << argv[0] << " <wordsize> <number of threads>\n";
return 1;
}
// Test pointer size matches 32/64
std::size_t wordsize = std::atoi(argv[1]);
bool wordSizeTestPassed = false;
if (wordsize == 32) {
if (sizeof(void *) != 4) {
std::cerr << "Test failed for word size=32\n";
return EXIT_FAILURE;
}
} else if (wordsize == 64) {
if (sizeof(void *) != 8) {
const vtkIdType numPts = std::atoi(argv[1]);
const int numberOfThreads = std::atoi(argv[2]);
vtkSMPTools::SetBackend(numberOfThreads <= 1 ? "SEQUENTIAL" : "STDThread");
vtkSMPTools::Initialize(std::max(1, numberOfThreads));
std::cout << "Program parameters:"
<< "\nnumberOfPoints=" << numPts
<< "\nnumberOfThreads=" << numberOfThreads << "\n";
std::cout << "Allocating " << numPts * 3 * sizeof(float) << "bytes\n";
vtkNew<vtkPoints> pts;
pts->SetDataTypeToFloat();
pts->SetNumberOfPoints(numPts);
std::cout << "Allocated "
<< pts->GetData()->GetSize() * pts->GetData()->GetDataTypeSize()
<< "bytes\n";
for (auto i = 0; i < numPts; ++i) {
pts->SetPoint(i, vtkMath::Random(-1, 1), vtkMath::Random(-1, 1),
vtkMath::Random(-1, 1));
std::cerr << "Test failed for word size=64\n";
return EXIT_FAILURE;
}
} else {
std::cerr << "Word size is unsupported " << wordsize << '\n';
return EXIT_FAILURE;
}
// Compute bounds using Initialize() and Reduce().
vtkFloatArray *ptsArray = vtkFloatArray::SafeDownCast(pts->GetData());
BoundsFunctor calcBounds(ptsArray);
vtkSMPTools::For(0, numPts, calcBounds);
std::array<double, 6> &bds = calcBounds.Bounds;
std::cout << "Bounds: ( " << bds[0] << "," << bds[1] << ", " << bds[2] << ","
<< bds[3] << ", " << bds[4] << "," << bds[5] << ")\n";
std::size_t numThreads = std::atoi(argv[2]);
if (numThreads > 0) {
auto sharedData = vtk::TakeSmartPointer(vtkTypeUInt32Array::New());
sharedData->SetNumberOfValues(numThreads);
std::vector<std::unique_ptr<std::thread>> threads(numThreads);
// write 2 * threadId into sharedData[threadId] from the thread.
for (std::size_t threadId = 0; threadId < numThreads; ++threadId) {
auto &thread = threads[threadId];
thread.reset(new std::thread([threadId, sharedData]() {
sharedData->SetTypedComponent(threadId, 0, 2 * threadId);
}));
}
for (const auto &thread : threads) {
thread->join();
}
// verify sharedData is updated.
for (std::size_t threadId = 0; threadId < numThreads; ++threadId) {
const auto value = sharedData->GetTypedComponent(threadId, 0);
if (value != 2 * threadId) {
std::cerr << "Incorrect value=" << value
<< " != 2 * threadId at threadId=" << threadId << '\n';
return EXIT_FAILURE;
}
}
}
return 0;
return EXIT_SUCCESS;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment