Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UPC runtime: process config.h.cmake for each libupc runtime variant #1

Closed
swatanabe opened this issue Feb 20, 2013 · 0 comments
Closed
Assignees

Comments

@swatanabe
Copy link

I am in the process of upgrading the UPC runtime to the latest version in GUPC. That version has support for inter-node communications via a networking API called "portals4". It is enabled via a configure option. The choices are: (1) the current 'smp' runtime, or (2) the 'portals4' runtime. At some point in the future, we might try to unify these runtimes. Another improvement is re-licensing from FSF-assigned GPL licensing to BSD-licensing.

As a first cut, I copied over the new files, tweaked CMakelists.txt by adding the new 'smp' files to LIBUPC_SOURCES. I also copied the new 'config.h.in' onto 'config.h.make'. This, however, led to some build issues. The important diff's follow.

46a64,69

/* Whether UPC pointers-to-shared use the 'packed' representation */

undef GUPCR_PTS_PACKED_REP

/* Size of shared pointer's phase field (in bits) */

undef GUPCR_PTS_PHASE_SIZE

49a73,78
/* Whether UPC shared pointers use the 'struct' representation */

undef GUPCR_PTS_STRUCT_REP

/* Size of shared pointer's thread field (in bits) */

undef GUPCR_PTS_THREAD_SIZE

52a82,87
/* Whether the 'vaddr' field comes first (ie, [[vaddr,thread,phase]]) */

undef GUPCR_PTS_VADDR_FIRST

/* Size of shared pointer's vaddr field (in bits) */

undef GUPCR_PTS_VADDR_SIZE

57c92,95

< #define GUPCR_TREE_FANOUT @UPC_TREE_FANOUT@

undef GUPCR_TREE_FANOUT

/* Define to 1 if UPC runtime will use Portals4 triggered operations. */

undef GUPCR_USE_PORTALS4_TRIGGERED_OPS

After reading through the cmake logic, it seems that the version of config.h that is created from 'config.h.cmake' is built at the top-level of the libupc build structure, but is not built for each {packed,struct}-pts,{first,last}-vaddr variant. The variants pick up their values of 'GUPCR_PTS_PACKED_REP', etc. from the 'COMPILER_DEFINITIONS' property:

set_property(TARGET ${lib_name} PROPERTY COMPILE_DEFINITIONS ${lib_defs})

Then, for the runtime sources written 'upc', there is this logic in 'smp/upc-lib.in':

ifdef UPC_PTS_PACKED_REP

define GUPCR_PTS_PACKED_REP 1

elif defined(UPC_PTS_STRUCT_REP)

define GUPCR_PTS_STRUCT_REP 1

endif

The logic above is a divergence from the logic in the GUPC runtime, because there 'config.h.in' is customized by configure for each runtime variant.

Is the above summary correct?

In the short term, I can remove the explicit #undef of the various shared pointer format related definitions and let the existing cmake logic take care of it, but I am wondering if the logic might be reworked to be more similar to the method used by GUPC?

In a related matter, as shown in the diff's above, there is the cmake substitution that I need to bring back:

define GUPCR_TREE_FANOUT @UPC_TREE_FANOUT@

In general, however, there appear to be many few configuration-related definitions that are either tested by 'cmake' or that might be provided as cmake parameters. (I don't know the syntax for setting those parameters, however.) In particular, the portals4 runtime introduces some new configuration parameters. For example,

40a25,36

/* Size of get/put bounce buffer */

undef GUPCR_BOUNCE_BUFFER_SIZE

/* upc_global_exit() timeout in seconds. */

undef GUPCR_GLOBAL_EXIT_TIMEOUT

/* Define to 1 if UPC runtime checks are supported. */

undef GUPCR_HAVE_CHECKS

/* Define to 1 if UPC runtime debugging mode is enabled. */

undef GUPCR_HAVE_DEBUG

43a40,60
/* Define to 1 if UPC runtime statistics collection is supported. */

undef GUPCR_HAVE_STATS

/* Define to 1 if UPC runtime tracing is supported. */

undef GUPCR_HAVE_TRACE

/* Maximum number of locks held per thread */

undef GUPCR_MAX_LOCKS

/* Define to 1 if UPC runtime will use node local memory accesses. */

undef GUPCR_NODE_LOCAL_MEM

/* Define to 1 if UPC node local access uses mmap-ed file. */

undef GUPCR_NODE_LOCAL_MEM_MMAP

/* Define to 1 if UPC node local access uses Posix shared memory. */

undef GUPCR_NODE_LOCAL_MEM_POSIX

/* Portals4 PTE base index. */

undef GUPCR_PTE_BASE

Summarizing:

  1. I'd like to move the shared pointer characteristics back into config.h and have config.h customized for each runtime variant. Is that feasible?
  2. I'd like it config.h.cmake produced the same definitions as found in GUPC's config.h.in both in the configuration tests it runs and also by providing similar configuration-specific parameters.

When using cmake, is it sometimes possible to actually run configure as a way of making configuration tests? Or does cmake have another way of implementing configure-like checks?
Add

Subtasks
Add

Related issues

Issue #
Delay: days Cancel
History
#1

Updated by John Wiegley 3 months ago

* Assignee set to Steven Watanabe

#2

Updated by Gary Funck 3 months ago
Comment

I recently merged the current GUPC libgupc runtime into the Clang UPC runtime. Most of the problems encountered relate to the fact that config.h is not fully processed via configure and is not instantiated for each runtime variant.

This web page summarizes the key differences:
[[http://gccupc.org/clang-upc-runtime-mods/]]

While going through the process of updating the runtime, I discovered a couple other differences that I will summarize here, but that might be logically separated out into other issues.

  1. In GUPC, there is a file named gcc-upc-lib.in that is pre-processed by a script to produce a header file, gcc-upc-lib.h . However, in Clang it is renamed to upc-lib.in and then pre-processed into upc-lib.h.
  2. In GUPC, gcc-upc-lib.h is #included from a file named include/gcc-upc.h. In GUPC, gcc-upc.h is pre-included by the gupc command.
  3. In Clang UPC, gcc-upc.h appears to be un-used.
  4. In Clang UPC, upc-lib.h is pre-included by the clang command when compiling UPC programs, only when the driver has determined that the runtime should be inlined.

Thus in addition to fully processing config.h.in and customizing it to each runtime variant, it appears that gcc-upc.h should be unconditionally pre-included (as this is the way that gupc works). This in turn will include gcc-upc-lib.h.

A note regarding the rename of gcc-upc-lib.in to upc-lib.in: Although there is some logic in doing that, it does make the task of tracking changes between gupc and clang upc more difficult.
#3

Updated by Steven Watanabe 3 months ago
Comment

  1. I'm not sure that moving the #defines back into config.h will help.
    The real problem is that you're trying to use the same file for
    config.h.in and config.h.cmake. Unfortunately, CMake uses a different
    syntax than autoconf, so this isn't really going to work.

  2. CMake has its own method of running configuration tests. I just didn't implement it, because it worked without on the platforms we tested with. I don't know of a way for CMake to use the autotools script (It may be possible, but I doubt that there's an easy way--running configure and parsing the output doesn't seem like a very good idea.).
    UPC runtime (libupc) build failure with newer cmake (2.8.10.2) #4

    Updated by Gary Funck 3 months ago

Updated by Steven Watanabe 3 months ago

* Status changed from New to In Progress

#6

Updated by Steven Watanabe 2 months ago
Comment

The following macros in config.h are apparently unused. I'm assuming that it's okay just to remove them.

HAVE_AS_SYMVER_DIRECTIVE
HAVE_ATTRIBUTE_ALIAS
HAVE_ATTRIBUTE_DLLEXPORT
HAVE_ATTRIBUTE_VISIBILITY
HAVE_BACKTRACE
HAVE_BACKTRACE SYMBOLS
HAVE_BACKTRACE_SYMBOLS_FD
HAVE_BROKEN_POSIX_SEMAPHORES
HAVE_CC_TLS
HAVE_DECL_SYS_SIGLIST
HAVE_DLFCN_H
HAVE_FCNTL_H
HAVE_FORK
HAVE_FTRUNCATE
HAVE_GETCWD
HAVE_GETHOSTBYNAME
HAVE_GETLOADAVG
HAVE_GETPAGESIZE
HAVE_GTHR_DEFAULT
HAVE_INTTYPES_H
HAVE_MALLOC
HAVE_MEMORY_H
HAVE_MEMSET
HAVE_MKDIR
HAVE_MMAP
HAVE_MUNMAP
HAVE_NETDB_H
HAVE_NETINET_IN_H
HAVE_PTHREAD_AFFINITY_NP
HAVE_PTRDIFF_T
HAVE_SCHED_H
HAVE_SEMAPHORE_H
HAVE_SOCKET
HAVE_STAT_EMPTY_STRING_BUG
HAVE_STDDEF_H
HAVE_STDINT_H
HAVE_STDLIB_H
HAVE_STRCASECMP
HAVE_STRDUP
HAVE_STRERROR
HAVE_STRINGS_H
HAVE_STRING_H
HAVE_STRTOL
HAVE_STRTOULL
HAVE_SYNC_BUILTINS
HAVE_SYS_LOADAVG_H
HAVE_SYS_SOCKET_H
HAVE_SYS_STAT_H
HAVE_SYS_TYPES_H
HAVE_TYPE_WAIT_H
HAVE_TLS
HAVE_UNISTD_H
HAVE_VFORK
HAVE_VFORK_H
HAVE_WORKING_FORK
HAVE_WORKING_VFORK
LIBGUPC_GNU_SYMBOL_VERSIONING
LSTAT_FOLLOWS_SLASHED_SYMLINK
LT_OBJDIR
PACKAGE
PACKAGE_NAME
PACKAGE_STRING
PACKAGE_TARNAME
PACKAGE_URL
PACKAGE_VERSION
SIZEOF_CHAR
SIZEOF_INT
SIZEOF_LONG
SIZEOF_SHORT
SIZEOF_VOID_P
STDC_HEADERS
STRING_WITH_STRINGS
VERSION
#7

Updated by Gary Funck 2 months ago
Comment

Steven Watanabe wrote:

The following macros in config.h are apparently unused.
I'm assuming that it's okay just to remove them.

Yes. That's OK. We have a tendency to add (or inherit) autoconf tests that we don't use.
#8

Updated by Steven Watanabe 2 months ago
Comment

Where can I find portals4?
#9

Updated by Steven Watanabe 2 months ago
Comment

I'm not sure that specializing config.h for each build variant is feasible.
config.h is one of the sources for gcc-upc-lib.h, and I'd really rather avoid specializing gcc-upc-lib.h as this would mean extra logic to #include the correct file depending on the compiler options.
#10

Updated by Gary Funck 2 months ago
Comment

Steven Watanabe wrote:

Where can I find portals4?

I will send you a "how to" under separate cover.
#11

Updated by Gary Funck 2 months ago
Comment

Steven Watanabe wrote:

I'm not sure that specializing config.h for each build variant is feasible.
config.h is one of the sources for gcc-upc-lib.h, and I'd really rather avoid specializing gcc-upc-lib.h as this would mean extra logic to #include the correct file depending on the compiler options.

We may need to discuss this in a telecon, so that I can be sure that I understand the issues.

However we do it, the goal is for the libgupc runtime sources (the non-make/config related files) to match those in the clang libupc directory. I don't think that Intrepid wants to use the approach used in the clang runtime, but perhaps there is a middle ground some where.

@ghost ghost assigned swatanabe Feb 20, 2013
vitillo pushed a commit to vitillo/clang-upc that referenced this issue Sep 14, 2013
1. Use a hanging ident for function calls nested in binary expressions.
   E.g.:
   int aaaaa = aaaaaaaaa && aaaaaaaaaa(
                                aaaaaaaaaa);

2. Slightly improve heuristic for builder type expressions and reduce
   penalty for breaking before "." and "->" in those.

3. Remove  mostly obsolete metric of decreasing indent level. This
   fixes: llvm.org/PR14931.

Changes clangupc#1 and clangupc#2 were necessary to keep tests passing after clangupc#3.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173680 91177308-0d34-0410-b5e6-96231b3b80d8
vitillo pushed a commit to vitillo/clang-upc that referenced this issue Sep 14, 2013
Sample output:
  #0 void construct(pointer __p, llvm::ImutAVLTree<llvm::ImutContainerInfo<clang::ento::BugType *> > *const &__val)
  clangupc#1 void push_back(const value_type &__x)
  clangupc#2 void destroy()
  clangupc#3 void release()
  clangupc#4 void ~ImmutableSet()

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178400 91177308-0d34-0410-b5e6-96231b3b80d8
vitillo pushed a commit to vitillo/clang-upc that referenced this issue Sep 14, 2013
Function declarations are now broken with the following preferences:
1) break amongst arguments.
2) break after return type.
3) break after (.
4) break before after nested name specifiers.

Options clangupc#2 or clangupc#3 are preferred over clangupc#1 only if a substantial number of
lines can be saved by that.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179287 91177308-0d34-0410-b5e6-96231b3b80d8
vitillo pushed a commit to vitillo/clang-upc that referenced this issue Sep 14, 2013
a lambda.

Bug clangupc#1 is that CGF's CurFuncDecl was "stuck" at lambda invocation
functions.  Fix that by generally improving getNonClosureContext
to look through lambdas and captured statements but only report
code contexts, which is generally what's wanted.  Audit uses of
CurFuncDecl and getNonClosureAncestor for correctness.

Bug clangupc#2 is that lambdas weren't specially mapping 'self' when inside
an ObjC method.  Fix that by removing the requirement for that
and using the normal EmitDeclRefLValue path in LoadObjCSelf.

rdar://13800041

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181000 91177308-0d34-0410-b5e6-96231b3b80d8
vitillo pushed a commit to vitillo/clang-upc that referenced this issue Sep 26, 2013
…86_64-unknown-unknown.

It would emit @llvm.memcpy with "-triple x86_64-(mingw32|win32)" and had been failing since Nick's r185735.

  ; Function Attrs: nounwind
  declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture readonly, i64, i32, i1) clangupc#1

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185796 91177308-0d34-0410-b5e6-96231b3b80d8
vitillo pushed a commit to vitillo/clang-upc that referenced this issue Sep 26, 2013
Sample output:

0.     Program arguments: ...
1.     <eof> parser at end of file
2.     While analyzing stack:
       #0 void inlined()
       clangupc#1 void test()
3.     crash-trace.c:6:3: Error evaluating statement

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186639 91177308-0d34-0410-b5e6-96231b3b80d8
@nenadv nenadv closed this as completed Feb 14, 2014
swatanabe pushed a commit that referenced this issue Jan 30, 2015
Due to what can only be described as a CRT bug, stdout and amazingly
even stderr are not always flushed upon process termination, especially
when the system is under high threading pressure.  I have found two
repros for this:

1) In lib\Support\Threading.cpp, change sys::Mutex to an
std::recursive_mutex and run check-clang.  Usually between 30 and 40
tests will fail.

2) Add OutputDebugStrings in code that runs during static initialization
and static shutdown.  This will sometimes generate similar failures.

After a substantial amount of troubleshooting and debugging, I found
that I could reproduce this from the command line without running
check-clang.  Simply make the mutex change described in #1, then
manually run the following command many times by running it once, then
pressing Up -> Enter very quickly:

D:\src\llvm\build\vs2013\Debug\bin\c-index-test.EXE -cursor-at=D:\src\llvm\tools\clang\test\Index\targeted-preamble.h:2:15 D:\src\llvm\tools\clang\test\Index\targeted-cursor.c -include D:\src\llvm\build\vs2013\tools\clang\test\Index\Output\targeted-cursor.c.tmp.h -Xclang -error-on-deserialized-decl=NestedVar1      -Xclang -error-on-deserialized-decl=TopVar    | D:\src\llvm\build\vs2013\Debug\bin\FileCheck.EXE D:\src\llvm\tools\clang\test\Index\targeted-cursor.c -check-prefix=PREAMBLE-CURSOR1

Sporadically they will fail, and attaching a debugger to a failed
instance indicates that stdin of FileCheck.exe is empty.

Note that due to the repro in #2, we can rule out a bug in the STL's
mutex implementation, and instead conclude that this is a real flake in
the windows test harness.

Test Plan:
Without patch: Ran check-clang 10 times and saw over 30 Unexpected failures on every run.
With patch: Ran check-clang 10 times and saw 0 unexpected failures across all runs.

Reviewers: rnk

Differential Revision: http://reviews.llvm.org/D4021

Patch by Zachary Turner!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@210225 91177308-0d34-0410-b5e6-96231b3b80d8
swatanabe pushed a commit that referenced this issue Mar 11, 2017
Summary:
The switch statement could be added to the hasCondition matcher.

Example:
```
clang-query> match switchStmt(hasCondition(ignoringImpCasts(declRefExpr())))
```

Output:
```
Match #1:

Binding for "root":
SwitchStmt 0x2f9b528 </usr/local/google/home/etienneb/examples/enum.cc:35:3, line:38:3>
|-<<<NULL>>>
|-ImplicitCastExpr 0x2f9b510 <line:35:11> 'int' <IntegralCast>
| `-ImplicitCastExpr 0x2f9b4f8 <col:11> 'enum Color' <LValueToRValue>
|   `-DeclRefExpr 0x2f9b4d0 <col:11> 'enum Color' lvalue Var 0x2f9a118 'C' 'enum Color'
`-CompoundStmt 0x2f9b610 <col:14, line:38:3>
  |-CaseStmt 0x2f9b578 <line:36:3, col:22>
  | |-ImplicitCastExpr 0x2f9b638 <col:8> 'int' <IntegralCast>
  | | `-DeclRefExpr 0x2f9b550 <col:8> 'enum Size' EnumConstant 0x2f99e40 'Small' 'enum Size'
  | |-<<<NULL>>>
  | `-ReturnStmt 0x2f9b5d0 <col:15, col:22>
  |   `-IntegerLiteral 0x2f9b5b0 <col:22> 'int' 1
  `-DefaultStmt 0x2f9b5f0 <line:37:3, col:12>
    `-BreakStmt 0x2f9b5e8 <col:12>

1 match.
```

Reviewers: aaron.ballman, sbenza, klimek

Subscribers: klimek, cfe-commits

Differential Revision: http://reviews.llvm.org/D20767

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@271208 91177308-0d34-0410-b5e6-96231b3b80d8
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

No branches or pull requests

2 participants