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

Ported integration_tests/test_list_01.py from LPython and add support for std::vector in LC to compile it #104

Merged
merged 4 commits into from
Mar 8, 2024

Conversation

czgdp1807
Copy link
Collaborator

No description provided.

@czgdp1807 czgdp1807 marked this pull request as ready for review March 8, 2024 14:13
@czgdp1807 czgdp1807 enabled auto-merge March 8, 2024 14:13
@czgdp1807 czgdp1807 merged commit 2222724 into lcompilers:main Mar 8, 2024
2 checks passed
@czgdp1807 czgdp1807 deleted the list_01 branch March 8, 2024 14:27
@certik
Copy link
Contributor

certik commented Mar 8, 2024

Excellent! How is the performance on this one?

@czgdp1807
Copy link
Collaborator Author

Haven't checked yet. But ASR is the same so performance should be the same. Will check during the weekend.

@certik
Copy link
Contributor

certik commented Mar 8, 2024

Performance will be the same as LPython, but I can't remember if we can beat Clang on this benchmark or not.

@czgdp1807
Copy link
Collaborator Author

czgdp1807 commented Mar 9, 2024

#include <vector>
#include <iostream>

int main() {
    std::vector<int32_t> v;
    for( int32_t i = 0; i < 400000000; i++ ) {
        v.push_back(i);
    }
    std::cout<<v[100000];
}
(lc) 21:35:58:~/lc_project/lc % clang++ ../debug.cpp -std=c++17
(lc) 21:36:04:~/lc_project/lc % time ./a.out                   
100000./a.out  12.70s user 0.49s system 99% cpu 13.286 total
(lc) 21:36:18:~/lc_project/lc % lc ../debug.cpp -o a.out       
(lc) 21:37:17:~/lc_project/lc % time ./a.out                   
100000
./a.out  0.30s user 0.11s system 91% cpu 0.457 total
(lc) 21:37:20:~/lc_project/lc % clang++ ../debug.cpp -std=c++17 -O3
(lc) 21:37:30:~/lc_project/lc % time ./a.out                       
100000./a.out  0.25s user 0.26s system 91% cpu 0.560 total

lc NOFAST is 29.07x faster than clang++ NOFAST (16.0.6) and 1.22x faster than clang++ -O3. I can't enable lc --fast via command line. I will add this option on Monday next week so that we can benchmark against clang++ without issues.

Update

After adding support for --fast tag (#110),

(lc) 0:18:07:~/lc_project/lc % lc /Users/czgdp1807/lc_project/debug.cpp --fast -o a.out   
(lc) 0:18:16:~/lc_project/lc % time ./a.out
100000./a.out  0.15s user 0.12s system 91% cpu 0.298 total
(lc) 0:18:21:~/lc_project/lc % clang++ ../debug.cpp -O3 -ffast-math
(lc) 0:19:31:~/lc_project/lc % time ./a.out
100000./a.out  0.26s user 0.29s system 91% cpu 0.601 total

So in release mode, LC is 2.02x faster than clang++ -O3 -ffast-math. This benchmark is just on std::vector::push_back. LC is the fastest of all.

@certik
Copy link
Contributor

certik commented Mar 9, 2024

Great job. This is very promising. Let me review this carefully and double check everything.

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