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

Basic support for gtest infra #89

Closed
wants to merge 123 commits into from
Closed

Basic support for gtest infra #89

wants to merge 123 commits into from

Conversation

Sameeranjoshi
Copy link
Collaborator

I tried building using -DLLVM_BUILD_TESTS=ON
I couldn't find any check-flang-optimizer target nor check-flang-unit target
The test is a dummy test, would work on that aggressively once the setup in done.

Can anyone from here guide on what information I might be missing?

schweitzpgi and others added 30 commits May 15, 2020 12:06
  - This requires analysis of local symbols.
  - To do that requires getting the symbol table (scope), which required
    threading the SemanticsContext for the main program.
  - Added sorting and sorrted symbol tables to the PFT.
  - Refactored temporaries.
  - Misc. refactoring to follow LLVM coding standard, etc.
With these changes, I can compile code like srot.f.
The internal symbol map had served its purpose and needs to be replaced with a
mapping structure that is more appropriate for Fortran variables, which can be
composed of a number of runtime values.  This new map will allow us to lower
more complicated entities correctly by tracking their component values.
* Generate FIR for a group of multi-way branches
 - arithmetic if
 - assigned goto (needs assign statement, which is also implemented)
 - computed goto
 - select case

* Review comment update.
fix compilation issue post merge
…ap for

lowering.  This piece primarily gets started in the direction of being able
to lower dynamic arrays and character types correctly.

There is still more work in fully leveraging this in the bridge, but all the
existing tests pass with this rewrite.
This patch changes the FIR region operations to be more like those found in
the loop dialect.  The changes are driven by the desire to be able to convert
FIR into a register ssa form.  The changes are specifically:

  - fir.loop has been replaced by fir.do_loop. The new form has the same
    semantics (inclusive bounds, unordered), but can now carry ssa-values
    around the loop and return them as results to the parent.
  - fir.where has been replaced by fir.if. This new form is identical to
    the current loop.if operation.
  - fir.iterate_while has been added. This operation is very similar to
    fir.loop with the addition that it requires a single loop-carried bool
    value that signals an early-exit condition to the operation.  While that
    value is true, iterate_while will continue to iterate. When it becomes
    false, the loop is exited.
  - fir.result is the new terminator for the above ops to facilitate the
    carrying of ssa-values through block arguments (phi nodes).

Change the syntax for fir.iterate_while to make it clear that the iterate condition is required.
Fixes bugs with lowering of fir.iterate_while to CFG.  The lowered code produced is now as follows.

    %0 = llvm.mlir.constant(1 : index) : !llvm.i64
    %1 = llvm.mlir.constant(100 : index) : !llvm.i64
    llvm.br ^bb1(%0, %arg0, %arg1 : !llvm.i64, !llvm.i1, !llvm.i32)
  ^bb1(%2: !llvm.i64, %3: !llvm.i1, %4: !llvm.i32):	// 2 preds: ^bb0, ^bb2
    %5 = llvm.icmp "slt" %2, %1 : !llvm.i64
    %6 = llvm.and %5, %3 : !llvm.i1
    llvm.cond_br %6, ^bb2, ^bb3
  ^bb2:	// pred: ^bb1
    %7 = ... : !llvm.i1
    %8 = llvm.add %2, %0 : !llvm.i64
    llvm.br ^bb1(%8, %7, %4 : !llvm.i64, !llvm.i1, !llvm.i32)
  ^bb3:	// pred: ^bb1

[review comment] improve description text to make it more clear

[review] minor cleanups per review comments
1. Initialize scalar intrinsic types
2. Add test global inits.
3. Add TODO place holders for things that need to be implemented
speculatively. This eliminates creation of some empty fir.if blocks.
…ence, we don't need or want to create a reference to the reference to pass the original reference. Instead just pass the reference itself.

add FIXME for POINTER and ALLOCATABLE
schweitzpgi and others added 13 commits May 15, 2020 18:57
this change exposes a problem in PFT.
We're near the end of bugs and missing features to support the F77
version of LAPACK. Removing this file in favor of opening Issues on
github to track any new problems.
remove the LAPACK-bugs.txt file.
These operations used to have different complexity, but it looks like
they are both constant as of C++11. Making this change just to be
consistent with other tests.
A small typo in '--fdebug-dump-pre-fir'.
Another crash apparently related to issue #74. Add check for empty list.
Add name mangling support for constants in procedures.
@banach-space
Copy link
Collaborator

Perhaps missing add_subdirectory(unittests) in the top CMake script for Flang?

Btw, the target that you've defined here is FlangUnitTests rather than check-flang-optimizer or check-flang-unit (i.e. try building FlangUnitTests instead).

@schweitzpgi
Copy link

The flang/CMakeLists.txt file probably needs some more work. For example, clang has the following to set up its testing.

https://github.com/flang-compiler/f18-llvm-project/blob/fir-dev/clang/CMakeLists.txt#L561-L590

@Sameeranjoshi
Copy link
Collaborator Author

Perhaps missing add_subdirectory(unittests) in the top CMake script for Flang?

It seems like there are some unittests written without using gtest and they tend to use ctest
Adding add_subdirectory(unittests) to top level CMakelists.txt fails the other tests present in directory.

CMake Error at llvm-proj/flang/unittests/Decimal/CMakeLists.txt:11 (add_flang_test):
  Unknown CMake command "add_flang_test".

Can we add only a single directory from unittests/ folder?
example, add_subdirectory(unittests/Optimizer)(This doesn't work anyways) or something similar?

Btw, the target that you've defined here is FlangUnitTests rather than check-flang-optimizer or check-flang-unit (i.e. try building FlangUnitTests instead).

I grepped for similar targets in llvm(check-llvm-unit) and mlir (check-mlir-unit) I couldn't find them.
So I chose the similar approach these projects tend to follow.
btw, how do we build FlangUnitTests target ?

@Sameeranjoshi
Copy link
Collaborator Author

The flang/CMakeLists.txt file probably needs some more work. For example, clang has the following to set up its testing.

https://github.com/flang-compiler/f18-llvm-project/blob/fir-dev/clang/CMakeLists.txt#L561-L590

Similar approach lldb and lld, follow also we have FLANG_INCLUDE_TESTS already in use in top level CMakelists.txt.

if(FLANG_INCLUDE_TESTS)
  add_subdirectory(unittests)
endif()

I might be wrong here but how does mlir work by just adding the directory without checks?

add_subdirectory(unittests)

I think clang is mixing regression tests and unittests, where as we have a LIT based regression tests merged in.

I think the issue might be raise from the older gtest setup already in place and there is a ticket for porting them to gtest
flang-compiler/f18#995

@kiranchandramohan
Copy link
Collaborator

Can this be added to llvm-project/flang?

@Sameeranjoshi
Copy link
Collaborator Author

Can this be added to llvm-project/flang?

@kiranchandramohan Thanks.
I was unknown of any test to write and test the gtest infra using fortran language constructs, whereas I had read the InternalNames.h and I wanted to have some tests for them as a part of working for fir-dev branch, hence I thought of having a PR in fir-dev.

I will push the part except the fir test into llvm-project/flang once I have the setup working.
Does that sound reasonable?

@banach-space
Copy link
Collaborator

banach-space commented May 21, 2020

@Sameeranjoshi

we have FLANG_INCLUDE_TESTS already in use in top level CMakelists.txt.

I didn't notice that, my bad! So yes, you need -DFLANG_INCLUDE_TESTS=On.

Otherwise everything should be in place. Include paths for GTest are set in add_unittests (which you call here).

I think the issue might be raise from the older gtest setup already in place

IIUC, there are currently only CTest tests in Flang (enabled here). I'm not aware of anything that would prevent CTest and GTest tests to co-exists.

btw, how do we build FlangUnitTests target ?

make FlangUnitTests (or ninja FlangUnitTests) - that's after running CMake with -DFLANG_INCLUDE_TESTS=On. I hope this helps.

Edit:

I'm not aware of anything that would prevent CTest and GTest tests to co-exists.

I might be missing something obvious though!

@kiranchandramohan
Copy link
Collaborator

@Sameeranjoshi That sounds OK to me. But consider the following if it is not too much work.

I was thinking that with unit tests, functions can be individually tested. If so it might be possible to test the name-mangling functions with what is already there in llvm-project/flang + Mangler.cpp, Mangler.h. And this does not require fir.

@schweitzpgi
Copy link

Merged after rebase.

@Sameeranjoshi Sameeranjoshi deleted the gtest_infra branch June 23, 2020 14:43
Leporacanthicus pushed a commit to Leporacanthicus/llvm-project that referenced this pull request Dec 31, 2023
This PR adds support for thread names in lldb on Windows.

```
(lldb) thr list
Process 2960 stopped
  thread flang-compiler#53: tid = 0x03a0, 0x00007ff84582db34 ntdll.dll`NtWaitForMultipleObjects + 20
  thread flang-compiler#29: tid = 0x04ec, 0x00007ff845830a14 ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'SPUW.6'
  thread flang-compiler#89: tid = 0x057c, 0x00007ff845830a14 ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'PPU[0x1000019] physics[main]'
  thread flang-compiler#3: tid = 0x0648, 0x00007ff843c2cafe combase.dll`InternalDoATClassCreate + 39518
  thread flang-compiler#93: tid = 0x0688, 0x00007ff845830a14 ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'PPU[0x100501d] uMovie::StreamingThread'
  thread flang-compiler#1: tid = 0x087c, 0x00007ff842e7a104 win32u.dll`NtUserMsgWaitForMultipleObjectsEx + 20
  thread flang-compiler#96: tid = 0x0890, 0x00007ff845830a14 ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'PPU[0x1002020] HLE Video Decoder'
<...>
```
NimishMishra pushed a commit to NimishMishra/f18-llvm-project that referenced this pull request Jun 27, 2024
…ang-compiler#89)

* [flang][OpenMP] Add support for multi-range `do concurrent` loops

Extends `do concurrent` to OpenMP mapping by adding support for
multi-range loops. The current implementation only works for perfectly
nested loops. So taking this input:

```fortran
do concurrent(i=1:n, j=1:m)
  a(i,j,k) = i * j
end do
```

will behave in exactly the same way as this input:

```
do concurrent(i=1:n)
  do concurrent(j=1:m)
    a(i,j,k) = i * j
  end do
end do
```
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.

8 participants