Commit Graph

2829 Commits

Author SHA1 Message Date
Simeon Ehrig
2101f08450 Fix doxygen error. 2018-06-27 11:15:27 +02:00
Axel Naumann
ee37473807 Check file is C_User before hitting disk. Thanks, Vassil! 2018-06-26 13:44:18 +02:00
Axel Naumann
18bd806414 Only check pointers for Decls from writable dirs (ROOT-9377). 2018-06-25 12:59:56 +02:00
Axel Naumann
72feb2cc20 Move NullDerefProtectionTransformer into unnamed namesp. 2018-06-25 12:59:56 +02:00
Axel Naumann
4d17a6d9e2 Add GCC fallthrough comment, 80cols. 2018-06-25 11:29:07 +02:00
Axel Naumann
a0674d2d91 Add GCC fallthrough comment. 2018-06-25 11:29:07 +02:00
Simeon Ehrig
8c14ae786d Forgot header for clang build. 2018-06-25 08:29:08 +02:00
Simeon Ehrig
2e89e3a8ee Reformated the source code with clang-format. 2018-06-25 08:29:07 +02:00
Simeon Ehrig
8f832942fb Fix cuda template specialization bug.
Problem:
If a c++ statement with a concrete template parameter will type in, cling pass the (unwrapped) input line and the specialization of the statement, generated by compilerinstance to the clang nvptx. This causes an  explicit-specialization-after-instantiation-error.

Solution:
Template specialization declaration will be save two times at a transaction. Once with the type kCCIHandleCXXImplicitFunctionInstantiation and once with the type kCCIHandleTopLevelDecl. To avoid sending a template specialization to the clang nvptx and causing an explicit-specialization-after-instantiation-error it have to check, which kCCIHandleTopLevelDecl declaration is also a kCCIHandleCXXImplicitFunctionInstantiation declaration.
2018-06-25 08:29:07 +02:00
Simeon Ehrig
7c954c6273 Change clang nvptx input code selection.
As input of clang nvptx there are two possible sources. The raw input of `IncrementalParser::parseInternal()` or the AST-Printer of the `llvm::module`. Now, to decide, which input source should be use, I use the value `Transaction::ConsumerCallInfo::kCCIHandleTopLevelDecl`. This allows more C++ constructs to use.

Fixed a small bug. The AST-printer prints `setValueNoAlloc()` without the scope `cling::runtime::internal`. This caused an error, because clang could not find the declaration in the global space. The solution are dummy declaration in the global space.

At the moment, templates doesn't works.
2018-06-25 08:29:07 +02:00
Simeon Ehrig
9a4418b3c0 Improvements for Pull Request #240
- little changes at comments and code style
- try to use const in IncrementalCUDADeviceCompiler, where is possible
- move CUDA device code compiler instance to IncrementalParser
- change the members of CuArgs to const and adjust the setCuArgs method
- use std::vector<string> instead llvm::Smallvector<const char *> to build argv for executeAndWait
- improve the error messages of generatePCH(), generatePTX() and generateFatbinary()
- replace m_Counter with a copy in IncrementalCUDADeviceCompiler to avoid involuntary changes
2018-06-25 08:29:07 +02:00
Simeon Ehrig
309cebff41 Add function, to save faulty .cu files of CUDA device compiler.
Before this commit, the CUDA device code Compiler class overwrited source code .cu files, if the translation get wrong. Now, it renames the faulty files, so you can check, which source code cause compiler errors.
2018-06-25 08:29:07 +02:00
Simeon Ehrig
68cffbb853 Improve CUDA device code testcases. 2018-06-25 08:29:07 +02:00
Simeon Ehrig
d14ab2daec Improve the search of the clang instance for CUDA.
Before, it was not possible to find the clang++, which is contained in the cling, if we don't start the clang from the bin folder ('./cling -xcuda'). Now, for example it is possible to start the cling with 'bin/cling -xcuda' .

Fix a Bug, which avoid to start './cling -xcuda -fsyntax-only'.
2018-06-25 08:29:07 +02:00
Simeon Ehrig
2b61966c0d Fix temp-path bug.
In some cases, the path of the cling temp folder contains some non printable chars at the end.
Change the handling of the path string, to solve this problem.
2018-06-25 08:29:07 +02:00
simeon
b87dfcf9b1 Improve Error Message. 2018-06-25 08:29:07 +02:00
Simeon Ehrig
eb5cfc5f3f The CUDA compiler can handle variable declarations from the prompt.
Now, it is possible to declare variables on the prompt, which are visible for other statements.

The problems was, that cling wrapped all statements in a function, to get valid input. So, every variable is just visible inside in its own wrapper function. To solve the problem, cling change the local variable declaration to a global declaration.

The implementation for the CUDA compiler checks, if the unwrapping is happened. If it happened, the c++ code of the unwrapped variable declaration (AST-printer) instead the raw input will be written to the .cu-file.
2018-06-25 08:29:07 +02:00
Simeon Ehrig
c18f074cbd Add workaround for clang PCH-bug
At the moment, to extend the AST-tree of the device code, we use PCH-files to extend the exist device code with new lines of code. In detail, if we want to create a new PTX-file, we use the CUDA code (.cu file) and a PCH-file with the existing AST as input and generate an new PCH-file, which contains the whole AST. Then, the PCH-file will compiled to a PTX-file.

A bug in clang prevent, that we can’t generate more than 5 new PCH-files. The bug is not easy to fix, so I write a small workaround. Instead using a PCH-file, which contains the AST, we generate a new complete AST from all .cu-files every time.

The workaround is temporary and should removed, if clang is patched.
2018-06-25 08:29:07 +02:00
Simeon Ehrig
454c359c51 Setting the arguments of cling to clang nvptx and fatbinary are possible.
Now, it is possible to set some arguments of the clang nvptx and fatbinary via arguments at cling start. The arguments are filtered. So not every argument is possible at the moment. The Arguments can’t changed during runtime, because the PCH-files forbid it. For Example, the calng nvptx use the optimization level, which is set at start of cling.

At the moment, the debug options of clang nvptx are simple. If any debug option is detected, just a -g will add to the clang nvptx.

Additional PTX options for clang nvptx doesn’t works at the moment. There is a problem at parsing at the start of cling.
2018-06-25 08:29:07 +02:00
Simeon Ehrig
4882fbe886 Overwork of the include path handling of the CUDA device compiler.
I replaced copies of the include paths with a pointer to the headerSearchOptions. Now, explicit handling of the include paths is not more necessary. Add include paths, which was declared via argument at start also works.
2018-06-25 08:29:07 +02:00
Simeon Ehrig
58d99cf4f9 CUDA device compiler can use include paths from cling runtime.
This new function allows the CUDA device compiler to search after headers in folders, which was declared at runtime vie .I command.
2018-06-25 08:29:07 +02:00
Simeon Ehrig
6652d1a7c9 Add CUDA device compiler, which allows to generate CUDA PTX Code on runtime.
The class IncrementalCUDADeviceCompiler use external tools to generate PTX and cuda fatbin files. It runs the tools clang and fatbinary via llvm::sys::ExecuteAndWait. The class also handle to include new code in existing code. The steps of the compiler pipeline are:
- clang: CUDA C++ + previous PCH -> PCH
- clang: PCH -> PTX
- fatbinary: PTX -> fatbin

There is no selection of code. Every input of the cling will pass to the  IncrementalCUDADeviceCompiler.
2018-06-25 08:29:07 +02:00
Simeon Ehrig
90454f964a Added function to detect c++ attributes at function definition.
Now, it is possible to define functions with c++ attributes without the .rawInput mode. For example functions like `[[ noreturn ]] foo() { ... }` or `[[deprecated]] [[nodiscard]] int bar(){ … }`.
2018-06-19 13:44:58 +02:00
Yuka Takahashi
891b279bcc Revert "Revert "Add the cwg to the prebuilt module cache path." (#2160)"
This reverts commit 011aa8200277cd31957e222afd9b37415458b31f.

This is a revert of revert. I reverted the first commit because adding
"." to prebuiltmodulepath was causing failure in runtime modules, but
now we're skipping "." in TCling::LazyFunctionCreatorAutoloadForModule so
doesn't matter even if we have ".".
2018-06-12 22:59:08 +02:00
Yuka Takahashi
befa982fe3 Fix nightlies by autoload dependency libraries
We had test failures in runtime nightlies such as this one:
https://epsft-jenkins.cern.ch/view/ROOT/job/root-nightly-runtime-cxxmodules/95/BUILDTYPE=Debug,COMPILER=gcc62,LABEL=slc6/testReport/junit/projectroot.roottest.root.math/smatrix/roottest_root_math_smatrix_testKalman/

Failures were due to what @pcanal commented in #2135, that some so files in
roottest doesn't have external linkage. (It means that if you call
    dlopen(libfoo.so), linux kernel can't find dependency libraries and it
    emits "undefined symbol" error when they try to initialize global
    variables in libfoo.so but couldn't find symbol definition)
With pch, rootmap files were providing information about the depending library.

However we stopped generating rootmap files in #2127 and that's why we
got these failures. To fix this issue, I implemented a callback to
TCling which gets called when DynamicLibraryManager fails. The callback
pass error message to TCling and it handles message if it contains "undefined error".
2018-06-12 22:59:08 +02:00
Saagar Jha
d57fbe37d5 Handle Control+C and Control+D (mostly) correctly 2018-06-12 08:41:07 +02:00
Saagar Jha
68c93f9743 Fix unfortunate typo 2018-06-12 08:41:03 +02:00
Guilherme Amadio
cbaac95d07 Replace deprecated std::ptr_fun and std::mem_fun with equivalent code
Removed in C++17. No functionality change intended.
2018-06-12 08:40:00 +02:00
Bertrand Bellenot
a561c61888 disable unicode (UTF-8) in the console for the time being, since it causes problems on Windows 10 2018-06-12 08:40:00 +02:00
Raphael Isemann
345a13cef6 Don't assume fileno is a function.
This otherwise leads to compilation errors when we do `::fileno`
as OpenBSD implemented fileno as a macro (which seems to be allowed).
2018-06-12 08:40:00 +02:00
Bertrand Bellenot
ed135557e7 disambiguate the else branch 2018-06-12 08:40:00 +02:00
Bertrand Bellenot
c4990cff45 Fix uninitialized fDefaultAttributes (makes terminal black on black) 2018-06-12 08:40:00 +02:00
Yuka Takahashi
0d478d0fc4 Revert "Add the cwg to the prebuilt module cache path." (#2160)
This reverts commit 5298b418eec4129351888f41cb7c3bfc90161e22.

This commit was mistakenly committed. PR was opened in #1730, but it was
closed and moved to #1761. I didn't notice this and created another PR
in #1980.

This change was causing 100+ failures in runtime cxxmodules nightlies.
(Eg. https://epsft-jenkins.cern.ch/job/root-pullrequests-build/29183/testReport/junit/projectroot/runtutorials/tutorial_fit_FittingDemo/)
We want to have **proper** PrebuildModulesPaths which information were
extracted from LD_LIBRARY_PATH and DYLD_LIBRARY_PATH, not a random ".".

Because of this commit, we were trying to autoload libraries generated
by roottest on-demand (for example "./h1analysisTreeReader_C.so") This
is not an intentional behavior, these autogenerated libraries are
already loaded by roottest and what we want to do is to load **proper**
libraries like libHist.so instead.
2018-06-07 15:59:45 +02:00
Yuka Takahashi
35a8988d50 Autoload less libraries
In previous allmodules&autoloading patch, we used callback from
DeserializationListener to get Decl and loaded corresponding libraries.
It worked, but the performance was bad because ROOT was loading
excessive libraries.

In this patch, we use TCling::LazyFunctionCreatorAutoloadForModule. This
function gets callback when "mangled_name" was not found in loaded
libraries thus we have to the load corresponding library and lookup
again.

I used unordered_map to store mangled identifier and library pair. I'm
doing an optimization by hashing mangled name and storing library not by
name but by uint8 and hold uint8-name information in another vector.
Also tried std::map but unorderd_map was more performant. There are
better hash table like:
https://probablydance.com/2018/05/28/a-new-fast-hash-table-in-response-to-googles-new-fast-hash-table/
we can try to use them if this part gets crucial.

With this patch:
```
Processing tutorials/hsimple.C...
hsimple   : Real Time =   0.04 seconds Cpu Time =   0.03 seconds
(TFile *) 0x562b37a14fe0
Processing /home/yuka/CERN/ROOT/memory.C...
cpu  time = 0.362307 seconds
sys  time = 0.039741 seconds
res  memory = 278.215 Mbytes
vir  memory = 448.973 Mbytes
```

W/o this patch:
```
Processing tutorials/hsimple.C...
hsimple   : Real Time =   0.08 seconds Cpu Time =   0.07 seconds
(TFile *) 0x5563018a1d30
Processing /home/yuka/CERN/ROOT/memory.C...
cpu  time = 1.524314 seconds
sys  time = 0.157075 seconds
res  memory = 546.867 Mbytes
vir  memory = 895.184 Mbytes
```

So it improves time by 4x times and memory by 2x.
2018-06-02 10:44:38 +02:00
Axel Naumann
eb9fbe9f2c Unroll the pointer-check cache loop. 2018-05-24 23:14:32 +02:00
Axel Naumann
332a707e55 Allow passing of cling::Interpreter constructor flags. 2018-05-22 23:29:52 +02:00
Axel Naumann
7682a69042 Do not override preproc (un)defines if already set. 2018-05-22 23:29:52 +02:00
Axel Naumann
673a1d63a4 cling PR 233 (#2038)
Add llvm module pass to generate unique cuda module ctor/dtor names.

This llvm module pass address the follow problem. Every llvm module has a cuda ctor and dtor (if a cuda fatbinary exist), with at least a function call to register the fatbinary. The ctor/dtor can also include function calls to register global functions and variables at runtime, depending on user's code. The lazy compilation detects functions by the name. If the name (symbol) already exists it uses the existing translation. Otherwise it translates the function on first use (but it never translates twice). Without the module pass, Cling will always use the translation of the first module.

The testcase use the reflection of the gCling interpreter object. It takes two random modules and compare the symbols of the cuda module ctor and dtor.

Also add function, which change the symbol of the cuda module ctor and dtor to preprocessor compliant symbols.
2018-05-18 11:14:07 +02:00
Yuka Takahashi
98719ad352 Preloading modules and autoloading libraries by deserialized decls
Preloading all the modules has several advantages. 1. We do not have to
rely on rootmap files which don't support some features (namespaces and
templates) 2. Lookup would be faster because we don't have to do
trampoline via rootmap files.

Autoloading libraries when decls are deserialized gives us correctness.
However we still need to optimize the performance by reducing the amount
of loaded libraries and improving Clang performance.
2018-05-18 10:14:30 +02:00
Axel Naumann
3b7919436c Do not unload enum fwd decl but silence redecl diag (ROOT-9363 ROOT-9114).
Unloading the enum forward decl has tragic consequences e.g. for template
specializations relying on that decl (as template type parameter): the
enum definition will not be associated with teh forward decl, and any
subsequent template specialization will not recognize the type identity
of the enum forward declaration and its definition.

Instead, silence the diagnostic. This is not nice, but will be fixed by
C++ modules.
2018-05-16 16:00:04 +02:00
Axel Naumann
d3e070c663 Revert "Move enum attributes after "enum class X: int" (ROOT-9114)."
This reverts commit 42f889c02436107da57d45192951176892666083.
2018-05-16 16:00:04 +02:00
Vassil Vassilev
806c5685c7 Add the cwg to the prebuilt module cache path.
Some modules (produced by rootcling) are located in the cwg and they
should be resolved from there without being rebuilt.
2018-05-09 22:14:39 +02:00
Bertrand Bellenot
01fa534b71 Fix compilation errors on Windows
Fix compilation errors with the latest version of Visual Studio (15.7.0)
- Prevent compilation error G47C585C4: STL1000: Unexpected compiler version, expected Clang 6 or newer
- Fix exported symbols
2018-05-09 10:14:21 +02:00
Oksana Shadura
f8b6afcbb0 Fixing linking of Clang libraries for Cling and rootcling_stage1 in case of builtin_clang=OFF 2018-05-02 11:29:42 +02:00
Axel Naumann
2a60e2a750 Implicit array decay, some printValue-s need arrays! Fix value pointer calculation. 2018-04-30 16:29:42 +02:00
Axel Naumann
47dde3b27f Cache result of type transform. 2018-04-30 16:29:42 +02:00
Axel Naumann
ef2fc34520 Also allow char16, char32 for string value printing. 2018-04-26 12:14:31 +02:00
Axel Naumann
9d3e144814 Allow "same types" to be printed as const char*.
Fixes printing of std::string::c_str().
2018-04-26 12:14:31 +02:00
Axel Naumann
0793802867 Fix const char* printing, take 2. 2018-04-25 22:00:16 +02:00
Axel Naumann
edef97f368 Fix const char* printing! 2018-04-25 21:29:08 +02:00