1 /* cilkscreen.h -*-C++-*-
3 *************************************************************************
6 * Copyright (C) 2010-2013, Intel Corporation
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
14 * * Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * * Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in
18 * the documentation and/or other materials provided with the
20 * * Neither the name of Intel Corporation nor the names of its
21 * contributors may be used to endorse or promote products derived
22 * from this software without specific prior written permission.
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
30 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
31 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
32 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
33 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
35 * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
38 **************************************************************************/
40 #ifndef INCLUDED_CILKSCREEN_H
41 #define INCLUDED_CILKSCREEN_H
43 #include <cilk/cilk_api.h>
46 * Cilkscreen "functions". These macros generate metadata in your application
47 * to notify Cilkscreen of program state changes
50 #if ! defined(CILK_STUB) && defined(__INTEL_COMPILER)
51 # define __cilkscreen_metacall(annotation,expr) \
52 __notify_zc_intrinsic((char *)annotation, expr)
54 # define __cilkscreen_metacall(annotation,expr) ((void)annotation, (void)(expr))
57 /* Call once when a user thread enters a spawning function */
58 #define __cilkscreen_enable_instrumentation() \
59 __cilkscreen_metacall("cilkscreen_enable_instrumentation", 0)
61 /* Call once when a user thread exits a spawning function */
62 #define __cilkscreen_disable_instrumentation() \
63 __cilkscreen_metacall("cilkscreen_disable_instrumentation", 0)
65 /* Call to temporarily disable cilkscreen instrumentation */
66 #define __cilkscreen_enable_checking() \
67 __cilkscreen_metacall("cilkscreen_enable_checking", 0)
69 /* Call to re-enable temporarily-disabled cilkscreen instrumentation */
70 #define __cilkscreen_disable_checking() \
71 __cilkscreen_metacall("cilkscreen_disable_checking", 0)
73 /* Inform cilkscreen that memory from begin to end can be reused without
74 * causing races (e.g., for memory that comes from a memory allocator) */
75 #define __cilkscreen_clean(begin, end) \
77 void *__data[2] = { (begin), (end) }; \
78 __cilkscreen_metacall("cilkscreen_clean", &__data); \
81 /* Inform cilkscreen that a lock is being acquired.
82 * If the lock type is not a handle, then the caller should take its address
83 * and pass the pointer to the lock. Otherwise, the caller should pass the
84 * lock handle directly.
86 #define __cilkscreen_acquire_lock(lock) \
87 __cilkscreen_metacall("cilkscreen_acquire_lock", (lock))
89 #define __cilkscreen_release_lock(lock) \
90 __cilkscreen_metacall("cilkscreen_release_lock", (lock))
95 * A metacall is a way to pass data to a function implemented by a tool.
96 * Metacalls are always instrumented when the tool is loaded.
99 // Tool code for Cilkscreen
100 #define METACALL_TOOL_CILKSCREEN 1
102 // Metacall codes implemented by Cilkscreen
103 #define CS_METACALL_PUTS 0 // Write string to the Cilkscreen log
105 #define __cilkscreen_puts(text) \
106 __cilkrts_metacall(METACALL_TOOL_CILKSCREEN, CS_METACALL_PUTS, (void *)(const char *)text)
108 #endif /* defined(INCLUDED_CILKSCREEN_H) */