]> git.djapps.eu Git - pkg/ggml/sources/ggml/commitdiff
zig : update build.zig (#296)
authorsjinzh <redacted>
Sun, 25 Jun 2023 13:36:09 +0000 (21:36 +0800)
committerGitHub <redacted>
Sun, 25 Jun 2023 13:36:09 +0000 (16:36 +0300)
build.zig

index f32a081d85b6733c60a51de0fc58df829bc4059c..34582cec6159a8851c4867cacbc05af4057300fc 100644 (file)
--- a/build.zig
+++ b/build.zig
@@ -1,6 +1,25 @@
 const std = @import("std");
 
-// Zig Version: 0.11.0-dev.3379+629f0d23b
+// Zig Version: 0.11.0-dev.3798+a5e15eced
+// Zig Build Command: zig build
+// Zig Run Command:    
+//     zig build run_dolly-v2             
+//     zig build run_gpt-2                  
+//     zig build run_gpt-j                   
+//     zig build run_gpt-neox                 
+//     zig build run_mnist                    
+//     zig build run_mpt                     
+//     zig build run_replit                  
+//     zig build run_starcoder                
+//     zig build run_test-grad0               
+//     zig build run_test-mul-mat0            
+//     zig build run_test-mul-mat2            
+//     zig build run_test-opt                 
+//     zig build run_test-vec1                
+//     zig build run_test0                   
+//     zig build run_test1                    
+//     zig build run_test2                    
+//     zig build run_test3                    
 pub fn build(b: *std.build.Builder) void {
     const target = b.standardTargetOptions(.{});
     const optimize = b.standardOptimizeOption(.{});
@@ -9,17 +28,16 @@ pub fn build(b: *std.build.Builder) void {
         .target = target,
         .optimize = optimize,
     });
-    lib.linkLibC();
-    lib.linkLibCpp();
-    lib.addIncludePath(".");
     lib.addIncludePath("./include");
     lib.addIncludePath("./include/ggml");
-    lib.addIncludePath("./examples");
     lib.addCSourceFiles(&.{
         "src/ggml.c",
     }, &.{"-std=c11"});
+    lib.linkLibC();
+    lib.linkLibCpp();
     b.installArtifact(lib);
 
+    // examples
     const examples = .{
         "dolly-v2",
         "gpt-2",
@@ -29,29 +47,67 @@ pub fn build(b: *std.build.Builder) void {
         "mpt",
         "replit",
         "starcoder",
+        // "whisper",
     };
-
-    inline for (examples) |example_name| {
+    inline for (examples) |name| {
         const exe = b.addExecutable(.{
-            .name = example_name,
+            .name = name,
             .target = target,
             .optimize = optimize,
         });
-        exe.addIncludePath(".");
         exe.addIncludePath("./include");
         exe.addIncludePath("./include/ggml");
         exe.addIncludePath("./examples");
+        // exe.addIncludePath("./examples/whisper");
         exe.addCSourceFiles(&.{
-            std.fmt.comptimePrint("examples/{s}/{s}.cpp", .{example_name, "main"}),
+            std.fmt.comptimePrint("examples/{s}/main.cpp", .{name}),
             "examples/common.cpp",
             "examples/common-ggml.cpp",
+            // "examples/whisper/whisper.cpp",
         }, &.{"-std=c++11"});
         exe.linkLibrary(lib);
         b.installArtifact(exe);
         const run_cmd = b.addRunArtifact(exe);
         run_cmd.step.dependOn(b.getInstallStep());
         if (b.args) |args| run_cmd.addArgs(args);
-        const run_step = b.step("run_" ++ example_name, "Run the app");
+        const run_step = b.step("run_" ++ name, "Run examples");
+        run_step.dependOn(&run_cmd.step);
+    }
+
+    // tests
+    const tests = .{
+        // "test-blas0",
+        "test-grad0",
+        "test-mul-mat0",
+        // "test-mul-mat1",
+        "test-mul-mat2",
+        "test-opt",
+        // "test-svd0",
+        // "test-vec0",
+        "test-vec1",
+        // "test-vec2",
+        "test0",
+        "test1",
+        "test2",
+        "test3",
+    };
+    inline for (tests) |name| {
+        const exe = b.addExecutable(.{
+            .name = name,
+            .target = target,
+            .optimize = optimize,
+        });
+        exe.addIncludePath("./include");
+        exe.addIncludePath("./include/ggml");
+        exe.addCSourceFiles(&.{
+            std.fmt.comptimePrint("tests/{s}.c", .{name}),
+        }, &.{"-std=c11"});
+        exe.linkLibrary(lib);
+        b.installArtifact(exe);
+        const run_cmd = b.addRunArtifact(exe);
+        run_cmd.step.dependOn(b.getInstallStep());
+        if (b.args) |args| run_cmd.addArgs(args);
+        const run_step = b.step("run_" ++ name, "Run tests");
         run_step.dependOn(&run_cmd.step);
     }
 }
\ No newline at end of file