Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use zig build only #271

Open
wants to merge 67 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
ba01116
naive impl
jackalcooper Feb 15, 2024
d5e74a2
Fix OpaquePtr making
jackalcooper Feb 15, 2024
1fb01a7
refactor capi
jackalcooper Feb 15, 2024
151bad6
extract functions
jackalcooper Feb 15, 2024
b6fc434
simplify switch case
jackalcooper Feb 16, 2024
b954df1
optimize the kind lookup
jackalcooper Feb 16, 2024
427f8e6
inline to reduce binary size
jackalcooper Feb 16, 2024
22849d7
minor DRY
jackalcooper Feb 16, 2024
037f5e1
Update kinda_library.zig
jackalcooper Feb 16, 2024
da5a4da
Update kinda_library.zig
jackalcooper Feb 16, 2024
28cf55b
further simplification
jackalcooper Feb 16, 2024
de9eddc
Update kinda_library.zig
jackalcooper Feb 16, 2024
2292e37
reduce binary size
jackalcooper Feb 16, 2024
f41a1cb
Update kinda_library.zig
jackalcooper Feb 16, 2024
4ccb63f
simplify
jackalcooper Feb 16, 2024
acf275a
Update kinda_library.zig
jackalcooper Feb 16, 2024
9125f7b
reduce size of struct
jackalcooper Feb 16, 2024
fd99d8f
move FTI to param
jackalcooper Feb 16, 2024
8fe49c8
Update kinda_library.zig
jackalcooper Feb 16, 2024
dbf5340
Update kinda_library.zig
jackalcooper Feb 16, 2024
27cb63b
Update kinda_library.zig
jackalcooper Feb 16, 2024
c78d5ee
Update kinda_library.zig
jackalcooper Feb 16, 2024
e380232
Remove library struct to reduce Zig-produced binary size (#269)
jackalcooper Feb 17, 2024
c7fb361
Refactor kinda ret (#270)
jackalcooper Feb 17, 2024
3807f1a
rm Struct_MlirAffineMap
jackalcooper Feb 17, 2024
4d34f51
use c.MlirSparseTensorLevelType
jackalcooper Feb 17, 2024
4be857e
Simplify
jackalcooper Feb 17, 2024
4db3f4c
unify naming
jackalcooper Feb 17, 2024
a34a3b7
move kinds to ex
jackalcooper Feb 17, 2024
98769e2
Update Makefile
jackalcooper Feb 17, 2024
60b4de4
generate capi_functions.exs
jackalcooper Feb 18, 2024
284f044
remove kind code gen
jackalcooper Feb 18, 2024
ecd387b
remove file from git
jackalcooper Feb 18, 2024
ecb6284
add ignore
jackalcooper Feb 18, 2024
d990392
fix warning
jackalcooper Feb 18, 2024
666fac0
minore refactor updater
jackalcooper Feb 18, 2024
c112166
add make_precompiler
jackalcooper Feb 18, 2024
0b66448
update kinda version
jackalcooper Feb 18, 2024
ade0be0
use new func from kinda
jackalcooper Feb 18, 2024
0f31ecd
update lock
jackalcooper Feb 18, 2024
da91992
fix
jackalcooper Feb 18, 2024
66b3146
fix
jackalcooper Feb 18, 2024
7878699
fix
jackalcooper Feb 18, 2024
1e34fed
update for elixir.cmake std
jackalcooper Feb 19, 2024
f133c11
update path
jackalcooper Feb 19, 2024
dcc2b22
replace cmake_build with zig build
jackalcooper Feb 19, 2024
8491f8a
simplify
jackalcooper Feb 19, 2024
ad2da64
add make -j
jackalcooper Feb 19, 2024
24707d7
Update Makefile
jackalcooper Feb 19, 2024
d34eac8
Update Makefile
jackalcooper Feb 19, 2024
2b8c4fb
fix for linux
jackalcooper Feb 19, 2024
3133bec
Update build.zig
jackalcooper Feb 19, 2024
aa8859c
use MIX_ENV
jackalcooper Feb 19, 2024
ab9b89f
upload file
jackalcooper Feb 19, 2024
e934666
use -std=gnu++17
jackalcooper Feb 19, 2024
ec19738
also generate flags
jackalcooper Feb 19, 2024
a502022
rm dbg
jackalcooper Feb 19, 2024
ce7c66d
simplify
jackalcooper Feb 19, 2024
7ca50b2
fix for linux
jackalcooper Feb 19, 2024
5bfeb74
refine
jackalcooper Feb 19, 2024
79acf5a
fix warning
jackalcooper Feb 19, 2024
38b8e91
-D_GLIBCXX_USE_CXX11_ABI=0
jackalcooper Feb 19, 2024
d9505bc
two libs
jackalcooper Feb 20, 2024
b1ca6b0
Revert "two libs"
jackalcooper Feb 20, 2024
3b5cf66
Update Beaver.cpp
jackalcooper Feb 20, 2024
720e810
Update Beaver.cpp
jackalcooper Feb 20, 2024
6d930f1
fix warnings
jackalcooper Feb 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
unify naming
jackalcooper committed Feb 17, 2024
commit 4db3f4ce751256611fb8b30f9c630bab596d4e31
10 changes: 5 additions & 5 deletions native/mlir-zig-proj/src/main.zig
Original file line number Diff line number Diff line change
@@ -254,7 +254,7 @@ const BeaverPass = struct {
print("fail to make res: {}\n", .{@TypeOf(op)});
unreachable;
};
tuple_slice[2] = beam.make_resource(env, pass, mlir_capi.MlirExternalPass.resource.t) catch {
tuple_slice[2] = beam.make_resource(env, pass, mlir_capi.ExternalPass.resource.t) catch {
print("fail to make res: {}\n", .{@TypeOf(pass)});
unreachable;
};
@@ -498,12 +498,12 @@ export fn beaver_raw_context_attach_diagnostic_handler(env: beam.env, _: c_int,
userData.?.handler = h;
}
const id = c.mlirContextAttachDiagnosticHandler(arg0, BeaverDiagnostic.errorHandler, userData, BeaverDiagnostic.deleteUserData);
return mlir_capi.MlirDiagnosticHandlerID.resource.make(env, id) catch return beam.make_error_binary(env, "when calling C function mlirContextAttachDiagnosticHandler, fail to make resource for: " ++ @typeName(mlir_capi.MlirDiagnosticHandlerID.T));
return mlir_capi.DiagnosticHandlerID.resource.make(env, id) catch return beam.make_error_binary(env, "when calling C function mlirContextAttachDiagnosticHandler, fail to make resource for: " ++ @typeName(mlir_capi.DiagnosticHandlerID.T));
}

fn beaver_raw_parse_pass_pipeline(env: beam.env, _: c_int, args: [*c]const beam.term) callconv(.C) beam.term {
var passManager: mlir_capi.MlirOpPassManager.T = mlir_capi.MlirOpPassManager.resource.fetch(env, args[0]) catch
return beam.make_error_binary(env, "when calling C function mlirParsePassPipeline, fail to fetch resource for passManager, expected: " ++ @typeName(mlir_capi.MlirOpPassManager.T));
var passManager: mlir_capi.OpPassManager.T = mlir_capi.OpPassManager.resource.fetch(env, args[0]) catch
return beam.make_error_binary(env, "when calling C function mlirParsePassPipeline, fail to fetch resource for passManager, expected: " ++ @typeName(mlir_capi.OpPassManager.T));
var pipeline: mlir_capi.StringRef.T = mlir_capi.StringRef.resource.fetch(env, args[1]) catch
return beam.make_error_binary(env, "when calling C function mlirParsePassPipeline, fail to fetch resource for pipeline, expected: " ++ @typeName(mlir_capi.StringRef.T));
return mlir_capi.LogicalResult.resource.make(env, c.mlirOpPassManagerAddPipeline(passManager, pipeline, BeaverDiagnostic.printDiagnostic, null)) catch return beam.make_error_binary(env, "when calling C function mlirParsePassPipeline, fail to make resource for: " ++ @typeName(mlir_capi.LogicalResult.T));
@@ -748,7 +748,7 @@ const handwritten_nifs = @import("wrapper.zig").nif_entries ++ mlir_capi.Entries
e.ErlNifFunc{ .name = "beaver_raw_beaver_type_print", .arity = 1, .fptr = Printer(mlir_capi.Type, c.mlirTypePrint).print, .flags = 0 },
e.ErlNifFunc{ .name = "beaver_raw_beaver_operation_print", .arity = 1, .fptr = Printer(mlir_capi.Operation, c.mlirOperationPrint).print, .flags = 0 },
e.ErlNifFunc{ .name = "beaver_raw_beaver_value_print", .arity = 1, .fptr = Printer(mlir_capi.Value, c.mlirValuePrint).print, .flags = 0 },
e.ErlNifFunc{ .name = "beaver_raw_beaver_pm_print", .arity = 1, .fptr = Printer(mlir_capi.MlirOpPassManager, c.mlirPrintPassPipeline).print, .flags = 0 },
e.ErlNifFunc{ .name = "beaver_raw_beaver_pm_print", .arity = 1, .fptr = Printer(mlir_capi.OpPassManager, c.mlirPrintPassPipeline).print, .flags = 0 },
e.ErlNifFunc{ .name = "beaver_raw_beaver_affine_map_print", .arity = 1, .fptr = Printer(mlir_capi.AffineMap, c.mlirAffineMapPrint).print, .flags = 0 },
e.ErlNifFunc{ .name = "beaver_raw_beaver_location_print", .arity = 1, .fptr = Printer(mlir_capi.Location, c.beaverLocationPrint).print, .flags = 0 },
e.ErlNifFunc{ .name = "beaver_raw_get_resource_c_string", .arity = 1, .fptr = beaver_raw_get_resource_c_string, .flags = 0 },
112 changes: 56 additions & 56 deletions native/mlir-zig-proj/src/mlir_capi.zig
Original file line number Diff line number Diff line change
@@ -60,34 +60,34 @@ fn MLIRCAPIKind(comptime n: []const u8) type {
return kinda.ResourceKind(@field(c, n), root_module ++ "." ++ n);
}

pub const MlirShapedTypeComponentsCallback = MLIRCAPIKind("MlirShapedTypeComponentsCallback");
pub const MlirTypeID = MLIRCAPIKind("MlirTypeID");
pub const MlirTypesCallback = MLIRCAPIKind("MlirTypesCallback");
pub const MlirIntegerSet = MLIRCAPIKind("MlirIntegerSet");
pub const MlirAffineExpr = MLIRCAPIKind("MlirAffineExpr");
pub const MlirStringCallback = MLIRCAPIKind("MlirStringCallback");
pub const MlirDialectHandle = MLIRCAPIKind("MlirDialectHandle");
pub const MlirDialectRegistry = MLIRCAPIKind("MlirDialectRegistry");
pub const MlirDiagnosticHandlerID = MLIRCAPIKind("MlirDiagnosticHandlerID");
pub const MlirDiagnosticHandler = MLIRCAPIKind("MlirDiagnosticHandler");
pub const MlirDiagnostic = MLIRCAPIKind("MlirDiagnostic");
pub const MlirDiagnosticSeverity = MLIRCAPIKind("MlirDiagnosticSeverity");
pub const MlirPassManager = MLIRCAPIKind("MlirPassManager");
pub const MlirRewritePatternSet = MLIRCAPIKind("MlirRewritePatternSet");
pub const MlirExecutionEngine = MLIRCAPIKind("MlirExecutionEngine");
pub const MlirOperationState = MLIRCAPIKind("MlirOperationState");
pub const MlirSymbolTable = MLIRCAPIKind("MlirSymbolTable");
pub const MlirRegisteredOperationName = MLIRCAPIKind("MlirRegisteredOperationName");
pub const MlirExternalPass = MLIRCAPIKind("MlirExternalPass");
pub const MlirExternalPassCallbacks = MLIRCAPIKind("MlirExternalPassCallbacks");
pub const MlirOpPassManager = MLIRCAPIKind("MlirOpPassManager");
pub const MlirAsmState = MLIRCAPIKind("MlirAsmState");
pub const MlirOperationWalkCallback = MLIRCAPIKind("MlirOperationWalkCallback");
pub const MlirWalkOrder = MLIRCAPIKind("MlirWalkOrder");
pub const MlirBytecodeWriterConfig = MLIRCAPIKind("MlirBytecodeWriterConfig");
pub const MlirOpPrintingFlags = MLIRCAPIKind("MlirOpPrintingFlags");
pub const MlirLlvmThreadPool = MLIRCAPIKind("MlirLlvmThreadPool");
pub const MlirTypeIDAllocator = MLIRCAPIKind("MlirTypeIDAllocator");
pub const ShapedTypeComponentsCallback = MLIRCAPIKind("MlirShapedTypeComponentsCallback");
pub const TypeID = MLIRCAPIKind("MlirTypeID");
pub const TypesCallback = MLIRCAPIKind("MlirTypesCallback");
pub const IntegerSet = MLIRCAPIKind("MlirIntegerSet");
pub const AffineExpr = MLIRCAPIKind("MlirAffineExpr");
pub const StringCallback = MLIRCAPIKind("MlirStringCallback");
pub const DialectHandle = MLIRCAPIKind("MlirDialectHandle");
pub const DialectRegistry = MLIRCAPIKind("MlirDialectRegistry");
pub const DiagnosticHandlerID = MLIRCAPIKind("MlirDiagnosticHandlerID");
pub const DiagnosticHandler = MLIRCAPIKind("MlirDiagnosticHandler");
pub const Diagnostic = MLIRCAPIKind("MlirDiagnostic");
pub const DiagnosticSeverity = MLIRCAPIKind("MlirDiagnosticSeverity");
pub const PassManager = MLIRCAPIKind("MlirPassManager");
pub const RewritePatternSet = MLIRCAPIKind("MlirRewritePatternSet");
pub const ExecutionEngine = MLIRCAPIKind("MlirExecutionEngine");
pub const OperationState = MLIRCAPIKind("MlirOperationState");
pub const SymbolTable = MLIRCAPIKind("MlirSymbolTable");
pub const RegisteredOperationName = MLIRCAPIKind("MlirRegisteredOperationName");
pub const ExternalPass = MLIRCAPIKind("MlirExternalPass");
pub const ExternalPassCallbacks = MLIRCAPIKind("MlirExternalPassCallbacks");
pub const OpPassManager = MLIRCAPIKind("MlirOpPassManager");
pub const AsmState = MLIRCAPIKind("MlirAsmState");
pub const OperationWalkCallback = MLIRCAPIKind("MlirOperationWalkCallback");
pub const WalkOrder = MLIRCAPIKind("MlirWalkOrder");
pub const BytecodeWriterConfig = MLIRCAPIKind("MlirBytecodeWriterConfig");
pub const OpPrintingFlags = MLIRCAPIKind("MlirOpPrintingFlags");
pub const LlvmThreadPool = MLIRCAPIKind("MlirLlvmThreadPool");
pub const TypeIDAllocator = MLIRCAPIKind("MlirTypeIDAllocator");

pub const allKinds = .{
Pass,
@@ -98,15 +98,15 @@ pub const allKinds = .{
ISize,
Attribute,
OpaquePtr,
MlirShapedTypeComponentsCallback,
MlirTypeID,
MlirTypesCallback,
ShapedTypeComponentsCallback,
TypeID,
TypesCallback,
Bool,
Operation,
MlirIntegerSet,
MlirAffineExpr,
MlirStringCallback,
MlirDialectHandle,
IntegerSet,
AffineExpr,
StringCallback,
DialectHandle,
CInt,
AffineMap,
Enum_MlirSparseTensorLevelType,
@@ -115,12 +115,12 @@ pub const allKinds = .{
I32,
I64,
CUInt,
MlirDialectRegistry,
MlirDiagnosticHandlerID,
MlirDiagnosticHandler,
DialectRegistry,
DiagnosticHandlerID,
DiagnosticHandler,
DiagnosticHandlerDeleteUserData,
MlirDiagnostic,
MlirDiagnosticSeverity,
Diagnostic,
DiagnosticSeverity,
F32,
U64,
U32,
@@ -132,34 +132,34 @@ pub const allKinds = .{
UnmanagedDenseResourceElementsAttrGetDeleteCallback,
OpaqueArray,
NamedAttribute,
MlirPassManager,
MlirRewritePatternSet,
PassManager,
RewritePatternSet,
Region,
Module,
MlirExecutionEngine,
ExecutionEngine,
GenericCallback,
ExternalPassConstruct,
ExternalPassRun,
Identifier,
MlirOperationState,
MlirSymbolTable,
OperationState,
SymbolTable,
Value,
Block,
Dialect,
MlirRegisteredOperationName,
MlirExternalPass,
MlirExternalPassCallbacks,
MlirOpPassManager,
RegisteredOperationName,
ExternalPass,
ExternalPassCallbacks,
OpPassManager,
AffineMapCompressUnusedSymbolsPopulateResult,
SymbolTableWalkSymbolTablesCallback,
OpOperand,
MlirAsmState,
MlirOperationWalkCallback,
MlirWalkOrder,
MlirBytecodeWriterConfig,
MlirOpPrintingFlags,
MlirLlvmThreadPool,
MlirTypeIDAllocator,
AsmState,
OperationWalkCallback,
WalkOrder,
BytecodeWriterConfig,
OpPrintingFlags,
LlvmThreadPool,
TypeIDAllocator,
};
pub fn open_generated_resource_types(env: beam.env) void {
inline for (allKinds) |k| {