Skip to content

Commit

Permalink
Add support for Darwin 32-bit and PPC (kokkos#5916)
Browse files Browse the repository at this point in the history
* Do not use 64-bit static_asserts on 32-bit build

* TestScan: case for 32-bit

* Disable team scratch failing test on 32-bit, for now

* CMakeLists: status message instead of a fatal error for 32-bit build

* Kokkos_ClockTic: add implementation for ppc

* Use KOKKOS_IMPL_32BIT instead of KOKKOS_32_BIT

* Add 32bit build to GitHub CI

* Limit ScatterView test to 1GB

* Fix signed compariosn in TestVector.hpp

* Indentation

* Signed compare

* Disable std::complex<long double> test

* Disable repeated_team_reduce and deep_copy_conversion

* Update test restriction

Co-authored-by: Damien L-G <dalg24+github@gmail.com>

* Update core/unit_test/TestTeamBasic.hpp

* Add assert for sizeof(void*)

* Try using integer comparison

* Add reference for clock_tic_host implementation

* Make FIXME_32BIT more uniform

* Print platform information

* Fix Kokkos_Core_fwd.hpp

* Separate 32bit CI into its own workflow

* Add new workflow file

* Minimize workflow file

* Try LIBDL=ON

* Remove ccache commands and LIBDL

---------

Co-authored-by: Daniel Arndt <arndtd@ornl.gov>
Co-authored-by: Damien L-G <dalg24+github@gmail.com>
  • Loading branch information
3 people committed May 2, 2023
1 parent 56ef02c commit e5490e1
Show file tree
Hide file tree
Showing 14 changed files with 100 additions and 10 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/continuous-integration-workflow-32bit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: github-Linux-32bit
on: [push, pull_request]

concurrency:
group: ${ {github.event_name }}-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{github.event_name == 'pull_request'}}

jobs:
CI-32bit:
name: Linux-32bit
runs-on: ubuntu-latest
container:
image: ghcr.io/kokkos/ci-containers/ubuntu:latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: install_multilib
run: sudo apt-get update && sudo apt-get install -y gcc-multilib g++-multilib gfortran-multilib
- name: Configure Kokkos
run: |
cmake -B builddir \
-DKokkos_ENABLE_OPENMP=ON \
-DKokkos_ENABLE_TESTS=ON \
-DKokkos_ENABLE_BENCHMARKS=ON \
-DKokkos_ENABLE_EXAMPLES=ON \
-DKokkos_ENABLE_DEPRECATED_CODE_4=ON \
-DKokkos_ENABLE_DEPRECATION_WARNINGS=OFF \
-DKokkos_ENABLE_COMPILER_WARNINGS=ON \
-DCMAKE_CXX_FLAGS="-Werror -m32 -DKOKKOS_IMPL_32BIT" \
-DCMAKE_CXX_COMPILER=g++ \
-DCMAKE_BUILD_TYPE=RelWithDebInfo
- name: Build
run: |
cmake --build builddir --parallel 2
- name: Tests
working-directory: builddir
run: ctest --output-on-failure
7 changes: 6 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,12 @@ IF (NOT CMAKE_SIZEOF_VOID_P)
MESSAGE(FATAL_ERROR "Kokkos did not configure correctly and failed to validate compiler. The most likely cause is linkage errors during CMake compiler validation. Please consult the CMake error log shown below for the exact error during compiler validation")
ENDIF()
ELSEIF (NOT CMAKE_SIZEOF_VOID_P EQUAL 8)
MESSAGE(FATAL_ERROR "Kokkos assumes a 64-bit build; i.e., 8-byte pointers, but found ${CMAKE_SIZEOF_VOID_P}-byte pointers instead")
IF(CMAKE_SIZEOF_VOID_P EQUAL 4)
MESSAGE(WARNING "32-bit builds are experimental and not officially supported.")
SET(KOKKOS_IMPL_32BIT ON)
ELSE()
MESSAGE(FATAL_ERROR "Kokkos assumes a 64-bit build, i.e., 8-byte pointers, but found ${CMAKE_SIZEOF_VOID_P}-byte pointers instead;")
ENDIF()
ENDIF()


Expand Down
2 changes: 2 additions & 0 deletions cmake/KokkosCore_config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,5 @@
#cmakedefine KOKKOS_ARCH_NAVI
#cmakedefine KOKKOS_ARCH_NAVI1030
#cmakedefine KOKKOS_ARCH_NAVI1100

#cmakedefine KOKKOS_IMPL_32BIT
4 changes: 2 additions & 2 deletions containers/unit_tests/TestScatterView.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -726,9 +726,9 @@ void test_scatter_view(int64_t n) {
}
#endif
// with hundreds of threads we were running out of memory.
// limit (n) so that duplication doesn't exceed 4GB
// limit (n) so that duplication doesn't exceed 1GB
constexpr std::size_t maximum_allowed_total_bytes =
4ull * 1024ull * 1024ull * 1024ull;
1ull * 1024ull * 1024ull * 1024ull;
std::size_t const maximum_allowed_copy_bytes =
maximum_allowed_total_bytes /
std::size_t(execution_space().concurrency());
Expand Down
4 changes: 2 additions & 2 deletions containers/unit_tests/TestVector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ struct test_vector_insert {
it_return = a.insert(it, n + 5, scalar_type(5));

ASSERT_EQ(a.size(), n + 1 + n + 5);
ASSERT_EQ(std::distance(it_return, a.begin() + 17), 0u);
ASSERT_EQ(std::distance(it_return, a.begin() + 17), 0);

Vector b;

Expand All @@ -65,7 +65,7 @@ struct test_vector_insert {
it_return = a.insert(it, b.begin(), b.end());

ASSERT_EQ(a.size(), n + 1 + n + 5 + 7);
ASSERT_EQ(std::distance(it_return, a.begin() + 27 + n), 0u);
ASSERT_EQ(std::distance(it_return, a.begin() + 27 + n), 0);

// Testing insert at end via all three function interfaces
a.insert(a.end(), 11);
Expand Down
10 changes: 7 additions & 3 deletions core/src/Kokkos_Core_fwd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,15 @@
#endif

//----------------------------------------------------------------------------
// Have assumed a 64bit build (8byte pointers) throughout the code base.

// Have assumed a 64-bit build (8-byte pointers) throughout the code base.
// 32-bit build allowed but unsupported.
#ifdef KOKKOS_IMPL_32BIT
static_assert(sizeof(void *) == 4,
"Kokkos assumes 64-bit build; i.e., 4-byte pointers");
#else
static_assert(sizeof(void *) == 8,
"Kokkos assumes 64-bit build; i.e., 8-byte pointers");
#endif
//----------------------------------------------------------------------------
namespace Kokkos {
Expand Down
21 changes: 21 additions & 0 deletions core/src/impl/Kokkos_ClockTic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,27 @@ KOKKOS_IMPL_HOST_FUNCTION inline uint64_t clock_tic_host() noexcept {

return (uint64_t)cycles;

#elif defined(__ppc__)
// see : pages.cs.wisc.edu/~legault/miniproj-736.pdf or
// cmssdt.cern.ch/lxr/source/FWCore/Utilities/interface/HRRealTime.h

uint64_t result = 0;
uint32_t upper, lower, tmp;

__asm__ volatile(
"0: \n"
"\tmftbu %0 \n"
"\tmftb %1 \n"
"\tmftbu %2 \n"
"\tcmpw %2, %0 \n"
"\tbne 0b \n"
: "=r"(upper), "=r"(lower), "=r"(tmp));
result = upper;
result = result << 32;
result = result | lower;

return (result);

#else

return std::chrono::high_resolution_clock::now().time_since_epoch().count();
Expand Down
6 changes: 6 additions & 0 deletions core/src/impl/Kokkos_Core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,12 @@ void pre_initialize_internal(const Kokkos::InitializationSettings& settings) {
#else
declare_configuration_metadata("architecture", "GPU architecture", "none");
#endif

#ifdef KOKKOS_IMPL_32BIT
declare_configuration_metadata("architecture", "platform", "32bit");
#else
declare_configuration_metadata("architecture", "platform", "64bit");
#endif
}

void post_initialize_internal(const Kokkos::InitializationSettings& settings) {
Expand Down
2 changes: 1 addition & 1 deletion core/src/impl/Kokkos_StringManipulation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ KOKKOS_FUNCTION constexpr to_chars_result to_chars_i(char *first, char *last,
unsigned_val = Unsigned(~value) + Unsigned(1);
}
}
unsigned int const len = to_chars_len(unsigned_val);
std::ptrdiff_t const len = to_chars_len(unsigned_val);
if (last - first < len) {
return {last, errc::value_too_large};
}
Expand Down
3 changes: 2 additions & 1 deletion core/src/impl/Kokkos_TaskBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ class TaskBase {
// the number of full task types that fit into a cache line. We'll leave it
// here for now, though, since we're probably going to be ripping all of the
// old TaskBase stuff out eventually anyway.
#ifndef KOKKOS_IMPL_32BIT
constexpr size_t unpadded_task_base_size = 44 + 2 * sizeof(int16_t);
// don't forget padding:
constexpr size_t task_base_misalignment =
Expand All @@ -229,7 +230,7 @@ static constexpr

static_assert(sizeof(TaskBase) == expected_task_base_size,
"Verifying expected sizeof(TaskBase)");

#endif
// </editor-fold> end Verify the size of TaskBase is as expected }}}2
//------------------------------------------------------------------------------

Expand Down
4 changes: 4 additions & 0 deletions core/unit_test/TestComplex.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -519,9 +519,13 @@ TEST(TEST_CATEGORY, complex_operations_arithmetic_types_overloads) {
ASSERT_EQ(Kokkos::conj(1), Kokkos::complex<double>(1));
ASSERT_EQ(Kokkos::conj(2.f), Kokkos::complex<float>(2.f));
ASSERT_EQ(Kokkos::conj(3.), Kokkos::complex<double>(3.));
// long double has size 12 but Kokkos::complex requires 2*sizeof(T) to be a
// power of two.
#ifndef KOKKOS_IMPL_32BIT
ASSERT_EQ(Kokkos::conj(4.l), Kokkos::complex<long double>(4.l));
static_assert((
std::is_same<decltype(Kokkos::conj(1)), Kokkos::complex<double>>::value));
#endif
static_assert((std::is_same<decltype(Kokkos::conj(2.f)),
Kokkos::complex<float>>::value));
static_assert((std::is_same<decltype(Kokkos::conj(3.)),
Expand Down
3 changes: 3 additions & 0 deletions core/unit_test/TestDeepCopyAlignment.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,9 @@ struct TestDeepCopyScalarConversion {
} // namespace Impl

TEST(TEST_CATEGORY, deep_copy_conversion) {
#ifdef KOKKOS_IMPL_32BIT
GTEST_SKIP() << "Failing KOKKOS_IMPL_32BIT"; // FIXME_32BIT
#endif
int64_t N0 = 19381;
int64_t N1 = 17;

Expand Down
3 changes: 3 additions & 0 deletions core/unit_test/TestTeamBasic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ struct LargeTeamScratchFunctor {
};

TEST(TEST_CATEGORY, large_team_scratch_size) {
#ifdef KOKKOS_IMPL_32BIT
GTEST_SKIP() << "Fails on 32-bit"; // FIXME_32BIT
#endif
const int level = 1;
const int n_teams = 1;

Expand Down
4 changes: 4 additions & 0 deletions core/unit_test/TestTeamReductionScan.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ TEST(TEST_CATEGORY, repeated_team_reduce) {
"properly implemented";
#endif

#ifdef KOKKOS_IMPL_32BIT
GTEST_SKIP() << "Failing KOKKOS_IMPL_32BIT"; // FIXME_32BIT
#endif

TestRepeatedTeamReduce<TEST_EXECSPACE>();
}

Expand Down

0 comments on commit e5490e1

Please sign in to comment.