mikemccand commented on code in PR #13572: URL: https://github.com/apache/lucene/pull/13572#discussion_r1814796588
########## lucene/native/src/c/dotProduct.c: ########## @@ -0,0 +1,209 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include <stdint.h> +#include <stdio.h> +#include <stdlib.h> +#include "dotProduct.h" + +#ifdef __ARM_ACLE +#include <arm_acle.h> +#endif + +#if (defined(__ARM_FEATURE_SVE)) +#include <arm_sve.h> + +/** + - ARM intrinsics guide - https://developer.arm.com/architectures/instruction-sets/intrinsics/#q=svptrue + - SVE Programming examples - https://developer.arm.com/documentation/dai0548/latest/ +*/ +void dump(int8_t vec[], int N) { + printf("["); + for (int i = 0; i < N ; i++) { + printf("%d,",vec[i]); + } + printf("]\n"); +} +/* + * Unrolled and vectorized int8 dotProduct implementation using SVE instructions + * NOTE: Clang 15.0 compiler on Apple M3 Max compiles the code below successfully + * with '-march=native+sve' option but throws "Illegal Hardware Instruction" error + * Looks like Apple M3 does not implement SVE and Apple's official documentation + * is not explicit about this or at least I could not find it. + * + */ +int32_t vdot8s_sve(int8_t vec1[], int8_t vec2[], int32_t limit) { Review Comment: Earlier @rmuir had suggested just relying on `gcc` to compile the "obvious" C code down to efficient vectorized implementation, but here it looks like we are still hand rolling the NEON asm intrinsics? Was the `gcc` path less performant? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org