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

hw08/cuda #9

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

hw08/cuda #9

wants to merge 1 commit into from

Conversation

Tigerrr07
Copy link

(迟来的Pr...)

  • filter_positive()有什么问题?
    在一个线程中对counter+1时,可能会有另外一个线程同时取出counter的旧值+1,而不是最新值,因此造成错误。使用atomicAdd()原子操作避免上述问题
  • fill_sin改为网格跨步循环后,可以指定任意的线程数(blockDim)和板块数(gridDim),无需担心越界或漏元素的问题
  • “边角料法”对于不是 1024 整数倍的 n 会出错,为什么?
    若n = 1025,n / 1024 = 1,总共会启动1*1024=1024个线程,会漏掉1个元素
  • CPU访问数据遗漏了同步,同步可以让CPU陷入等待,等GPU中的任务队列执行完毕后才继续工作

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

Successfully merging this pull request may close these issues.

1 participant