Merge changes I0527dd5c,Ib8e76b7e

* changes:
  Reorder tests for Float16 vector functions
  Add native_distance for half.
diff --git a/api/rs_vector_math.spec b/api/rs_vector_math.spec
index 9a3e13d..a9f3583 100644
--- a/api/rs_vector_math.spec
+++ b/api/rs_vector_math.spec
@@ -210,6 +210,17 @@
 test: vector
 end:
 
+function: native_distance
+version: 24
+attrib: const
+w: 1, 2, 3, 4
+t: f16
+ret: #2
+arg: #2#1 left_vector
+arg: #2#1 right_vector
+test: none
+end:
+
 function: native_length
 version: 21
 attrib: const
diff --git a/java/tests/RsTest/src/com/android/rs/test/math_fp16.rs b/java/tests/RsTest/src/com/android/rs/test/math_fp16.rs
index 331a871..eef3a8a 100644
--- a/java/tests/RsTest/src/com/android/rs/test/math_fp16.rs
+++ b/java/tests/RsTest/src/com/android/rs/test/math_fp16.rs
@@ -88,6 +88,12 @@
     h1 = fn(h3);            \
     h1 = fn(h4);
 
+#define TEST_H_FUNC_HN_HN(fn) \
+    h1 = fn(h1, h1);          \
+    h1 = fn(h2, h2);          \
+    h1 = fn(h3, h3);          \
+    h1 = fn(h4, h4);
+
 static bool testAPI() {
     TEST_HN_FUNC_HN(acos);
     TEST_HN_FUNC_HN(acosh);
@@ -138,7 +144,6 @@
     TEST_IN_FUNC_HN(ilogb);
     TEST_HN_FUNC_HN_IN(ldexp);
     TEST_HN_FUNC_HN_I(ldexp);
-    TEST_H_FUNC_HN(length);
     TEST_HN_FUNC_HN(lgamma);
     TEST_HN_FUNC_HN_PIN(lgamma);
 
@@ -191,7 +196,6 @@
     TEST_HN_FUNC_HN(native_log1p);
     TEST_HN_FUNC_HN(native_log2);
 
-    TEST_HN_FUNC_HN(native_normalize);
     TEST_HN_FUNC_HN_HN(native_powr);
     TEST_HN_FUNC_HN(native_recip);
     TEST_HN_FUNC_HN_IN(native_rootn);
@@ -207,7 +211,6 @@
     TEST_HN_FUNC_HN(native_tanpi);
 
     TEST_HN_FUNC_HN_HN(nextafter);
-    TEST_HN_FUNC_HN(normalize);
     TEST_HN_FUNC_HN_HN(pow);
     TEST_HN_FUNC_HN_IN(pown);
     TEST_HN_FUNC_HN_HN(powr);
@@ -241,6 +244,14 @@
     // Vector math functions
     h3 = cross(h3, h3);
     h4 = cross(h4, h4);
+
+    TEST_H_FUNC_HN_HN(distance);
+    TEST_H_FUNC_HN_HN(dot);
+    TEST_H_FUNC_HN(length);
+    TEST_H_FUNC_HN_HN(native_distance);
+    TEST_H_FUNC_HN(native_length);
+    TEST_HN_FUNC_HN(native_normalize);
+    TEST_HN_FUNC_HN(normalize);
     return true;
 }
 
diff --git a/scriptc/rs_vector_math.rsh b/scriptc/rs_vector_math.rsh
index d611464..2f5e8e7 100644
--- a/scriptc/rs_vector_math.rsh
+++ b/scriptc/rs_vector_math.rsh
@@ -294,6 +294,26 @@
     native_distance(float4 left_vector, float4 right_vector);
 #endif
 
+#if (defined(RS_VERSION) && (RS_VERSION >= 24))
+extern half __attribute__((const, overloadable))
+    native_distance(half left_vector, half right_vector);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 24))
+extern half __attribute__((const, overloadable))
+    native_distance(half2 left_vector, half2 right_vector);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 24))
+extern half __attribute__((const, overloadable))
+    native_distance(half3 left_vector, half3 right_vector);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 24))
+extern half __attribute__((const, overloadable))
+    native_distance(half4 left_vector, half4 right_vector);
+#endif
+
 /*
  * native_length: Approximate length of a vector
  *