Skip to content

__all_sync和__any_sync的使用问题,书P119 #44

@czflshzy

Description

@czflshzy

老师好,我在学习“11.3 更多线程束内的基本函数”时,运行github中warp.cu。
书上以及理论上的结果应该是
all_sync (FULL_MASK): 0
all_sync (mask1): 1
any_sync (FULL_MASK): 1
any_sync (mask2): 0
然而,我运行出的结果是
all_sync (FULL_MASK): 0
all_sync (mask1): 0
any_sync (FULL_MASK): 1
any_sync (mask2): 1

我知晓本书所参考的是 CUDA 10 版本,而我使用的是Cuda12.8,
但是查手册,
__all_sync(unsigned mask, predicate):
Evaluate predicate for all non-exited threads in mask and return non-zero if and only if predicate evaluates to non-zero for all of them.

__any_sync(unsigned mask, predicate):
Evaluate predicate for all non-exited threads in mask and return non-zero if and only if predicate evaluates to non-zero for any of them
这两个函数的作用应该没有因为Cuda版本的更新而产生改变。

我使用的设备:NVIDIA GeForce RTX 3070 Laptop GPU+Cuda 12.8

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