Skip to content

Conversation

@masahi
Copy link
Member

@masahi masahi commented Dec 7, 2020

This adds a new tir builtin atomic_add and corresponding lowering rule for LLVM GPU backends. So far, atomic_add is introduced and used by CUDA topi, and LLVM based GPU backend cannot compile ops that use it (nms, scatter_add, argwhere).

Unfortunately I couldn't get atomic_add working for CPU backend. There is some pointer cast issue that llvm IR verifier rejects. I think it is related to implicit cast to i8* done by LLVM CPU backend, but I haven't looked into details. So for now, only GPU backends support lowering atomic_add.

Other restriction is I've only supported 32 bit atomics. Supporting int64 atomic would be desirable but it looks complicated (need to generate CAS loop etc).

Obviously I'm a complete noob to atomic issues, any help would be appreciated.

please review @tqchen @zhiics @yzhliu @yidawang

Copy link
Contributor

@Laurawly Laurawly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Just a small comment that we can add a todo in the comment for CPU atomic.

@zhiics zhiics merged commit 3144cec into apache:main Dec 8, 2020
@zhiics
Copy link
Member

zhiics commented Dec 8, 2020

Thanks @masahi @Laurawly

@masahi masahi mentioned this pull request Dec 11, 2020
TusharKanekiDey pushed a commit to TusharKanekiDey/tvm that referenced this pull request Jan 20, 2021
* support atomic add on llvm

* make atomic builtin intrin

* test bincount on nvptx

* use builtin::atomic_add

* add atomic llvm codegen test, only works on int8 input somehow

* supports fp32 atomic

* drop support for cpu atomic

* add comment

* add atomic gpu unit test

* reenable other tests

* add doc string

* run black

* fix build with llvm 8 and older

* fix format

* do not run float32 atomic test on ci

* do not run scatter_add 1d with float inputs on CI

* fix typo

* add todo comment for cpu backend

* fix build on ci

Co-authored-by: masa <[email protected]>
trevor-m pushed a commit to neo-ai/tvm that referenced this pull request Jan 21, 2021
* support atomic add on llvm

* make atomic builtin intrin

* test bincount on nvptx

* use builtin::atomic_add

* add atomic llvm codegen test, only works on int8 input somehow

* supports fp32 atomic

* drop support for cpu atomic

* add comment

* add atomic gpu unit test

* reenable other tests

* add doc string

* run black

* fix build with llvm 8 and older

* fix format

* do not run float32 atomic test on ci

* do not run scatter_add 1d with float inputs on CI

* fix typo

* add todo comment for cpu backend

* fix build on ci

Co-authored-by: masa <[email protected]>
electriclilies pushed a commit to electriclilies/tvm that referenced this pull request Feb 18, 2021
* support atomic add on llvm

* make atomic builtin intrin

* test bincount on nvptx

* use builtin::atomic_add

* add atomic llvm codegen test, only works on int8 input somehow

* supports fp32 atomic

* drop support for cpu atomic

* add comment

* add atomic gpu unit test

* reenable other tests

* add doc string

* run black

* fix build with llvm 8 and older

* fix format

* do not run float32 atomic test on ci

* do not run scatter_add 1d with float inputs on CI

* fix typo

* add todo comment for cpu backend

* fix build on ci

Co-authored-by: masa <[email protected]>
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.

3 participants