Skip to content

Commit 107c4f1

Browse files
Update build.gradle and build.sh to separate x64 linux nmslib build with different gcc versions (#2506)
* Update build gradle to separate nmslib / faiss generation Signed-off-by: Peter Zhu <[email protected]> * Update scripts/build.sh to separate enable gcc switch Signed-off-by: Peter Zhu <[email protected]> * Remove test comments Signed-off-by: Peter Zhu <[email protected]> * Remove test comments Signed-off-by: Peter Zhu <[email protected]> * Remove test comments Signed-off-by: Peter Zhu <[email protected]> * Updating restart and rolling upgrade bwc test bundle.gradle Signed-off-by: Peter Zhu <[email protected]> * Enforce gcc10 for nmslib to compile and avx512_spr have no-op Signed-off-by: Peter Zhu <[email protected]> --------- Signed-off-by: Peter Zhu <[email protected]>
1 parent 8ee82b9 commit 107c4f1

File tree

6 files changed

+30
-2
lines changed

6 files changed

+30
-2
lines changed

.github/workflows/CI.yml

+5
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ jobs:
4040
matrix:
4141
java: [11, 17, 21]
4242

43+
env:
44+
CC: gcc10-gcc
45+
CXX: gcc10-g++
46+
FC: gcc10-gfortran
47+
4348
name: Build and Test k-NN Plugin on Linux
4449
runs-on: ubuntu-latest
4550
needs: Get-CI-Image-Tag

.github/workflows/test_security.yml

+4
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ jobs:
3939
strategy:
4040
matrix:
4141
java: [21]
42+
env:
43+
CC: gcc10-gcc
44+
CXX: gcc10-g++
45+
FC: gcc10-gfortran
4246

4347
name: Run Integration Tests on Linux
4448
runs-on: ubuntu-latest

build.gradle

+10-1
Original file line numberDiff line numberDiff line change
@@ -347,13 +347,20 @@ task cmakeJniLib(type:Exec) {
347347
commandLine args
348348
}
349349

350+
task buildNmslib(type:Exec) {
351+
dependsOn cmakeJniLib
352+
workingDir 'jni'
353+
commandLine 'make', 'opensearchknn_nmslib', '-j', "${nproc_count}"
354+
}
355+
350356
task buildJniLib(type:Exec) {
351357
dependsOn cmakeJniLib
352358
workingDir 'jni'
353-
commandLine 'make', 'opensearchknn_nmslib', 'opensearchknn_faiss', 'opensearchknn_common', '-j', "${nproc_count}"
359+
commandLine 'make', 'opensearchknn_faiss', 'opensearchknn_common', '-j', "${nproc_count}"
354360
}
355361

356362
test {
363+
dependsOn buildNmslib
357364
dependsOn buildJniLib
358365
systemProperty 'tests.security.manager', 'false'
359366
systemProperty "java.library.path", "$rootDir/jni/release"
@@ -368,6 +375,7 @@ test {
368375
def _numNodes = findProperty('numNodes') as Integer ?: 1
369376
integTest {
370377
if (integTestDependOnJniLib) {
378+
dependsOn buildNmslib
371379
dependsOn buildJniLib
372380
}
373381
systemProperty 'tests.security.manager', 'false'
@@ -468,6 +476,7 @@ task integTestRemote(type: RestIntegTestTask) {
468476

469477
run {
470478
useCluster project.testClusters.integTest
479+
dependsOn buildNmslib
471480
dependsOn buildJniLib
472481
doFirst {
473482
// There seems to be an issue when running multi node run or integ tasks with unicast_hosts

qa/restart-upgrade/build.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ testClusters {
134134
// All nodes are upgraded to latest version and run the tests
135135
task testRestartUpgrade(type: StandaloneRestIntegTestTask) {
136136
dependsOn "testAgainstOldCluster"
137+
dependsOn rootProject.tasks.buildNmslib
137138
dependsOn rootProject.tasks.buildJniLib
138139
dependsOn rootProject.tasks.assemble
139140
useCluster testClusters."${baseName}"

qa/rolling-upgrade/build.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ task testAgainstOldCluster(type: StandaloneRestIntegTestTask) {
5252
// This results in a mixed cluster with 2 nodes on the old version and 1 upgraded node.
5353
task testAgainstOneThirdUpgradedCluster(type: StandaloneRestIntegTestTask) {
5454
useCluster testClusters."${baseName}"
55+
dependsOn rootProject.tasks.buildNmslib
5556
dependsOn rootProject.tasks.buildJniLib
5657
dependsOn rootProject.tasks.assemble
5758
dependsOn "testAgainstOldCluster"

scripts/build.sh

+9-1
Original file line numberDiff line numberDiff line change
@@ -131,16 +131,24 @@ cd $work_dir
131131
./gradlew :buildJniLib -Davx512.enabled=false -Davx512_spr.enabled=false -Davx2.enabled=false -Dbuild.lib.commit_patches=false -Dnproc.count=${NPROC_COUNT:-1}
132132

133133
if [ "$PLATFORM" != "windows" ] && [ "$ARCHITECTURE" = "x64" ]; then
134+
echo "Building k-NN library nmslib with gcc 10 on non-windows x64"
135+
rm -rf jni/CMakeCache.txt jni/CMakeFiles
136+
env CC=gcc10-gcc CXX=gcc10-g++ FC=gcc10-gfortran ./gradlew :buildNmslib -Dbuild.lib.commit_patches=false -Dbuild.lib.apply_patches=false
137+
134138
echo "Building k-NN library after enabling AVX2"
135139
# Skip applying patches as patches were applied already from previous :buildJniLib task
136140
# If we apply patches again, it fails with conflict
141+
rm -rf jni/CMakeCache.txt jni/CMakeFiles
137142
./gradlew :buildJniLib -Davx2.enabled=true -Davx512.enabled=false -Davx512_spr.enabled=false -Dbuild.lib.commit_patches=false -Dbuild.lib.apply_patches=false
138143

139144
echo "Building k-NN library after enabling AVX512"
140145
./gradlew :buildJniLib -Davx512.enabled=true -Davx512_spr.enabled=false -Dbuild.lib.commit_patches=false -Dbuild.lib.apply_patches=false
141146

142147
echo "Building k-NN library after enabling AVX512_SPR"
143148
./gradlew :buildJniLib -Davx512_spr.enabled=true -Dbuild.lib.commit_patches=false -Dbuild.lib.apply_patches=false
149+
150+
else
151+
./gradlew :buildNmslib -Dbuild.lib.commit_patches=false -Dbuild.lib.apply_patches=false
144152
fi
145153

146154
./gradlew publishPluginZipPublicationToZipStagingRepository -Dopensearch.version=$VERSION -Dbuild.snapshot=$SNAPSHOT -Dbuild.version_qualifier=$QUALIFIER
@@ -149,7 +157,7 @@ fi
149157
# Add lib to zip
150158
zipPath=$(find "$(pwd)/build/distributions" -path \*.zip)
151159
distributions="$(dirname "${zipPath}")"
152-
mkdir $distributions/lib
160+
mkdir -p $distributions/lib
153161
libPrefix="libopensearchknn"
154162
if [ "$PLATFORM" = "windows" ]; then
155163
libPrefix="opensearchknn"

0 commit comments

Comments
 (0)