Commit Graph

1972 Commits

Author SHA1 Message Date
Chris Kitching 803d3ffd9c 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.
2017-10-24 20:38:25 +01:00
Evgeny Mankov 4e78738267 Merge pull request #230 from emankov/master
[HIPIFY][fix] cmake: NO_DEFAULT_PATH is strongly needed in find_package for LLVM
2017-10-24 20:44:56 +03:00
Evgeny Mankov cbb772c3ab Merge pull request #224 from ChrisKitching/tests
[HIPIFY] Make the automated tests more useful
2017-10-24 20:12:36 +03:00
Evgeny Mankov 712a1da073 Merge branch 'master' into tests 2017-10-24 20:03:51 +03:00
Evgeny Mankov 7b307b21d1 Merge pull request #227 from ChrisKitching/clang-silly
Tweak some version numbers in clang version compatibility checks
2017-10-24 17:16:07 +03:00
Evgeny Mankov 4a0228cedb [HIPIFY][fix] cmake: NO_DEFAULT_PATH is strongly needed in find_package for LLVM
Otherwise LLVM will be searched in system folders.
2017-10-24 16:35:10 +03:00
Maneesh Gupta e324e77184 Merge pull request #225 from emankov/master
[HIPIFY] cmake: fix standalone build
2017-10-24 17:06:51 +05:30
Evgeny Mankov 7c51376bbf [HIPIFY][fix] cmake: do not build hipify-clang if not asked
+ warn "hipify-clang will not be built" if HIPIFY_CLANG_LLVM_DIR is not specified.
+ fix typo in previous commit .
2017-10-24 14:16:05 +03:00
emankov 559d9a68aa [HIPIFY] cmake: simplify build 2017-10-24 10:51:11 +03:00
Chris Kitching aa288fcf1f Tweak some version numbers in clang version compatibility checks
Apparently a couple of those APIs changed in clang 5, not 4.

Drat.
2017-10-24 01:45:23 +01:00
Evgeny Mankov cdd849541f [HIPIFY] cmake: fix standalone build 2017-10-23 21:16:13 +03:00
Chris Kitching 2c65d0da37 Add concurentKernels.cu to the testsuite 2017-10-23 13:39:37 +01:00
Chris Kitching 64d5f07050 Add the CUDA samples include dir to the path for tests
Means we get to easily steal CUDA examples for tests
2017-10-23 13:39:37 +01:00
Chris Kitching 2437b31939 Add cudaRegister.cu lit test 2017-10-23 13:39:37 +01:00
Chris Kitching ead79e5bf4 Add square.cu to lit testsuite 2017-10-23 13:39:37 +01:00
Chris Kitching c99dcbba8d Introduce a test runner script to simplify invocation
... And to use a standard, highly amusing trick for making
coloured output work.
2017-10-23 13:39:37 +01:00
Chris Kitching 5912f465bd Adapt lit test for the hipLaunchKernelGGL changes from before... 2017-10-23 13:39:37 +01:00
Chris Kitching 74fd64d5c1 Migrate lit test to using FileCheck, so failures are readable
It seems the test is already broken, but look how awesome the
error message is now:

/home/chris/HIP/tests/hipify-clang/axpy.cu:31:12: error: expected string not found in input
 // CHECK: hipLaunchKernel(HIP_KERNEL_NAME(axpy), dim3(1), dim3(kDataLen), 0, 0, a, device_x, device_y);
           ^
<stdin>:31:2: note: scanning from here
 //
 ^
<stdin>:33:2: note: possible intended match here
 hipLaunchKernelGGL(axpy, dim3(1), dim3(kDataLen), 0, 0, a, device_x, device_y);
 ^
2017-10-23 13:39:37 +01:00
Chris Kitching 3868036ea7 Look for FileCheck for running lit tests, too
Use of grep in `lit` RUN lines is deprecated:
https://llvm.org/docs/TestingGuide.html#writing-new-regression-tests

Using grep leads to really unhelpful failure output (it literally
just says "the test failed"). FileCheck is much more helpful, and
distributed with LLVM on most distros anyway, so this extra
dependency shouldn't prove problematic.
2017-10-23 13:39:36 +01:00
Chris Kitching 9747578d09 Propagate the CUDA toolkit directory into the lit tests
Allows the tests to actually run... :D
2017-10-23 13:39:36 +01:00
Chris Kitching e9d259699c Remove dependency on nonexistent lit target
This just... isn't a target. Maybe you were trying to do a file
dependency? But that's handled implicitly by the find_program
call anyway, so all this is doing is generating a cmake warning
2017-10-23 13:39:36 +01:00
Evgeny Mankov 9dec691dbf Merge pull request #219 from ChrisKitching/newClang
[HIPIFY] Migrate hipify-clang to a newer version of clang
2017-10-21 11:59:46 +03:00
Ben Sander 326651875d Merge pull request #214 from scchan/reinit_printf_buffer
hipDeviceReset(): make sure to reinitialize the printf buffer in hcc RT
2017-10-20 11:04:37 -05:00
Chris Kitching 893ee6d6ca 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.
2017-10-19 17:09:32 +01:00
Chris Kitching a06fe54ee8 Be agnostic to the new getReplacements() API
See comment
2017-10-19 17:08:55 +01:00
Chris Kitching 9d83348ac7 Use inline initialisers to set default field values
A trivial cleanup that helps in a moment..
2017-10-19 17:08:55 +01:00
Chris Kitching abd34b2125 Omit now-removed Filename string arg from handleBeginSource 2017-10-19 17:08:55 +01:00
Chris Kitching 885573e1e2 Cope with Replacements now having llvm::Error returns 2017-10-19 17:08:54 +01:00
Chris Kitching 9ccb966e2b Cope with clang 4.0's rename of getNumArgs()
Sorry, this one I couldn't do in a perfectly elegant way ;)
2017-10-19 17:08:54 +01:00
Chris Kitching 22a5e2330d 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.
2017-10-19 17:08:54 +01:00
Chris Kitching 73984ed809 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.
2017-10-19 17:08:54 +01:00
Chris Kitching c876f6ffd5 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...
2017-10-19 17:08:54 +01:00
Chris Kitching ed6681f563 Use the cache for global variables - not PARENT_SCOPE hacks 2017-10-19 17:08:54 +01:00
Chris Kitching 6abd8963ae Skip lit tests if lit cannot be found 2017-10-19 17:08:54 +01:00
Chris Kitching c62766f880 Don't reinvent find_package
PythonInterp is a finder module that ships with cmake. It supports
the conventional interaction with find_package that allows you
to demand success, and particular vesions, without having your
own logic:

https://cmake.org/cmake/help/v3.0/command/find_package.html
2017-10-19 17:08:53 +01:00
Chris Kitching 03dd8c9fca Don't be picky about clang versions 2017-10-19 17:08:53 +01:00
Chris Kitching b926cdf002 Declare HIPIFY_CLANG_TESTS as a cmake option 2017-10-19 17:08:53 +01:00
Chris Kitching d3a5646051 Use early return to avoid indenting all of CMakeLists.txt 2017-10-19 17:08:53 +01:00
Chris Kitching 72c9767b1d Fix broken indentation introduced by previous commit 2017-10-19 17:08:53 +01:00
Evgeny Mankov c648621510 Merge pull request #217 from ChrisKitching/cxx
[HIPIFY] Don't reject C++ > 11 language features
2017-10-19 17:38:18 +03:00
Chris Kitching 6165b65d21 Inline a redundant std::vector
Looks like a partial refactor..?
2017-10-19 14:11:25 +01:00
Chris Kitching 90b04f696b Allow user-provided -std=* argument to override the default
This means any user-provided -std=* argument overrides this one,
allowing use of newer standards.
2017-10-19 14:11:15 +01:00
Siu Chi Chan a1956f64e6 hipDeviceReset(): make sure to reinitialize the printf buffer in hcc RT 2017-10-18 16:26:13 -04:00
Evgeny Mankov 6cfa73a7da Merge pull request #210 from ChrisKitching/output-hipify
[HIPIFY] Alter output file behaviour slightly
2017-10-18 21:46:31 +03:00
Chris Kitching dbbd6d576d Unconditionally append .hip as the default output filename 2017-10-18 19:19:18 +01:00
Evgeny Mankov 69b1b91311 Merge pull request #195 from emankov/master
[HIPIFY] CUDA RT Textures and Arrays support update
[HIPIFY] cmake changes
[HIPIFY][#199][Partial fix] Fix for cudaLaunchKernel transformation
2017-10-17 18:21:28 +03:00
Chris Kitching 14061bf0e6 If an output path is given _use it_
Don't append .hip to a user-provided output file...
2017-10-16 17:32:57 +01:00
Chris Kitching bd8a90a05b 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
2017-10-16 17:32:56 +01:00
Evgeny Mankov f3ef942407 [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.
2017-10-12 20:05:42 +03:00
Evgeny Mankov ff38a484af [HIPIFY] cmake changes
+ standalone build support
+ WIN MSVC support
+ disable lit testing by default
+ to enable lit testing -DHIPIFY_CLANG_TESTS=1 should be specified

Tested builds:
+ hipify-clang standalone           {Ubuntu 16.04|Windows 10} {Debug|Release} {x86|x64a} {g++|clang++|MSVC 2017} {llvm 3.8.0|llvm 3.9.0} {-DHIPIFY_CLANG_TESTS=1| }
+ HIP {-DHIPIFY_CLANG_LLVM_DIR=..|} {Ubuntu 16.04}            {Debug|Release} {x86|x64a} {hcc}                   {llvm 3.8.0|llvm 3.9.0} {-DHIPIFY_CLANG_TESTS=1| }
2017-10-09 20:28:20 +03:00