Skip to content

Commit 1aeb480

Browse files
Dan AlbertDanAlbert
authored andcommitted
Update NDK to r28c.
I was planning to leave this on the LTS, but android/ndk#2100 is really annoying now that I've updated CMake.
1 parent 6aa4aae commit 1aeb480

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

build-logic/src/main/java/com/android/ndk/samples/buildlogic/Versions.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ object Versions {
66
const val COMPILE_SDK = 35
77
const val TARGET_SDK = 35
88
const val MIN_SDK = 21
9-
const val NDK = "27.1.12297006" // r27b
9+
const val NDK = "28.2.13676358" // r28c
1010
const val CMAKE = "4.1.0"
1111
val JAVA = JavaVersion.VERSION_1_8
1212
}

vectorization/src/main/cpp/benchmark.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ Vec4 result;
4848
* @return The average duration per call in nanoseconds.
4949
*/
5050
[[nodiscard, clang::noinline]] std::chrono::nanoseconds Benchmark(
51-
Vec4& position, Mat4& translation,
52-
std::function<Vec4(const Vec4&, const Mat4&)> func) {
51+
Vec4<>& position, Mat4<>& translation,
52+
std::function<Vec4<>(const Vec4<>&, const Mat4<>&)> func) {
5353
// TODO: Move to a unit test.
5454
auto test = func(position, translation);
5555
auto expected = Vec4{{20, 10, 10, 1}};
@@ -82,11 +82,11 @@ BenchmarkMatrixMultiplication(Backend backend) {
8282
switch (backend) {
8383
case Backend::kAutoVectorization:
8484
LOG(INFO) << "Benchmarking auto-vectorization";
85-
return Benchmark(position, translation, [](Vec4 p, Mat4 t) {
85+
return Benchmark(position, translation, [](Vec4<> p, Mat4<> t) {
8686
return MultiplyWithAutoVectorization(t, p);
8787
});
8888
case Backend::kCxxSimd:
89-
#if __NDK_MAJOR__ >= 28
89+
#if __NDK_MAJOR__ >= 29
9090
#error check if std::simd works yet
9191
#endif
9292
// The libc++ in NDK r27 has only a skeleton implementation of std::simd.
@@ -96,19 +96,20 @@ BenchmarkMatrixMultiplication(Backend backend) {
9696
return std::unexpected{BenchmarkError::kNotImplemented};
9797
case Backend::kClangVector:
9898
LOG(INFO) << "Benchmarking Clang vectors";
99-
return Benchmark(position, translation, [](Vec4 p, Mat4 t) {
99+
return Benchmark(position, translation, [](Vec4<> p, Mat4<> t) {
100100
return MultiplyWithClangVectors(t, p);
101101
});
102102
case Backend::kClangMatrix:
103103
LOG(INFO) << "Benchmarking Clang matrices";
104-
return Benchmark(position, translation, [](Vec4 p, Mat4 t) {
104+
return Benchmark(position, translation, [](Vec4<> p, Mat4<> t) {
105105
// This is the default implementation since it's the fastest.
106106
return t * p;
107107
});
108108
case Backend::kOpenMp:
109109
LOG(INFO) << "Benchmarking OpenMP SIMD";
110-
return Benchmark(position, translation,
111-
[](Vec4 p, Mat4 t) { return MultiplyWithOpenMP(t, p); });
110+
return Benchmark(position, translation, [](Vec4<> p, Mat4<> t) {
111+
return MultiplyWithOpenMP(t, p);
112+
});
112113
default:
113114
return std::unexpected{BenchmarkError::kUnknownBackend};
114115
}

vectorization/src/main/cpp/matrix.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,10 @@ class Matrix {
140140
template <size_t Rows, size_t Columns, typename T>
141141
Matrix(T (&&)[Rows][Columns]) -> Matrix<Rows, Columns, T>;
142142

143-
#if __NDK_MAJOR__ >= 28
144-
#error "TODO: `template <typename T = float>` each of these"
145-
#endif
146-
using Mat4 = Matrix<4, 4>;
147-
using Vec4 = Matrix<4, 1>;
143+
template <typename T = float>
144+
using Mat4 = Matrix<4, 4, T>;
145+
146+
template <typename T = float>
147+
using Vec4 = Matrix<4, 1, T>;
148148

149149
} // namespace samples::vectorization

0 commit comments

Comments
 (0)