miclib Zig wrapper

Zig 0.16 wrapper for Intel/CIRCL miclib.h / libmicmgmt.

Build

zig build

The default miclib system library name is micmgmt, which links -lmicmgmt. Override it if your install uses another name:

zig build -Dmiclib_name=micmgmt

miclib.h includes scif.h, so -Dmiclib_include must reference a directory where both headers are visible. The build script links micmgmt, scif, libc, and libc++ because the upstream implementation is C++ with a C ABI.

Use as a dependency

zig fetch --save git+https://git.kbz8.me/kbz_8/miclib-zig.git

Then in your build.zig:

const miclib_dep = b.dependency("miclib", .{
    .target = target,
    .optimize = optimize,
});

exe.root_module.addImport("miclib", miclib_dep.module("miclib"));

Then in Zig:

const mic = @import("miclib");

try mic.load();
defer mic.unload();

var list = try mic.DeviceList.init();
defer list.deinit();

const count = try list.count();
for (0..count) |index| {
    const device_num = try list.deviceAtIndex(index);
    var device = try mic.Device.open(device_num);
    defer device.deinit();

    var memory = try device.memoryInfo();
    defer memory.deinit();

    const mem_mib = try memory.size();
    _ = mem_mib;
}
S
Description
Zig wrapper for miclib.h / libmicmgmt
Readme MIT 74 KiB
Languages
Zig 100%