Adds all the compiler flags to optimize Llama to be more performant. Also makes METAL non conditional
This commit is contained in:
parent
89e89599fd
commit
5faa33de27
1 changed files with 69 additions and 28 deletions
|
@ -2,30 +2,13 @@
|
||||||
|
|
||||||
import PackageDescription
|
import PackageDescription
|
||||||
|
|
||||||
#if arch(arm) || arch(arm64)
|
let package = Package(
|
||||||
let platforms: [SupportedPlatform]? = [
|
name: "llama",
|
||||||
.macOS(.v11),
|
platforms: [.macOS(.v11),
|
||||||
.iOS(.v14),
|
.iOS(.v14),
|
||||||
.watchOS(.v4),
|
.watchOS(.v4),
|
||||||
.tvOS(.v14)
|
.tvOS(.v14)
|
||||||
]
|
],
|
||||||
let exclude: [String] = []
|
|
||||||
let additionalSources: [String] = ["ggml-metal.m"]
|
|
||||||
let additionalSettings: [CSetting] = [
|
|
||||||
.unsafeFlags(["-fno-objc-arc"]),
|
|
||||||
.define("GGML_SWIFT"),
|
|
||||||
.define("GGML_USE_METAL")
|
|
||||||
]
|
|
||||||
#else
|
|
||||||
let platforms: [SupportedPlatform]? = nil
|
|
||||||
let exclude: [String] = ["ggml-metal.metal"]
|
|
||||||
let additionalSources: [String] = []
|
|
||||||
let additionalSettings: [CSetting] = []
|
|
||||||
#endif
|
|
||||||
|
|
||||||
let package = Package(
|
|
||||||
name: "llama",
|
|
||||||
platforms: platforms,
|
|
||||||
products: [
|
products: [
|
||||||
.library(name: "llama", targets: ["llama"]),
|
.library(name: "llama", targets: ["llama"]),
|
||||||
],
|
],
|
||||||
|
@ -33,21 +16,79 @@ let package = Package(
|
||||||
.target(
|
.target(
|
||||||
name: "llama",
|
name: "llama",
|
||||||
path: ".",
|
path: ".",
|
||||||
exclude: exclude,
|
|
||||||
sources: [
|
sources: [
|
||||||
"ggml.c",
|
"ggml.c",
|
||||||
"llama.cpp",
|
"llama.cpp",
|
||||||
"ggml-alloc.c",
|
"ggml-alloc.c",
|
||||||
"k_quants.c",
|
"k_quants.c",
|
||||||
] + additionalSources,
|
"ggml-metal.m"
|
||||||
|
],
|
||||||
publicHeadersPath: "spm-headers",
|
publicHeadersPath: "spm-headers",
|
||||||
cSettings: [
|
cSettings: [
|
||||||
.unsafeFlags(["-Wno-shorten-64-to-32"]),
|
.unsafeFlags(["-Wno-shorten-64-to-32",
|
||||||
|
"-Wall",
|
||||||
|
"-Wextra",
|
||||||
|
"-Wpedantic",
|
||||||
|
"-Wshadow",
|
||||||
|
"-Wcast-qual",
|
||||||
|
"-Wstrict-prototypes",
|
||||||
|
"-Wpointer-arith",
|
||||||
|
"-Wdouble-promotion",
|
||||||
|
"-Wno-unused-function",
|
||||||
|
"-Wmissing-prototypes",
|
||||||
|
"-Werror=vla",
|
||||||
|
"-mavx",
|
||||||
|
"-mavx2",
|
||||||
|
"-mfma",
|
||||||
|
"-mf16c",
|
||||||
|
"-O3",
|
||||||
|
"-DNDEBUG",
|
||||||
|
"-Wno-format",
|
||||||
|
"-mf16c"]),
|
||||||
.define("GGML_USE_K_QUANTS"),
|
.define("GGML_USE_K_QUANTS"),
|
||||||
.define("GGML_USE_ACCELERATE")
|
.define("GGML_USE_ACCELERATE"),
|
||||||
] + additionalSettings,
|
.define("NDEBUG"),
|
||||||
|
.define("_XOPEN_SOURCE", to: "600"),
|
||||||
|
.define("_DARWIN_C_SOURCE"),
|
||||||
|
.unsafeFlags(["-fno-objc-arc"]),
|
||||||
|
.define("GGML_SWIFT"),
|
||||||
|
.define("GGML_USE_METAL")
|
||||||
|
],
|
||||||
|
cxxSettings: [
|
||||||
|
.unsafeFlags(["-Wno-shorten-64-to-32",
|
||||||
|
"-Wall",
|
||||||
|
"-Wextra",
|
||||||
|
"-Wpedantic",
|
||||||
|
"-Wshadow",
|
||||||
|
"-Wcast-qual",
|
||||||
|
"-Wstrict-prototypes",
|
||||||
|
"-Wpointer-arith",
|
||||||
|
"-Wdouble-promotion",
|
||||||
|
"-Wno-unused-function",
|
||||||
|
"-Wmissing-prototypes",
|
||||||
|
"-Werror=vla",
|
||||||
|
"-mavx",
|
||||||
|
"-mavx2",
|
||||||
|
"-mfma",
|
||||||
|
"-mf16c",
|
||||||
|
"-O3",
|
||||||
|
"-DNDEBUG",
|
||||||
|
"-Wno-format",
|
||||||
|
"-mf16c"]),
|
||||||
|
.define("GGML_USE_K_QUANTS"),
|
||||||
|
.define("GGML_USE_ACCELERATE"),
|
||||||
|
.unsafeFlags(["-fno-objc-arc"]),
|
||||||
|
.define("GGML_SWIFT"),
|
||||||
|
.define("GGML_USE_METAL"),
|
||||||
|
.define("NDEBUG"),
|
||||||
|
.define("_XOPEN_SOURCE", to: "600"),
|
||||||
|
.define("_DARWIN_C_SOURCE")
|
||||||
|
],
|
||||||
linkerSettings: [
|
linkerSettings: [
|
||||||
.linkedFramework("Accelerate")
|
.linkedFramework("Accelerate"),
|
||||||
|
.linkedFramework("Foundation"),
|
||||||
|
.linkedFramework("Metal"),
|
||||||
|
.linkedFramework("MetalKit")
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue