Skip to content

Commit

Permalink
[GLUTEN-6571][VL] Add platform and arch subdirectory for base lib pac…
Browse files Browse the repository at this point in the history
…kage
  • Loading branch information
wForget committed Aug 20, 2024
1 parent 11a236d commit 9d2e717
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 3 deletions.
1 change: 1 addition & 0 deletions backends-velox/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@
<resources>
<resource>
<directory>${cpp.releases.dir}</directory>
<targetPath>org/apache/gluten/${platform}/${arch}</targetPath>
</resource>
<resource>
<directory>${resource.dir}</directory>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ class VeloxListenerApi extends ListenerApi with Logging {
JniLibLoader.loadFromPath(libPath, false)
} else {
val baseLibName = conf.get(GlutenConfig.GLUTEN_LIB_NAME, "gluten")
loader.mapAndLoad(baseLibName, false)
loader.mapAndLoad(VeloxBackend.BACKEND_NAME, false)
loader.mapAndLoad(java.util.Optional.of(baseLibPackage), baseLibName, false)
loader.mapAndLoad(java.util.Optional.of(baseLibPackage), VeloxBackend.BACKEND_NAME, false)
}

// Initial native backend with configurations.
Expand All @@ -130,6 +130,18 @@ class VeloxListenerApi extends ListenerApi with Logging {
GlutenRowSplitter.setInstance(new VeloxRowSplitter())
}

private lazy val baseLibPackage: String = {
val osName = System.getProperty("os.name") match {
case n if n.contains("Linux") => "linux"
case n if n.contains("Mac") => "darwin"
case _ =>
// Default to linux
"linux"
}
val arch = System.getProperty("os.arch")
s"org/apache/gluten/$osName/$arch"
}

private def shutdown(): Unit = {
// TODO shutdown implementation in velox to release resources
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.Vector;

Expand Down Expand Up @@ -159,10 +160,14 @@ public static void unloadFromPath(String libPath) {
}

public void mapAndLoad(String unmappedLibName, boolean requireUnload) {
mapAndLoad(Optional.empty(), unmappedLibName, requireUnload);
}
public void mapAndLoad(Optional<String> packagePath, String unmappedLibName, boolean requireUnload) {
synchronized (loadedLibraries) {
try {
final String mappedLibName = System.mapLibraryName(unmappedLibName);
load(mappedLibName, requireUnload);
String resourceName = packagePath.map(p -> p + "/" + mappedLibName).orElse(mappedLibName);
load(resourceName, requireUnload);
} catch (Exception e) {
throw new GlutenException(e);
}
Expand Down
54 changes: 54 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,60 @@
</plugins>
</build>
</profile>

<!-- Profiles for different platforms -->
<profile>
<id>Darwin-x86</id>
<activation>
<os>
<family>mac</family>
<arch>x86</arch>
</os>
</activation>
<properties>
<platform>darwin</platform>
<arch>x86_64</arch>
</properties>
</profile>
<profile>
<id>Darwin-aarch64</id>
<activation>
<os>
<family>mac</family>
<arch>aarch64</arch>
</os>
</activation>
<properties>
<platform>darwin</platform>
<arch>aarch64</arch>
</properties>
</profile>
<profile>
<id>Linux-amd64</id>
<activation>
<os>
<family>Linux</family>
<arch>amd64</arch>
</os>
</activation>
<properties>
<platform>linux</platform>
<arch>amd64</arch>
</properties>
</profile>
<profile>
<id>Linux-aarch64</id>
<activation>
<os>
<family>Linux</family>
<arch>aarch64</arch>
</os>
</activation>
<properties>
<platform>linux</platform>
<arch>aarch64</arch>
</properties>
</profile>
</profiles>

<dependencyManagement>
Expand Down

0 comments on commit 9d2e717

Please sign in to comment.