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

Wrong vector addition result inside a Cuda kernel. #1288

Open
nikitanodar opened this issue Apr 16, 2024 · 1 comment
Open

Wrong vector addition result inside a Cuda kernel. #1288

nikitanodar opened this issue Apr 16, 2024 · 1 comment

Comments

@nikitanodar
Copy link

nikitanodar commented Apr 16, 2024

The current master version (a2844eed) produces the wrong result in the kernel:

#include <glm/vec4.hpp>
#include <stdio.h>

__global__ void foo()
{
    glm::vec4 a{1.0f, 1.0f, 1.0f, 1.0f};
    glm::vec4 b{2.0f, 2.0f, 2.0f, 2.0f};
    glm::vec4 c = a + b;

    printf("%f %f %f %f\n%f %f %f %f\n%f %f %f %f\n%f %f %f %f\n\n", //
           a.x, a.y, a.z, a.w,                                       //
           b.x, b.y, b.z, b.w,                                       //
           a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w,               //
           c.x, c.y, c.z, c.w);
}

int main()
{
    foo<<<1, 1>>>();

    cudaDeviceSynchronize();

    return 0;
}

The result is:

1.000000 1.000000 1.000000 1.000000
2.000000 2.000000 2.000000 2.000000
3.000000 3.000000 3.000000 3.000000
1.000000 1.000000 1.000000 0.000000

The tag 1.0.1 version works as expected, i.e. the output is:

1.000000 1.000000 1.000000 1.000000
2.000000 2.000000 2.000000 2.000000
3.000000 3.000000 3.000000 3.000000
3.000000 3.000000 3.000000 3.000000
OS Ubuntu 20.04
nvcc --version Cuda compilation tools, release 11.4, V11.4.315
nvidia-smi Driver Version: 535.171.04 CUDA Version: 12.2

The same issue is reproduced on my colleagues machines with different OSes/drivers.

@Beastmaster
Copy link

I found the same problem

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

No branches or pull requests

2 participants