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

tan + sin funcs #391

Merged
merged 3 commits into from
Jun 20, 2024
Merged

tan + sin funcs #391

merged 3 commits into from
Jun 20, 2024

Conversation

enricozb
Copy link
Contributor

@enricozb enricozb commented Jun 18, 2024

fixes #384

@HigherOrderBot

This comment has been minimized.

src/hvm.c Outdated
@@ -570,6 +570,10 @@ static inline Numb operate(Numb a, Numb b) {
case OP_AND: return new_f24(atan2f(av, bv));
case OP_OR: return new_f24(logf(bv) / logf(av));
case OP_XOR: return new_f24(powf(av, bv));
case OP_SHL: return new_f24(sin(av + bv));
case FP_SHL: return new_f24(sin(av + bv));
Copy link
Member

Choose a reason for hiding this comment

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

We don't need to waste f24 FP_SHL and FP_SHR here

src/hvm.cu Outdated
@@ -676,6 +676,10 @@ __device__ __host__ inline Numb operate(Numb a, Numb b) {
case OP_AND: return new_f24(atan2f(av, bv));
case OP_OR: return new_f24(logf(bv) / logf(av));
case OP_XOR: return new_f24(powf(av, bv));
case OP_SHL: return new_f24(sin(av + bv));
case FP_SHL: return new_f24(sin(av + bv));
Copy link
Member

Choose a reason for hiding this comment

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

Same

src/hvm.rs Outdated
@@ -407,6 +407,10 @@ impl Numb {
OP_AND => Numb::new_f24(av.atan2(bv)),
OP_OR => Numb::new_f24(bv.log(av)),
OP_XOR => Numb::new_f24(av.powf(bv)),
OP_SHL => Numb::new_f24((av + bv).sin()),
OP_SHR => Numb::new_f24((av + bv).tan()),
FP_SHL => Numb::new_f24((av + bv).sin()),
Copy link
Member

Choose a reason for hiding this comment

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

and here

src/ast.rs Outdated
@@ -79,6 +79,8 @@ impl<'i> CoreParser<'i> {
_ if self.try_consume("&") => hvm::OP_AND,
_ if self.try_consume("|") => hvm::OP_OR,
_ if self.try_consume("^") => hvm::OP_XOR,
_ if self.try_consume("sin") => hvm::OP_SHL,
Copy link
Member

Choose a reason for hiding this comment

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

These symbols are trying to uniquely map to operators, so we shouldn't add sin and tan here. Notice how there's no pow, log and atan2.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fair enough but in the context of [ nothing else could appear there, thought it would be a bit more readable.

@enricozb enricozb removed the request for review from VictorTaelin June 19, 2024 07:21
@HigherOrderBot
Copy link
Collaborator

Perf run for aa0ca1c:

compiled
========

file            runtime         main            (local)       
==============================================================
sort_bitonic    c                        4.02s           3.87s
                cuda                     0.24s           0.23s
--------------------------------------------------------------
sum_rec         c                        1.43s           1.47s
                cuda                     0.15s           0.14s
--------------------------------------------------------------
sum_tree        c                        0.13s           0.12s
                cuda                     0.10s           0.11s
--------------------------------------------------------------
tuples          c                        2.97s           3.50s
                cuda                   timeout         timeout
--------------------------------------------------------------

interpreted
===========

file            runtime         main            (local)       
==============================================================
sort_bitonic    c                        3.38s           4.77s
                cuda                     0.24s           0.23s
                rust                   timeout         timeout
--------------------------------------------------------------
sum_rec         c                        1.70s           1.64s
                cuda                     0.14s           5.43s
                rust                    14.07s          13.58s
--------------------------------------------------------------
sum_tree        c                        0.27s           0.17s
                cuda                     0.08s           0.09s
                rust                     0.85s           0.88s
--------------------------------------------------------------
tuples          c                        4.06s           4.58s
                cuda                   timeout         timeout
                rust                     3.79s           3.82s
--------------------------------------------------------------


@enricozb enricozb merged commit a6e0e9d into main Jun 20, 2024
4 checks passed
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.

Add trigonometric function operators for F24
3 participants