beehive-lab / TornadoVM

TornadoVM: A practical and efficient heterogeneous programming framework for managed languages
https://www.tornadovm.org
Apache License 2.0
1.15k stars 109 forks source link

Fix failing unit-tests for PTX in Jenkins #441

Closed stratika closed 1 month ago

stratika commented 1 month ago

Description

This PR fixes some failing unit-tests for PTX.

Problem description

Here is a description of the reason of failing for every fixed test:

Backend/s tested

Mark the backends affected by this PR.

OS tested

Mark the OS where this PR is tested.

Did you check on FPGAs?

If it is applicable, check your changes on FPGAs.

How to test the new patch?

make BACKEND=ptx
make tests

jjfumero commented 1 month ago

It is not clear to me why we need to narrow the type from FP64 to FP32 if the operation selected is double. The PTX instruction set supports FP64. Can you expand on this?

stratika commented 1 month ago

It is not clear to me why we need to narrow the type from FP64 to FP32 if the operation selected is double. The PTX instruction set supports FP64. Can you expand on this?

Yes of course, the operations cos and sin in PTX support only FP32.

Screenshot 2024-06-04 at 10 14 42

This is something that we have already in develop when we run cos and sin operations with double types. However, the cospi and sinpi operations were escaping and producing compilation problems regarding mismatched types of the operands.

jjfumero commented 1 month ago

Thanks @stratika for the clarification. I saw how the NVIDIA compile handles when using OpenCL. It seems they use an intermediate table with pre-compute values called __cudart_sin_cos_coeffs . Let's continue with the narrow option and investigate this type of optimizations in the future.

jjfumero commented 1 month ago

As a side note, can we document somewhere that we narrow these operations in the context of NVIDIA PTX?

stratika commented 1 month ago

As a side note, can we document somewhere that we narrow these operations in the context of NVIDIA PTX?

Do we have such documentation for the other narrowed operations? Any suggestions? Adding a Javadoc?

jjfumero commented 1 month ago

I think the best way is to add Javadoc in the the TornadoMath API for those operations.