[PATCH] D76365: [cuda][hip] Add CUDA builtin surface/texture reference support.

2020-04-11 Thread Michael Liao via Phabricator via cfe-commits
hliao added a comment. In D76365#1975784 , @tra wrote: > It appears I can crash clang with some texture code: > https://godbolt.org/z/5vdEwC `llvm.nvvm.tex.unified.2d.v4f32.f32` has a vector output, the alias __attribute__((device)) float tex2d_ld(te

[PATCH] D76365: [cuda][hip] Add CUDA builtin surface/texture reference support.

2020-04-10 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment. It appears I can crash clang with some texture code: https://godbolt.org/z/5vdEwC Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D76365/new/ https://reviews.llvm.org/D76365 ___ cfe-

[PATCH] D76365: [cuda][hip] Add CUDA builtin surface/texture reference support.

2020-03-30 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment. In D76365#1947479 , @hliao wrote: > Nice! I'll file a bug with NVIDIA. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D76365/new/ https://reviews.llvm.org/D76365

[PATCH] D76365: [cuda][hip] Add CUDA builtin surface/texture reference support.

2020-03-27 Thread Michael Liao via Phabricator via cfe-commits
hliao added a comment. In D76365#1947462 , @hliao wrote: > In D76365#1947103 , @tra wrote: > > > In D76365#1946938 , @hliao wrote: > > > > > The new revision is accepted, rig

[PATCH] D76365: [cuda][hip] Add CUDA builtin surface/texture reference support.

2020-03-27 Thread Michael Liao via Phabricator via cfe-commits
hliao added a comment. In D76365#1947103 , @tra wrote: > In D76365#1946938 , @hliao wrote: > > > The new revision is accepted, right? Just want to confirm as it seems you > > accept it before I posted the new chang

[PATCH] D76365: [cuda][hip] Add CUDA builtin surface/texture reference support.

2020-03-27 Thread Michael Liao via Phabricator via cfe-commits
hliao added a comment. In D76365#1947103 , @tra wrote: > In D76365#1946938 , @hliao wrote: > > > The new revision is accepted, right? Just want to confirm as it seems you > > accept it before I posted the new chang

[PATCH] D76365: [cuda][hip] Add CUDA builtin surface/texture reference support.

2020-03-27 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment. In D76365#1946938 , @hliao wrote: > The new revision is accepted, right? Just want to confirm as it seems you > accept it before I posted the new change. The approval was for the old version. I didn't undo it when I reopened the re

[PATCH] D76365: [cuda][hip] Add CUDA builtin surface/texture reference support.

2020-03-27 Thread Michael Liao via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes. Closed by commit rG5be9b8cbe2b2: [cuda][hip] Add CUDA builtin surface/texture reference support. (authored by hliao). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D76365/new/

[PATCH] D76365: [cuda][hip] Add CUDA builtin surface/texture reference support.

2020-03-27 Thread Michael Liao via Phabricator via cfe-commits
hliao added a comment. In D76365#1946925 , @hliao wrote: > Fix Sema checks on partial template specialization. > > - Revise Sema checks on the template class. The new revision is accepted, right? Just want to confirm as it seems you accept it before I p

[PATCH] D76365: [cuda][hip] Add CUDA builtin surface/texture reference support.

2020-03-27 Thread Michael Liao via Phabricator via cfe-commits
hliao updated this revision to Diff 253214. hliao added a comment. Fix Sema checks on partial template specialization. - Revise Sema checks on the template class. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D76365/new/ https://reviews.llvm.org/D7

[PATCH] D76365: [cuda][hip] Add CUDA builtin surface/texture reference support.

2020-03-27 Thread Artem Belevich via Phabricator via cfe-commits
tra reopened this revision. tra added a comment. This revision is now accepted and ready to land. Reopened for further work Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D76365/new/ https://reviews.llvm.org/D76365

[PATCH] D76365: [cuda][hip] Add CUDA builtin surface/texture reference support.

2020-03-27 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment. In D76365#1946415 , @hliao wrote: > That's a partial template specialization needs handling. I am revising that > patch. Please revert it first. Thanks. Reverted in fe8063e1a0e983f1b4d

[PATCH] D76365: [cuda][hip] Add CUDA builtin surface/texture reference support.

2020-03-27 Thread Michael Liao via Phabricator via cfe-commits
hliao added a comment. In D76365#1946407 , @tra wrote: > In D76365#1946345 , @tra wrote: > > > Looks like the change breaks compilation for us: > > > > In file included from :1: > > In file included from > > ll

[PATCH] D76365: [cuda][hip] Add CUDA builtin surface/texture reference support.

2020-03-27 Thread Michael Liao via Phabricator via cfe-commits
hliao added a comment. In D76365#1946345 , @tra wrote: > Looks like the change breaks compilation for us: > > In file included from :1: > In file included from > llvm_unstable/toolchain/lib/clang/google3-trunk/include/__clang_cuda_runtime_wrapper.h:10

[PATCH] D76365: [cuda][hip] Add CUDA builtin surface/texture reference support.

2020-03-27 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment. In D76365#1946345 , @tra wrote: > Looks like the change breaks compilation for us: > > In file included from :1: > In file included from > llvm_unstable/toolchain/lib/clang/google3-trunk/include/__clang_cuda_runtime_wrapper.h:104:

[PATCH] D76365: [cuda][hip] Add CUDA builtin surface/texture reference support.

2020-03-27 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment. Looks like the change breaks compilation for us: In file included from :1: In file included from llvm_unstable/toolchain/lib/clang/google3-trunk/include/__clang_cuda_runtime_wrapper.h:104: In file included from cuda/include/cuda_runtime.h:116: cuda/include/cuda_surfac

[PATCH] D76365: [cuda][hip] Add CUDA builtin surface/texture reference support.

2020-03-26 Thread Michael Liao via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes. Closed by commit rG6a9ad5f3f4ac: [cuda][hip] Add CUDA builtin surface/texture reference support. (authored by hliao). Changed prior to commit: https://reviews.llvm.org/D76365?vs=252828&id=252929#toc Repository: rG LLVM

[PATCH] D76365: [cuda][hip] Add CUDA builtin surface/texture reference support.

2020-03-26 Thread Michael Liao via Phabricator via cfe-commits
hliao added a comment. In D76365#1944272 , @tra wrote: > LGTM. Next step is to figure out what various > __nv_tex_surf_handler(...) maps to for various strings (there are > ~110 of them in CUDA-10.2) and implement its replacement. I think we should > be

[PATCH] D76365: [cuda][hip] Add CUDA builtin surface/texture reference support.

2020-03-26 Thread Artem Belevich via Phabricator via cfe-commits
tra accepted this revision. tra added a comment. This revision is now accepted and ready to land. LGTM. Next step is to figure out what various __nv_tex_surf_handler(...) maps to for various strings (there are ~110 of them in CUDA-10.2) and implement its replacement. I think we should be able t

[PATCH] D76365: [cuda][hip] Add CUDA builtin surface/texture reference support.

2020-03-26 Thread Michael Liao via Phabricator via cfe-commits
hliao updated this revision to Diff 252828. hliao added a comment. Rebase to the master code Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D76365/new/ https://reviews.llvm.org/D76365 Files: clang/include/clang/AST/Type.h clang/include/clang/Bas

[PATCH] D76365: [cuda][hip] Add CUDA builtin surface/texture reference support.

2020-03-26 Thread Michael Liao via Phabricator via cfe-commits
hliao marked an inline comment as done. hliao added inline comments. Comment at: clang/lib/Headers/__clang_cuda_runtime_wrapper.h:82-94 #undef __CUDACC__ #if CUDA_VERSION < 9000 #define __CUDABE__ #else +#define __CUDACC__ #define __CUDA_LIBDEVICE__ #endif

[PATCH] D76365: [cuda][hip] Add CUDA builtin surface/texture reference support.

2020-03-26 Thread Michael Liao via Phabricator via cfe-commits
hliao updated this revision to Diff 252758. hliao added a comment. Fix windows build and revise header change. - When including `drivers_types.h` or `host_defines.h` with `__CUDACC__`, the only difference is the additional attributes added. No additional change. - After including `host_defines.h

[PATCH] D76365: [cuda][hip] Add CUDA builtin surface/texture reference support.

2020-03-25 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments. Comment at: clang/lib/Headers/__clang_cuda_runtime_wrapper.h:82-94 #undef __CUDACC__ #if CUDA_VERSION < 9000 #define __CUDABE__ #else +#define __CUDACC__ #define __CUDA_LIBDEVICE__ #endif hliao wrote: > hliao wrote: > > tra wrote:

[PATCH] D76365: [cuda][hip] Add CUDA builtin surface/texture reference support.

2020-03-25 Thread Michael Liao via Phabricator via cfe-commits
hliao marked 3 inline comments as done. hliao added inline comments. Comment at: clang/lib/Headers/__clang_cuda_runtime_wrapper.h:82-94 #undef __CUDACC__ #if CUDA_VERSION < 9000 #define __CUDABE__ #else +#define __CUDACC__ #define __CUDA_LIBDEVICE__ #endif

[PATCH] D76365: [cuda][hip] Add CUDA builtin surface/texture reference support.

2020-03-24 Thread Michael Liao via Phabricator via cfe-commits
hliao marked 6 inline comments as done. hliao added inline comments. Comment at: clang/lib/CodeGen/CodeGenModule.cpp:701-713 + if (getLangOpts().CUDAIsDevice) { +// As CUDA builtin surface/texture types are replaced, skip generating TBAA +// access info. +if (AccessT

[PATCH] D76365: [cuda][hip] Add CUDA builtin surface/texture reference support.

2020-03-24 Thread Michael Liao via Phabricator via cfe-commits
hliao updated this revision to Diff 252468. hliao marked an inline comment as done. hliao added a comment. Add Sema checks on CUDA device builtin surface/texture attributes. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D76365/new/ https://reviews.l

[PATCH] D76365: [cuda][hip] Add CUDA builtin surface/texture reference support.

2020-03-20 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments. Comment at: clang/lib/CodeGen/CodeGenModule.cpp:701-713 + if (getLangOpts().CUDAIsDevice) { +// As CUDA builtin surface/texture types are replaced, skip generating TBAA +// access info. +if (AccessType->isCUDADeviceBuiltinSurfaceType()) { +

[PATCH] D76365: [cuda][hip] Add CUDA builtin surface/texture reference support.

2020-03-20 Thread Michael Liao via Phabricator via cfe-commits
hliao updated this revision to Diff 251777. hliao added a comment. Minor revising following reviewer's comment. Work on Sema checks and upload another review. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D76365/new/ https://reviews.llvm.org/D76365

[PATCH] D76365: [cuda][hip] Add CUDA builtin surface/texture reference support.

2020-03-20 Thread Michael Liao via Phabricator via cfe-commits
hliao marked 5 inline comments as done. hliao added inline comments. Comment at: clang/lib/CodeGen/CodeGenModule.cpp:701-713 + if (getLangOpts().CUDAIsDevice) { +// As CUDA builtin surface/texture types are replaced, skip generating TBAA +// access info. +if (AccessT

[PATCH] D76365: [cuda][hip] Add CUDA builtin surface/texture reference support.

2020-03-20 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments. Comment at: clang/lib/CodeGen/CGCUDARuntime.h:51 +}; +unsigned Kind : 2; +unsigned Extern : 1; This should be `DeviceVarKind` Comment at: clang/lib/CodeGen/CGCUDARuntime.h:53 +unsigned Extern : 1; +

[PATCH] D76365: [cuda][hip] Add CUDA builtin surface/texture reference support.

2020-03-20 Thread Michael Liao via Phabricator via cfe-commits
hliao added a comment. In D76365#1932517 , @tra wrote: > In D76365#1932439 , @hliao wrote: > > > > > > > > > That's a magic. I could not figure out how it works. From its use, e.g. > > `tex2D` on `texture`, > > >

[PATCH] D76365: [cuda][hip] Add CUDA builtin surface/texture reference support.

2020-03-19 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment. In D76365#1932439 , @hliao wrote: > > That's a magic. I could not figure out how it works. From its use, e.g. > `tex2D` on `texture`, > > __nv_tex_surf_handler("__tex2D_v2", (typename __nv_tex_rmet_cast::type) > &temp, t, x, y

[PATCH] D76365: [cuda][hip] Add CUDA builtin surface/texture reference support.

2020-03-19 Thread Michael Liao via Phabricator via cfe-commits
hliao added a comment. In D76365#1932398 , @tra wrote: > I believe LLVM does have `nvvm.texsurf.handle` implemented: > https://github.com/llvm/llvm-project/blob/d9972f848294b06807c8764615852ba2bc1e8a74/llvm/include/llvm/IR/IntrinsicsNVVM.td#L1150 This o

[PATCH] D76365: [cuda][hip] Add CUDA builtin surface/texture reference support.

2020-03-19 Thread Michael Liao via Phabricator via cfe-commits
hliao added a comment. In D76365#1932392 , @tra wrote: > > Note that, clang-based one needs defining texture fetch functions as they > > could not be reused from CUDA SDK. That part is enclosed with #if > > defined(__clang__). > > What prevents clang to

[PATCH] D76365: [cuda][hip] Add CUDA builtin surface/texture reference support.

2020-03-19 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment. I believe LLVM does have `nvvm.texsurf.handle` implemented: https://github.com/llvm/llvm-project/blob/d9972f848294b06807c8764615852ba2bc1e8a74/llvm/include/llvm/IR/IntrinsicsNVVM.td#L1150 We also appear to have some plumbing for it in clang: https://github.com/llvm/llvm-pro

[PATCH] D76365: [cuda][hip] Add CUDA builtin surface/texture reference support.

2020-03-19 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment. > Note that, clang-based one needs defining texture fetch functions as they > could not be reused from CUDA SDK. That part is enclosed with #if > defined(__clang__). What prevents clang to compile the texture functions in the CUDA headers? It looks like we'll need to imple

[PATCH] D76365: [cuda][hip] Add CUDA builtin surface/texture reference support.

2020-03-19 Thread Michael Liao via Phabricator via cfe-commits
hliao added a comment. With this revision, the following sample could be compiled with CUDA SDK and almost the same PTX code is generated. #include texture tex; #if defined(__clang__) struct v4f { float x, y, z, w; }; __device__ v4f tex_2d_ld(texture, float,

[PATCH] D76365: [cuda][hip] Add CUDA builtin surface/texture reference support.

2020-03-19 Thread Michael Liao via Phabricator via cfe-commits
hliao updated this revision to Diff 251488. hliao added a comment. More refinement to compile sample code with CUDA headers. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D76365/new/ https://reviews.llvm.org/D76365 Files: clang/include/clang/AST/

[PATCH] D76365: [cuda][hip] Add CUDA builtin surface/texture reference support.

2020-03-18 Thread Michael Liao via Phabricator via cfe-commits
hliao updated this revision to Diff 251241. hliao added a comment. Revise one part of the logic to reduce condition evaluation overhead. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D76365/new/ https://reviews.llvm.org/D76365 Files: clang/includ

[PATCH] D76365: [cuda][hip] Add CUDA builtin surface/texture reference support.

2020-03-18 Thread Michael Liao via Phabricator via cfe-commits
hliao updated this revision to Diff 251125. hliao added a comment. Fix warnings from clang-tidy. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D76365/new/ https://reviews.llvm.org/D76365 Files: clang/include/clang/AST/Type.h clang/include/clang

[PATCH] D76365: [cuda][hip] Add CUDA builtin surface/texture reference support.

2020-03-18 Thread Michael Liao via Phabricator via cfe-commits
hliao updated this revision to Diff 251101. hliao added a comment. Reformatting with clang-format. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D76365/new/ https://reviews.llvm.org/D76365 Files: clang/include/clang/AST/Type.h clang/include/cla

[PATCH] D76365: [cuda][hip] Add CUDA builtin surface/texture reference support.

2020-03-18 Thread Michael Liao via Phabricator via cfe-commits
hliao created this revision. hliao added reviewers: tra, rjmccall, yaxunl. Herald added a reviewer: a.sidorin. Herald added a project: clang. Herald added a subscriber: cfe-commits. - Even though the bindless surface/texture interfaces are promoted, there are still code using surface/texture refe