mirror of
https://github.com/apache/lucene.git
synced 2025-02-06 01:58:44 +00:00
Leverage accelerated vector hardware instructions in Vector Search. Lucene already has a mechanism that enables the use of non-final JDK APIs, currently used for the Previewing Pamana Foreign API. This change expands this mechanism to include the Incubating Pamana Vector API. When the jdk.incubator.vector module is present at run time the Panamaized version of the low-level primitives used by Vector Search is enabled. If not present, the default scalar version of these low-level primitives is used (as it was previously). Currently, we're only targeting support for JDK 20. A subsequent PR should evaluate JDK 21. --------- Co-authored-by: Uwe Schindler <uschindler@apache.org> Co-authored-by: Robert Muir <rmuir@apache.org>
76 lines
2.4 KiB
Groovy
76 lines
2.4 KiB
Groovy
/*
|
|
* 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.
|
|
*/
|
|
|
|
def resources = scriptResources(buildscript)
|
|
|
|
configure(rootProject) {
|
|
ext {
|
|
// also change this in extractor tool: ExtractForeignAPI
|
|
vectorIncubatorJavaVersions = [ JavaVersion.VERSION_20 ] as Set
|
|
}
|
|
}
|
|
|
|
configure(project(":lucene:core")) {
|
|
ext {
|
|
apijars = file('src/generated/jdk');
|
|
mrjarJavaVersions = [ 19, 20 ]
|
|
}
|
|
|
|
configurations {
|
|
apiextractor
|
|
}
|
|
|
|
dependencies {
|
|
apiextractor "org.ow2.asm:asm:${scriptDepVersions['asm']}"
|
|
}
|
|
|
|
for (jdkVersion : mrjarJavaVersions) {
|
|
def task = tasks.create(name: "generateJdkApiJar${jdkVersion}", type: JavaExec) {
|
|
description "Regenerate the API-only JAR file with public Panama Foreign & Vector API from JDK ${jdkVersion}"
|
|
group "generation"
|
|
|
|
javaLauncher = javaToolchains.launcherFor {
|
|
languageVersion = JavaLanguageVersion.of(jdkVersion)
|
|
}
|
|
|
|
onlyIf {
|
|
try {
|
|
javaLauncher.get()
|
|
return true
|
|
} catch (Exception e) {
|
|
logger.warn('Launcher for Java {} is not available; skipping regeneration of Panama Foreign & Vector API JAR.', jdkVersion)
|
|
logger.warn('Error: {}', e.cause?.message)
|
|
logger.warn("Please make sure to point env 'JAVA{}_HOME' to exactly JDK version {} or enable Gradle toolchain auto-download.", jdkVersion, jdkVersion)
|
|
return false
|
|
}
|
|
}
|
|
|
|
classpath = configurations.apiextractor
|
|
mainClass = file("${resources}/ExtractJdkApis.java") as String
|
|
systemProperties = [
|
|
'user.timezone': 'UTC'
|
|
]
|
|
args = [
|
|
jdkVersion,
|
|
new File(apijars, "jdk${jdkVersion}.apijar"),
|
|
]
|
|
}
|
|
|
|
regenerate.dependsOn task
|
|
}
|
|
}
|