Commit Graph

343 Commits

Author SHA1 Message Date
Chris Kitching 9eff10c00d Move giant lookup table into another translation unit
Also, rewrote it as a constant variable instead of a function
that imperatively fills a map. It's shorter, faster the compile,
and (depending on how badly the compiler screws it up) maybe
faster to run.

And, of course, it starts breaking up that giant .cpp file.


[ROCm/hip commit: 4ab29113a1]
2017-10-24 20:38:25 +01:00
Chris Kitching 71cc7740ff Tweak some version numbers in clang version compatibility checks
Apparently a couple of those APIs changed in clang 5, not 4.

Drat.


[ROCm/hip commit: 0207a29f78]
2017-10-24 01:45:23 +01:00
Chris Kitching ecbe19828e Avoid a double-free of HipifyPPCallbacks instance
This bug was present all along, but something changed in the order
of de-initialisation performed by llvm that makes it actually
crash now.

The constructor of HipifyPPCallbacks gives:
```
std::unique_ptr<HipifyPPCallbacks>(this)
```
to the LLVM Preprocessor instance. The Preprocessor instance
subsequently frees the HipifyPPCallbacks, which is then freed
again when we leave the stack frame at line 4340.

So: let's leak the HipifyPPCallbacks onto the heap, and leave
the LLVM Preprocessor object responsible for tidying it up.


[ROCm/hip commit: f5b273fc4f]
2017-10-19 17:09:32 +01:00
Chris Kitching dc869ef474 Be agnostic to the new getReplacements() API
See comment


[ROCm/hip commit: 6718519025]
2017-10-19 17:08:55 +01:00
Chris Kitching c08f105982 Use inline initialisers to set default field values
A trivial cleanup that helps in a moment..


[ROCm/hip commit: 24fc459f69]
2017-10-19 17:08:55 +01:00
Chris Kitching 2584387bfc Omit now-removed Filename string arg from handleBeginSource
[ROCm/hip commit: 7ae6a10c99]
2017-10-19 17:08:55 +01:00
Chris Kitching b2ac8756fc Cope with Replacements now having llvm::Error returns
[ROCm/hip commit: 7e253365f1]
2017-10-19 17:08:54 +01:00
Chris Kitching 5e45fd1c7c Cope with clang 4.0's rename of getNumArgs()
Sorry, this one I couldn't do in a perfectly elegant way ;)


[ROCm/hip commit: 575bedb28c]
2017-10-19 17:08:54 +01:00
Chris Kitching 459b78e997 Remove unnecessary call to Retain() on a smart pointer
The Preprocessor smart pointer is held by the CompilerInstance,
and therefore its reference count cannot reach zero until the
CompilerInstance itself is destroyed.

If the CompilerInstance is destroyed, you have more to worry about
than just the preprocessor being deallocated!

Newer versions of the LLVM/Clang API migrated to using
std::shared_ptr, so there is no `Retain()` function (by that
name, anyway). Eliminating this redundant use is a neat and
backward-compatible way to become compatible with newer versions
of the LLVM/Clang API.


[ROCm/hip commit: 0953a7887d]
2017-10-19 17:08:54 +01:00
Chris Kitching 316faf5fc7 Refer to clang::StringLiteral explicitly
Newer versions of llvm/clang mean there is both an
llvm::StringLiteral and a clang::StringLiteral. Since we're
dumping both namespaces wholesale into the global namespace with
`using` declarations, this creates a name collision, which must be
resolved.

This change is backwards-compatible, and fixes a problem you
encounter when using newer versions of the llvm/clang API.


[ROCm/hip commit: 2975d00edc]
2017-10-19 17:08:54 +01:00
Chris Kitching 24adac896b Fix two faulty LLVM version checks
What we actually want to do here is use the StringRef version in
versions newer than 3.8, and the void one in 3.8 and older.

Checking "major-version >= 3 && minor-version >= 9" does not do
what we want. Consider what this will do for version 4.0, for
which minor-version is zero...


[ROCm/hip commit: 3a2fe40f78]
2017-10-19 17:08:54 +01:00
Chris Kitching 9cd878f5c7 Inline a redundant std::vector
Looks like a partial refactor..?


[ROCm/hip commit: 4ba2b2e5b8]
2017-10-19 14:11:25 +01:00
Chris Kitching 0602fc6124 Allow user-provided -std=* argument to override the default
This means any user-provided -std=* argument overrides this one,
allowing use of newer standards.


[ROCm/hip commit: 742526706b]
2017-10-19 14:11:15 +01:00
Evgeny Mankov 65497bfaff Merge pull request #210 from ChrisKitching/output-hipify
[HIPIFY] Alter output file behaviour slightly

[ROCm/hip commit: db7661ccad]
2017-10-18 21:46:31 +03:00
Chris Kitching 49f9c4feff Unconditionally append .hip as the default output filename
[ROCm/hip commit: 296c5a33ce]
2017-10-18 19:19:18 +01:00
Chris Kitching a2629da99c If an output path is given _use it_
Don't append .hip to a user-provided output file...


[ROCm/hip commit: e4e17a56bb]
2017-10-16 17:32:57 +01:00
Chris Kitching 0c0891836f Operate on a temp file in-place
This copies to the output after operation, instead of working
_on_ the output. This allows includes to work correctly, while
supporting output paths anywhere on the filesystem.

Fixes #208
Fixes #206


[ROCm/hip commit: 2263cb9f72]
2017-10-16 17:32:56 +01:00
Evgeny Mankov 0162211c28 [HIPIFY][#199][Partial fix] Fix for cudaLaunchKernel transformation
[Synopsis]
If any of kernel arguments is a MACRO its location calculation is wrong (location of its definition is actually calculated).
Thus garbage code is being produced on the place of such a MACRO starting from the end of its actual definition.

[Solution]
Add isMacroBodyExpansion and isMacroArgExpansion checks on kernel arguments.


[ROCm/hip commit: 7ee8e2d51b]
2017-10-12 20:05:42 +03:00
Evgeny Mankov 643eb7ace7 [HIPIFY] CUDA RT Textures and Arrays support update
[ROCm/hip commit: 53ce40ebab]
2017-10-05 16:38:36 +03:00
Evgeny Mankov e93f55f502 [HIPIFY] CUDA RT Textures support update
[ROCm/hip commit: 28a300aed2]
2017-09-18 17:52:50 +03:00
Evgeny Mankov 24fc06496b Update Cuda2Hip.cpp
[ROCm/hip commit: d614f53ad7]
2017-07-28 01:45:24 +03:00
Evgeny Mankov 21c012ffca [HIPIFY] CUDA RT Textures support
[ROCm/hip commit: ffcf5d32a0]
2017-07-27 18:39:40 +03:00
Evgeny Mankov 9ba397e8fe [HIPIFY] CUDA Stream Callback support
[ROCm/hip commit: 368aebc4bc]
2017-07-26 19:29:50 +03:00
Evgeny Mankov e17a4fffa9 [HIPIFY] Finally finished syncing with CUDA 8.0.61 Driver and Runtime… (#105)
[hipify-clang] Finally finished syncing with CUDA 8.0.61 Driver and Runtime API (including missing data types, D3D, OpenGL, VDPAU and EGL interop).

    + All the Modules are supported now:
	1) 4.1 – 4.31 from CUDA 8.0.61 Driver API
	2) CUDA_Driver_API_functions_supported_by_HIP.md updated accordingly
	3) 4.1 – 4.31 from CUDA 8.0.61 Runtime API
	4) CUDA_Runtime_API_functions_supported_by_HIP.md updated accordingly
    + Typos fixing
    + Annotating

[ROCm/hip commit: 85e6593a1b]
2017-07-26 09:38:03 +05:30
Evgeny Mankov c396932615 [HIPIFY] Sync more CUDA Driver API functions.
+ 4.14. Event Management
+ 4.15. Execution Control

ToDo: 4.16 - 4.31 modules of CUDA Driver API.


[ROCm/hip commit: b4a39664f0]
2017-06-22 21:53:32 +03:00
Evgeny Mankov c351308890 [HIPIFY] Sync HIPIFY with HIP by CUDA Driver API functions.
+ 4.12. Unified Addressing
+ 4.13. Stream Management

ToDo: 4.14 - 4.31 modules of CUDA Driver API.


[ROCm/hip commit: 0208fa4e70]
2017-06-14 19:55:55 +03:00
Evgeny Mankov df7cbf0a1a [HIPIFY] Initial sync HIPIFY with HIP by CUDA Driver API functions.
+ CUDA_Driver_API_functions_supported_by_HIP.md update.
+ Initial update of HIPIFY with CUDA driver API functions:
  1.Error Handling, 2.Initialization, 3.Version Management, 5-6.Device Management, 7.Primary Context, 8-9.Context, 10.Module Management, 11.Memory Management.
+ Sync HIP functions against CUDA Driver and Runtime API functions.
+ Typo fixes.

ToDo: 12-30 modules of CUDA Driver API.


[ROCm/hip commit: f805bd0c1d]
2017-06-13 20:25:11 +03:00
Evgeny Mankov 0c12f09ba5 [HIPIFY] All CUDA 8.0.44 API functions update
(for both Driver and Runtime APIs)

1) P2P
cuDeviceGetP2PAttribute   cudaDeviceGetP2PAttribute

2) Memory Mngmnt
cuMemPrefetchAsync        cudaMemPrefetchAsync
cuMemAdvise               cudaMemAdvise
cuMemRangeGetAttribute    cudaMemRangeGetAttribute
cuMemRangeGetAttributes   cudaMemRangeGetAttributes

3) Streams (Driver API only, no analogues in Runtime API)
cuStreamWaitValue32
cuStreamWaitValue32
cuStreamWriteValue32

4) Texture Reference Mngmnt (Driver API only, no analogues in Runtime API)
cuTexRefSetBorderColor
cuTexRefGetBorderColor


[ROCm/hip commit: 4a5484c616]
2017-06-01 21:08:33 +03:00
Evgeny Mankov 7a3befc555 [HIP] [HIPIFY] CUDA Driver API 8.0.44 JIT options support.
[ROCm/hip commit: 6e99e388ea]
2017-05-31 18:55:29 +03:00
Evgeny Mankov f99ab93b61 [HIPIFY] Add the rest CUDA Runtime API 8.0.44 Data structures.
+ sync with corresponding CUDA Driver API Data structures.

P.S.
There is no any new changes in CUDA Runtime API 8.0.61 Data structures since 8.0.44.


[ROCm/hip commit: 063539308e]
2017-05-30 19:45:59 +03:00
Evgeny Mankov 8a05cf882f [HIPIFY] Add the rest CUDA Driver API 8.0.44 Data structures.
+ Memory advise values
+ Memory Range Attributes
+ P2P Attributes

P.S.
There is no any new changes in CUDA Driver API 8.0.61 Data structures since 8.0.44.


[ROCm/hip commit: 1cc5f42e34]
2017-05-30 18:29:14 +03:00
Evgeny Mankov 8574437d36 [HIPIFY] Add more CUDA Driver API 8.0.44 Data structures.
[ROCm/hip commit: 3e99bc23e7]
2017-05-30 17:58:13 +03:00
Evgeny Mankov bc9b970f82 [FIX] [HIPIFY] Add matchers for function return types.
https://github.com/GPUOpen-ProfessionalCompute-Tools/HIP/issues/73

Examples (https://github.com/thrust/thrust/blob/master/thrust/system/cuda/detail/trivial_copy.inl):

template<typename System1,
         typename System2>
cudaStream_t cuda_memcpy_stream(const thrust::cpp::execution_policy<System1> &,
                                const thrust::cuda::execution_policy<System2> &exec)

template<typename System1,
         typename System2>
cudaMemcpyKind cuda_memcpy_kind(const thrust::cuda::execution_policy<System1> &,
                                const thrust::cpp::execution_policy<System2> &)


[ROCm/hip commit: c863215611]
2017-05-24 18:25:40 +03:00
Evgeny Mankov 0a43773e0d [FIX] [HIPIFY] Matcher for new operator is missing.
https://github.com/GPUOpen-ProfessionalCompute-Tools/HIP/issues/80

Example from CUDA 8.0.44 sample (CUDASamples\0_Simple\matrixMulDrv\matrixMulDrv.cpp):
    CUjit_option *jitOptions = new CUjit_option[jitNumOptions];
where CUjit_option is enum, should be:
    hipJitOption *jitOptions = new hipJitOption[jitNumOptions];


[ROCm/hip commit: 3d973dc4da]
2017-05-23 19:45:38 +03:00
Evgeny Mankov cb7e073c42 [HIPIFY] [FIX] [HIPIFY] Matcher for pointer to enum var declaration is missing.
https://github.com/GPUOpen-ProfessionalCompute-Tools/HIP/issues/79

Example from CUDA 8.0.44 sample (CUDASamples\0_Simple\matrixMulDrv\matrixMulDrv.cpp):
    CUjit_option *jitOptions = new CUjit_option[jitNumOptions];
where CUjit_option is enum, should be:
    hipJitOption *jitOptions = new hipJitOption[jitNumOptions];

[TODO]
1. new CUjit_option -> new hipJitOption.
   Matcher for new operator is missing:
https://github.com/GPUOpen-ProfessionalCompute-Tools/HIP/issues/79
2. Merge matchers cudaEnumDecl and cudaEnumVarPtr.


[ROCm/hip commit: b5a1d47e68]
2017-05-19 17:39:09 +03:00
Evgeny Mankov 042de3e175 [HIP] [HIPIFY] [FIX] cuModuleLoadDataEx -> hipModuleLoadDataEx
https://github.com/GPUOpen-ProfessionalCompute-Tools/HIP/issues/81

1.	Do not use JIT options on HCC path, call hipModuleLoadData instead.
2.	NVCC path is unchanged, to call cuModuleLoadDataEx with all options.
3.	Get rid of manual hipification, based on #ifdef #else for NVCC/HIP.
4.	Update documentation accordingly.


[ROCm/hip commit: 270f643c9c]
2017-05-19 17:22:14 +03:00
Evgeny Mankov 1a183a71a5 [HIPIFY] cudaMallocPitch -> hipMallocPitch
[ROCm/hip commit: 12d8c53c90]
2017-05-16 18:21:25 +03:00
Evgeny Mankov 6b76c979ce [HIPIFY] CUDA Driver API: Primary Context Management support.
[ROCm/hip commit: a97cb6810c]
2017-05-15 15:35:52 +03:00
Evgeny Mankov 3408458f9f [HIPIFY] Fix string routines.
Some Clang tooling functions return std::string, some return StringRef. Assigning of returning std::string to StringRef variables leads to garbage in it.
DEBUG build is always affected.


[ROCm/hip commit: 25d470c380]
2017-05-11 21:50:36 +03:00
Evgeny Mankov dfbc039ebb [HIPIFY] LLVM 3.9 support
3.8 and 3.9 are both supported. 3.8 is stable, 3.9 needs more testing.


[ROCm/hip commit: 05be936fd6]
2017-05-05 21:28:02 +03:00
Evgeny Mankov 869dfcd01f [HIPIFY] CUDA RT memcpy functions update.
cudaMemcpyFromSymbol -> hipMemcpyFromSymbol
cudaMemcpyFromSymbolAsync -> hipMemcpyFromSymbolAsync
cudaMemcpy2DAsync -> hipMemcpy2DAsync


[ROCm/hip commit: 9b65358c68]
2017-05-03 23:05:44 +03:00
Evgeny Mankov 4841eb2bff [HIPIFY] Blas update: add a few functions, supported by HIP.
cublasDaxpy -> hipblasDaxpy
cublasDgemv -> hipblasDgemv
cublasDger  -> hipblasDger
cublasDgemm -> hipblasDgemm
cublasDgemmBatched -> hipblasDgemmBatched
cublasGetStream -> hipblasGetStream
cublasSetStream -> hipblasSetStream
cublasDaxpy -> hipblasDaxpy


[ROCm/hip commit: 1269897606]
2017-05-03 22:45:56 +03:00
Evgeny Mankov 115709ba28 [HIPIFY] HIPIFY and HIP sync with CUDA Driver API data types.
+ Update CUDA_Driver_API_functions_supported_by_HIP.md.
+ Final update of HIPIFY with CUDA driver data types.

[TODO] Syncing HIPIFY and HIP by CUDA Driver API functions.


[ROCm/hip commit: 70c94d7b83]
2017-05-03 21:59:48 +03:00
Evgeny Mankov d439bbd746 [HIPIFY] Rename enumConstantDecl -> enumDecl
Reason: not to mix up with clang's enumConstantDecl, used for enum DeclRefExpr (enum constant).


[ROCm/hip commit: c7958cbb8b]
2017-04-28 21:59:33 +03:00
Evgeny Mankov a83172c49b * [HIPIFY] [FIX] Replacement error: enum cudaMemcpyKind kind -> hipMemcpyKindyKind kind
https://github.com/GPUOpen-ProfessionalCompute-Tools/HIP/issues/72

[Solution] [Workaround]
Offset calculation for enum VarDecl as param decl, declared with enum type specifier.

[Result]
enum cudaMemcpyKind kind -> enum hipMemcpyKind kind

[ToDo]
Test on terminal qualifiers (const, etc).


[ROCm/hip commit: eddd021996]
2017-04-28 21:45:36 +03:00
Evgeny Mankov 4fe32b302f [HIPIFY] [FIX] replacement error: cudaError_t -> hipError_t_t
https://github.com/GPUOpen-ProfessionalCompute-Tools/HIP/issues/71

[Solution]
getUnqualifiedType for enumConstantDecl's type is added, except ordinary enum declarations (w/o typedef).

[ToDo]
Find more appropriate way of distinguishing redefined enum declarations and ordinary ones.


[ROCm/hip commit: 3d88932c8d]
2017-04-28 21:03:03 +03:00
Evgeny Mankov d4c04914d2 [HIPIFY] Initial sync HIPIFY with HIP by CUDA Driver API data types.
+ Introduce CUDA_Driver_API_functions_supported_by_HIP.md.
+ Initial update of HIPIFY with CUDA driver data types.
+ Initial sync HIP types against CUDA Driver and Runtime API types.
+ Typo fixes.


[ROCm/hip commit: 3c1dd246d6]
2017-04-21 21:46:30 +03:00
Evgeny Mankov b203f9f593 [HIPIFY] GGL support
+ hipLaunchKernel -> hipLaunchKernelGGL
+ macro HIP_KERNEL_NAME is no longer used


[ROCm/hip commit: 143e0af716]
2017-04-03 22:05:01 +03:00
Evgeny Mankov cdf0813551 [HIPIFY] Remove hipLaunchParm in HIP kernel declaration.
[ROCm/hip commit: 449d21b3c6]
2017-04-03 20:32:50 +03:00
Evgeny Mankov e4c4da05fd [HIP] [FIX] Fix GCC build.
[ROCm/hip commit: e34e5ef885]
2017-03-20 21:03:18 +03:00