Skip to content

issue with vector-addion.cu  #13

Open

Description

@dsinsight

Hey Nick,
I am getting an error in / Boundary Check
if (tid < N) c[tid] = a[tid] + b[tid];
but when i corrected according to vs suggestion to / Boundary Check
if (tid < N) c[tid] == a[tid] + b[tid];
then it says warning #174-D: expression has no effect
1> if (tid < N) c[tid] == a[tid] + b[tid];
However, after this warning, it showed "completed successfully" .
I used the VS-2022 community. Can you please explain what happened, I am still confused

Also, when I compile the same program with nvcc on WSL2-ubuntu 20.2 it says
vector-add.cu(26): warning #174-D: expression has no effect
but the compilation was done and on running the output file give this -
vector-add: vector-add.cu:33: void verify_result(std::vector&, std::vector&, std::vector&): Assertion `c[i] == a[i] + b[i]' failed.
Aborted

Can you please help me out with the same

Regards
Pronod

Activity

  1. Coder2503 commented on Aug 29, 2025

    @Coder2503

    Hey Nick,
    I am getting an error in / Boundary Check
    if (tid < N) c[tid] = a[tid] + b[tid];
    but when i corrected according to vs suggestion to / Boundary Check
    if (tid < N) c[tid] == a[tid] + b[tid];
    then it says warning #174-D: expression has no effect
    1> if (tid < N) c[tid] == a[tid] + b[tid];
    However, after this warning, it showed "completed successfully" .
    I used the VS-2022 community. Can you please explain what happened, I am still confused

    Also, when I compile the same program with nvcc on WSL2-ubuntu 20.2 it says
    vector-add.cu(26): warning #174-D: expression has no effect
    but the compilation was done and on running the output file give this -
    vector-add: vector-add.cu:33: void verify_result(std::vector&, std::vector&, std::vector&): Assertion `c[i] == a[i] + b[i]' failed.
    Aborted

    Can you please help me out with the same

    Regards
    Pronod

    c[tid]==a[tid]+b[tid] is asserting if tid'th element of c equals sum of tid'th element of a and b and that's why it fails.
    if (tid < N){c[tid] = a[tid] + b[tid]; } is the way to go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions