1.5 KiB
1.5 KiB
miclib Zig wrapper
Zig 0.16 wrapper for Intel/CIRCL miclib.h / libmicmgmt.
This repo does not vendor MPSS, miclib.h, scif.h, libmicmgmt, or libscif.
Install/build miclib separately, then point Zig at the include/library directories.
Build
zig build \
-Dmiclib_include=/usr/local/include \
-Dmiclib_libdir=/usr/local/lib
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,
.miclib_include = "/usr/local/include",
.miclib_libdir = "/usr/local/lib",
});
exe.root_module.addImport("miclib", miclib_dep.module("miclib"));
Then in Zig:
const mic = @import("miclib");
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;
}