Skip to content

[PET-to-MLIR] handle no-ID int in PET index - #7

Closed
Komisarczyk wants to merge 53 commits into
LoopTactics:pet-mlirfrom
Komisarczyk:pet-mlir
Closed

Komisarczyk wants to merge 53 commits into
LoopTactics:pet-mlirfrom
Komisarczyk:pet-mlir

Conversation

@Komisarczyk

Copy link
Copy Markdown

No description provided.

chelini and others added 30 commits April 25, 2020 09:36
The first attempt in lowering a static control part (Scop) to the affine
dialect. The design is made around to classes: islNodeBuilder and mlirCodegen.
The former is used to walk the isl ast, while the latter is used to create IR
using the MLIR builders.
Introduce createBinaryOp to build binary operation starting from location
information, and an LHS and RHS values. Handle addition, multiplication,
subtraction and division operations.
Set up test infrastructure.
The lower and upper bounds specify a half-open range: the range includes the
lower bound but does not include the upper bound. Thus +1.
- Test end-to-end flow. Note that we use an
  absolute path for the util lib.

- Drop loopDownward.

- Merge tests in runner.mlir

- Fix test for gemm and gemver.
Originally the increment generated in postInc was of type float only. Enable
also int (32bit) and double. Add proper test case for int. Currently, we cannot
distinguish between float and double as a pet_expr can be only of type
pet_expr_int and pet_expr_double. For pet_expr_double we always generate float.
Add command-line options for input and output.
Properly handle release for pet_expr *
chelini and others added 22 commits April 25, 2020 09:41
Add naive test cases for gemm and gemv.
…ee summary)

- Handle post_inc and post_dec pet expressions.

- Fix generation for Add operation.

- Fix loop generation.

- Handle loop directions.

- Register affine and std dialect in MLIR context.

- Add test cases.
Remove unnecessary scope resolution.
- Regroup command line options in a 'tool options' category.

- Use InitLLVM as best practice for llvm-based tool.

- Pass -I options to pet.
- Fix getContext.

- replace unreachable with assert.

- Compute array extent by looking up the
array space among read/write accesses.
Similar to what Polly does in ppcgCodegen.cpp
This revision adds handling for print call operation withing the Scop. This
gives us a way to test the entire flow end-to-end. Future revisions will handle
more complex cases.
- Handle pet_kill_op: Kill statements are introduced automatically for locally
  defined scalars or arrays, one at the point of the declaration and one at the
  point where the declaration goes out of scope.

- Rename getShapeExpr to getDimensionalityExpr. Compute the dimensionality
  via pet array instead of using isl::space.

- Move helpers fuctions (getDimensionalityExpr, isMultiDimensionalArray
  and convertExprToMemRef) in the MLIRCodegen class.

- Fix convertToMemRef to handle multi-dimensional arrays.

- Re-work createAllocOp. In case of rescheduling pet_kill_op are
  lost, therefore createStoreOp may need to allocate.
Originally we extended mlir/Types.h with isInt and IsFloat to check if the type
was int or float like. It is not necessary to touch MLIR.
PET distinguishes between two types of const expressions integer and
floating-point, but it does not differentiate on the bit width, which is an
implementation choice. When creating a floating-point expression, get the type
of the LHS to distinguish between F32 and F64.
chelini pushed a commit that referenced this pull request May 20, 2020
Summary:
The previous code tries to strip out parentheses and anything in between
them. I'm guessing the idea here was to try to drop any listed arguments
for the function being symbolized. Unfortunately this approach is broken
in several ways.

* Templated functions may contain parentheses. The existing approach
messes up these names.
* In C++ argument types are part of a function's signature for the
purposes of overloading so removing them could be confusing.

Fix this simply by not trying to adjust the function name that comes
from `atos`.

A test case is included.

Without the change the test case produced output like:

```
WRITE of size 4 at 0x6060000001a0 thread T0
    #0 0x10b96614d in IntWrapper<void >::operator=> const&) asan-symbolize-templated-cxx.cpp:10
    #1 0x10b960b0e in void writeToA<IntWrapper<void > >>) asan-symbolize-templated-cxx.cpp:30
    #2 0x10b96bf27 in decltype>)>> >)) std::__1::__invoke<void >), IntWrapper<void > >>), IntWrapper<void >&&) type_traits:4425
    #3 0x10b96bdc1 in void std::__1::__invoke_void_return_wrapper<void>::__call<void >), IntWrapper<void > >>), IntWrapper<void >&&) __functional_base:348
    #4 0x10b96bd71 in std::__1::__function::__alloc_func<void >), std::__1::allocator<void >)>, void >)>::operator>&&) functional:1533
    #5 0x10b9684e2 in std::__1::__function::__func<void >), std::__1::allocator<void >)>, void >)>::operator>&&) functional:1707
    #6 0x10b96cd7b in std::__1::__function::__value_func<void >)>::operator>&&) const functional:1860
    #7 0x10b96cc17 in std::__1::function<void >)>::operator>) const functional:2419
    #8 0x10b960ca6 in Foo<void >), IntWrapper<void > >::doCall>) asan-symbolize-templated-cxx.cpp:44
    #9 0x10b96088b in main asan-symbolize-templated-cxx.cpp:54
    #10 0x7fff6ffdfcc8 in start (in libdyld.dylib) + 0
```

Note how the symbol names for the frames are messed up (e.g. #8, #1).

With the patch the output looks like:

```
WRITE of size 4 at 0x6060000001a0 thread T0
    #0 0x10005214d in IntWrapper<void (int)>::operator=(IntWrapper<void (int)> const&) asan-symbolize-templated-cxx.cpp:10
    #1 0x10004cb0e in void writeToA<IntWrapper<void (int)> >(IntWrapper<void (int)>) asan-symbolize-templated-cxx.cpp:30
    #2 0x100057f27 in decltype(std::__1::forward<void (*&)(IntWrapper<void (int)>)>(fp)(std::__1::forward<IntWrapper<void (int)> >(fp0))) std::__1::__invoke<void (*&)(IntWrapper<void (int)>), IntWrapper<void (int)> >(void (*&)(IntWrapper<void (int)>), IntWrapper<void (int)>&&) type_traits:4425
    #3 0x100057dc1 in void std::__1::__invoke_void_return_wrapper<void>::__call<void (*&)(IntWrapper<void (int)>), IntWrapper<void (int)> >(void (*&)(IntWrapper<void (int)>), IntWrapper<void (int)>&&) __functional_base:348
    #4 0x100057d71 in std::__1::__function::__alloc_func<void (*)(IntWrapper<void (int)>), std::__1::allocator<void (*)(IntWrapper<void (int)>)>, void (IntWrapper<void (int)>)>::operator()(IntWrapper<void (int)>&&) functional:1533
    #5 0x1000544e2 in std::__1::__function::__func<void (*)(IntWrapper<void (int)>), std::__1::allocator<void (*)(IntWrapper<void (int)>)>, void (IntWrapper<void (int)>)>::operator()(IntWrapper<void (int)>&&) functional:1707
    #6 0x100058d7b in std::__1::__function::__value_func<void (IntWrapper<void (int)>)>::operator()(IntWrapper<void (int)>&&) const functional:1860
    #7 0x100058c17 in std::__1::function<void (IntWrapper<void (int)>)>::operator()(IntWrapper<void (int)>) const functional:2419
    #8 0x10004cca6 in Foo<void (IntWrapper<void (int)>), IntWrapper<void (int)> >::doCall(IntWrapper<void (int)>) asan-symbolize-templated-cxx.cpp:44
    #9 0x10004c88b in main asan-symbolize-templated-cxx.cpp:54
    #10 0x7fff6ffdfcc8 in start (in libdyld.dylib) + 0
```

rdar://problem/58887175

Reviewers: kubamracek, yln

Subscribers: #sanitizers, llvm-commits

Tags: #sanitizers

Differential Revision: https://reviews.llvm.org/D79597
chelini pushed a commit that referenced this pull request Jun 14, 2020
Summary:
crash stack:

```
llvm-project/clang/lib/AST/ASTContext.cpp:2248: clang::TypeInfo clang::ASTContext::getTypeInfoImpl(const clang::Type *) const: Assertion `!A->getDeducedType().isNull() && "cannot request the size of an undeduced or dependent auto type"' failed.
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
 #0 0x00000000025bb0bf llvm::sys::PrintStackTrace(llvm::raw_ostream&) llvm-project/llvm/lib/Support/Unix/Signals.inc:564:13
 #1 0x00000000025b92b0 llvm::sys::RunSignalHandlers() llvm-project/llvm/lib/Support/Signals.cpp:69:18
 #2 0x00000000025bb535 SignalHandler(int) llvm-project/llvm/lib/Support/Unix/Signals.inc:396:3
 #3 0x00007f9ef9298110 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14110)
 #4 0x00007f9ef8d72761 raise /build/glibc-M65Gwz/glibc-2.30/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
 #5 0x00007f9ef8d5c55b abort /build/glibc-M65Gwz/glibc-2.30/stdlib/abort.c:81:7
 #6 0x00007f9ef8d5c42f get_sysdep_segment_value /build/glibc-M65Gwz/glibc-2.30/intl/loadmsgcat.c:509:8
 #7 0x00007f9ef8d5c42f _nl_load_domain /build/glibc-M65Gwz/glibc-2.30/intl/loadmsgcat.c:970:34
 #8 0x00007f9ef8d6b092 (/lib/x86_64-linux-gnu/libc.so.6+0x34092)
 #9 0x000000000458abe0 clang::ASTContext::getTypeInfoImpl(clang::Type const*) const llvm-project/clang/lib/AST/ASTContext.cpp:0:5
```

Reviewers: sammccall

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D81384
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.

2 participants