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

Implement unsupported/buggy floating-point operations by using Bluespec's import "BDPI" feature #28

Closed
RyanGlScott opened this issue Nov 8, 2024 · 0 comments · Fixed by #29
Labels
enhancement New feature or request

Comments

@RyanGlScott
Copy link
Collaborator

Currently, there are a variety of floating-point operations that copilot-bluespec simply does not support:

  • -- Unsupported operations (see
    -- https://github.com/B-Lang-org/bsc/discussions/534)
    Exp _ty -> unsupportedFPOp "exp"
    Log _ty -> unsupportedFPOp "log"
    Acos _ty -> unsupportedFPOp "acos"
    Asin _ty -> unsupportedFPOp "asin"
    Atan _ty -> unsupportedFPOp "atan"
    Cos _ty -> unsupportedFPOp "cos"
    Sin _ty -> unsupportedFPOp "sin"
    Tan _ty -> unsupportedFPOp "tan"
    Acosh _ty -> unsupportedFPOp "acosh"
    Asinh _ty -> unsupportedFPOp "asinh"
    Atanh _ty -> unsupportedFPOp "atanh"
    Cosh _ty -> unsupportedFPOp "cosh"
    Sinh _ty -> unsupportedFPOp "sinh"
    Tanh _ty -> unsupportedFPOp "tanh"
    Ceiling _ty -> unsupportedFPOp "ceiling"
    Floor _ty -> unsupportedFPOp "floor"
  • -- Unsupported operations (see
    -- https://github.com/B-Lang-org/bsc/discussions/534)
    Pow _ty -> unsupportedFPOp "(**)"
    Logb _ty -> unsupportedFPOp "logb"
    Atan2 _ty -> unsupportedFPOp "atan2"

See B-Lang-org/bsc#534.

In addition, copilot-bluespec's implementation of sqrt is buggy. See B-Lang-org/bsc#710.

Both of these problems can be solved by using BSV's import "BDPI" feature, which is essentially a foreign function interface to C code in Bluespec. Using this, we can implement these floating-operations in Bluespec in terms of the corresponding operations in libc. They won't be the fastest implementations around, but they'll at least be correct.

@RyanGlScott RyanGlScott added the enhancement New feature or request label Nov 8, 2024
RyanGlScott added a commit that referenced this issue Nov 11, 2024
This implements `exp`, `log`, etc. (which were previously missing in
`copilot-bluespec`) as well as `sqrt` (which was previously buggy) using
Bluespec's `import "BDPI"` feature, allowing these operations to be implemented
in terms of C code. While not the most performant implementations around, these
are much more likely to be correct than hand-written code. We can work on
improving the performance of these operations in future work.
RyanGlScott added a commit that referenced this issue Nov 12, 2024
Implement missing/buggy FP operations with `import "BDPI"`. Refs #28.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
1 participant