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

LLVM_WASM: Support testing infrastructure #3866

Merged
merged 5 commits into from
Apr 15, 2024

Conversation

Shaikh-Ubaid
Copy link
Member

No description provided.

@Shaikh-Ubaid Shaikh-Ubaid force-pushed the llvm_wasm_test_support branch 2 times, most recently from aa44dbf to 4373243 Compare April 13, 2024 11:07
@Shaikh-Ubaid Shaikh-Ubaid marked this pull request as ready for review April 13, 2024 11:27
@Shaikh-Ubaid
Copy link
Member Author

No tests were removed from integration_tests/CMakelists.txt. Just llvm_wasm LABEL was added to supporting tests.

@@ -8,14 +8,14 @@ program sin_02
x = 10.5_dp
r1 = dsin(x)
r2 = -0.87969575997167_dp
err = abs(r1-r2)
err = my_abs(r1-r2)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name abs in integration_tests/arrays_04_func_pass_arr_dims.f90 and integration_tests/sin_02.f90 conflicts with abs from math.h when linking with c runtime library which is compiled to wasm. For now I simply renamed the abs to my_abs in these tests.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is problematic. If this is needed for the WASM output testing at the CI, then let's patch this file only in the WASM CI test with a patch file, and report a bug.

I would not stop testing this very important use case of a user-defined function with the same name as an intrinsic function.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reverted these changes.

conflicts with abs from math.h when linking with c runtime library which is compiled to wasm

The conflict is a warning. So, the tests pass seem to pass. For now, I think it is fine to have the warning. We can later using --mangle with the llvm_wasm backend for these tests. We can also do it in this PR, but since the changes in CMakeLists.txt are related to enabling a backend, I think we should provide such flags in a separate PR.

@Shaikh-Ubaid
Copy link
Member Author

This is ready.

Copy link
Contributor

@certik certik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beautiful, great job!

I left some comments that we should address.

@@ -254,7 +254,7 @@ LFORTRAN_API int32_t _lfortran_ichar(char *c);
LFORTRAN_API int32_t _lfortran_iachar(char *c);
LFORTRAN_API int32_t _lfortran_all(bool *mask, int32_t n);
LFORTRAN_API void _lpython_set_argv(int32_t argc_1, char *argv_1[]);
LFORTRAN_API int32_t _lpython_get_argc();
LFORTRAN_API void _lpython_get_argc(int32_t *cnt);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this change needed?

First, we'll need to do the same change in the LLVM backend, and test it in LPython.

But since we have other functions here that return values, why cannot this one return it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But since we have other functions here that return values, why cannot this one return it?

It can return a value. It can also simply take argument by reference and assign the return value to it (current approach). I think it is upto us which approach to follow.

In the LLVM backend, the prototype for this is defined as void _lpython_get_argc(int32_t *cnt) which conflicts with the prototype int32_t _lpython_get_argc(). So, we needed to update one of the prototype to match the other. In this case, I choosed to update the C runtime library prototype so that it matches with the one that we are declaring in the LLVM backend.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me know if we should do the other way round.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change breaks LPython. So, I made it the other way round by updating the LLVM backend with the correct prototype. I submitted the change to LPython as well lcompilers/lpython#2650.

@@ -8,14 +8,14 @@ program sin_02
x = 10.5_dp
r1 = dsin(x)
r2 = -0.87969575997167_dp
err = abs(r1-r2)
err = my_abs(r1-r2)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is problematic. If this is needed for the WASM output testing at the CI, then let's patch this file only in the WASM CI test with a patch file, and report a bug.

I would not stop testing this very important use case of a user-defined function with the same name as an intrinsic function.

strategy:
fail-fast: false
matrix:
llvm-version: ["10", "14", "15", "16"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this add a lot of tests into our CI and slow it down? Maybe we can test 10 and 16 only?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anything is fine for me. I simply used the existing LLVM testing approach at the CI.

Maybe we can test 10 and 16 only?

We can. Let's also test 13 (which is in middle of 10 and 16)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now, I am testing 10 and 16. Hopefully they should be sufficient. If not we can add more later.

@certik
Copy link
Contributor

certik commented Apr 14, 2024

881 tests pass. Very impressive.

@Shaikh-Ubaid Shaikh-Ubaid force-pushed the llvm_wasm_test_support branch 2 times, most recently from 5829ccb to 6fc4dae Compare April 14, 2024 05:37
@Shaikh-Ubaid
Copy link
Member Author

Ready.

Copy link
Contributor

@certik certik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great to merge. Thanks for this!

@certik certik merged commit f6d9f0f into lfortran:main Apr 15, 2024
23 checks passed
@Shaikh-Ubaid Shaikh-Ubaid deleted the llvm_wasm_test_support branch April 15, 2024 07:21
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

2 participants