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

Gemv #1208

Merged
merged 140 commits into from Jun 15, 2023
Merged

Gemv #1208

merged 140 commits into from Jun 15, 2023

Conversation

ZuseZ4
Copy link
Member

@ZuseZ4 ZuseZ4 commented May 18, 2023

TODO:

unify fwd_call_args and rev_call_args
handle nested rules to cover more branches.

@ZuseZ4 ZuseZ4 force-pushed the gemv branch 2 times, most recently from 6f8b8fb to 97fa4ed Compare May 30, 2023 01:57
@wsmoses
Copy link
Member

wsmoses commented May 30, 2023

@ftynse

enzyme/Enzyme/Utils.cpp Outdated Show resolved Hide resolved
enzyme/Enzyme/Utils.cpp Outdated Show resolved Hide resolved
@ZuseZ4
Copy link
Member Author

ZuseZ4 commented Jun 1, 2023

@wsmoses
cc @vchuravy

define internal fastcc void @preprocess_julia_gemm__1050(i32 zeroext %0, i32 zeroext %1, {} addrspace(10)* noundef nonnull align 16 dereferenceable(40) %2, {} addrspace(10)* noundef nonnull align 16 dereferenceable(40) %3, {} addrspace(10)* noundef nonnull align 16 dereferenceable(40) %4) unnamed_addr #20 !dbg !299 {
top:
  %5 = call noalias nonnull dereferenceable(1) dereferenceable_or_null(1) i8* @malloc(i64 1), !enzyme_fromstack !309
  %6 = call noalias nonnull dereferenceable(1) dereferenceable_or_null(1) i8* @malloc(i64 1), !enzyme_fromstack !309
  %7 = call noalias nonnull dereferenceable(8) dereferenceable_or_null(8) i8* @malloc(i64 8), !enzyme_fromstack !310
  %8 = bitcast i8* %7 to i64*, !enzyme_caststack !15
  %9 = bitcast i64* %8 to i8*
  %10 = call noalias nonnull dereferenceable(8) dereferenceable_or_null(8) i8* @malloc(i64 8), !enzyme_fromstack !310
  %11 = bitcast i8* %10 to i64*, !enzyme_caststack !15
  %12 = bitcast i64* %11 to i8*
  %13 = call noalias nonnull dereferenceable(8) dereferenceable_or_null(8) i8* @malloc(i64 8), !enzyme_fromstack !310
  %14 = bitcast i8* %13 to i64*, !enzyme_caststack !15
  %15 = bitcast i64* %14 to i8*
  %16 = call noalias nonnull dereferenceable(8) dereferenceable_or_null(8) i8* @malloc(i64 8), !enzyme_fromstack !310
  %17 = bitcast i8* %16 to i64*, !enzyme_caststack !15
  %18 = bitcast i64* %17 to i8*
  %19 = call noalias nonnull dereferenceable(8) dereferenceable_or_null(8) i8* @malloc(i64 8), !enzyme_fromstack !310
  %20 = bitcast i8* %19 to i64*, !enzyme_caststack !15
  %21 = bitcast i64* %20 to i8*
  %22 = call noalias nonnull dereferenceable(8) dereferenceable_or_null(8) i8* @malloc(i64 8), !enzyme_fromstack !310
  %23 = bitcast i8* %22 to i64*, !enzyme_caststack !15
  %24 = bitcast i64* %23 to i8*
  %25 = call noalias nonnull dereferenceable(8) dereferenceable_or_null(8) i8* @malloc(i64 8), !enzyme_fromstack !310
  %26 = bitcast i8* %25 to i64*, !enzyme_caststack !15
  %27 = bitcast i64* %26 to i8*
  %28 = call noalias nonnull dereferenceable(8) dereferenceable_or_null(8) i8* @malloc(i64 8), !enzyme_fromstack !310
  %29 = bitcast i8* %28 to i64*, !enzyme_caststack !15
  %30 = bitcast i64* %29 to i8*
  %31 = call {}*** @julia.get_pgcstack() #23
  call void @llvm.dbg.value(metadata {} addrspace(10)* null, metadata !308, metadata !DIExpression(DW_OP_deref)) #23, !dbg !311

errors with:
pp: %_replacementA51 = phi i8* of %6 = call noalias nonnull dereferenceable(1) dereferenceable_or_null(1) i8* @malloc(i64 1), !enzyme_fromstack !31

I now cache and re-load all scalar values.
All non i8* seem to automatically receive the !enzyme_caststack treatment, which probably ins't applied to Characters ('N', 'T', ...) because there are already i8*.
Without the casting we however end up re-using those values directly for the following gemm calls.
In all other cases we do only use the new values (e.g. %15), after casting %13 back and forth.
Since %13 is therefore not used anywhere else, enzyme probably succeeds at replacing it, while it fails for my char.
I guess I would need to update that inside of Enzyme, or can I update my tblgen code?

enzyme/Enzyme/Utils.cpp Outdated Show resolved Hide resolved
enzyme/Enzyme/DifferentialUseAnalysis.cpp Outdated Show resolved Hide resolved
enzyme/Enzyme/Utils.cpp Show resolved Hide resolved
enzyme/Enzyme/Utils.cpp Outdated Show resolved Hide resolved
enzyme/Enzyme/Utils.cpp Outdated Show resolved Hide resolved
enzyme/Enzyme/Utils.cpp Show resolved Hide resolved
enzyme/tools/enzyme-tblgen/datastructures.h Outdated Show resolved Hide resolved
enzyme/tools/enzyme-tblgen/enzyme-tblgen.cpp Outdated Show resolved Hide resolved
enzyme/tools/enzyme-tblgen/enzyme-tblgen.cpp Outdated Show resolved Hide resolved
enzyme/tools/enzyme-tblgen/enzyme-tblgen.cpp Outdated Show resolved Hide resolved
enzyme/tools/enzyme-tblgen/enzyme-tblgen.cpp Outdated Show resolved Hide resolved
ZuseZ4 and others added 2 commits June 12, 2023 22:29
Thank you!

Co-authored-by: Tim Gymnich <tgymnich@icloud.com>
@ZuseZ4 ZuseZ4 enabled auto-merge (squash) June 15, 2023 01:59
@ZuseZ4 ZuseZ4 merged commit 215b63c into main Jun 15, 2023
38 of 66 checks passed
@ZuseZ4 ZuseZ4 deleted the gemv branch August 9, 2023 18:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants