1/* cilkscreen.h -*-C++-*- 2 * 3 ************************************************************************* 4 * 5 * @copyright 6 * Copyright (C) 2010-2013, Intel Corporation 7 * All rights reserved. 8 * 9 * @copyright 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 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 19 * distribution. 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. 23 * 24 * @copyright 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. 37 * 38 **************************************************************************/ 39 40#ifndef INCLUDED_CILKSCREEN_H 41#define INCLUDED_CILKSCREEN_H 42 43#include <cilk/cilk_api.h> 44 45/* 46 * Cilkscreen "functions". These macros generate metadata in your application 47 * to notify Cilkscreen of program state changes 48 */ 49 50#if ! defined(CILK_STUB) && defined(__INTEL_COMPILER) 51# define __cilkscreen_metacall(annotation,expr) \ 52 __notify_zc_intrinsic((char *)annotation, expr) 53#else 54# define __cilkscreen_metacall(annotation,expr) ((void)annotation, (void)(expr)) 55#endif 56 57/* Call once when a user thread enters a spawning function */ 58#define __cilkscreen_enable_instrumentation() \ 59 __cilkscreen_metacall("cilkscreen_enable_instrumentation", 0) 60 61/* Call once when a user thread exits a spawning function */ 62#define __cilkscreen_disable_instrumentation() \ 63 __cilkscreen_metacall("cilkscreen_disable_instrumentation", 0) 64 65/* Call to temporarily disable cilkscreen instrumentation */ 66#define __cilkscreen_enable_checking() \ 67 __cilkscreen_metacall("cilkscreen_enable_checking", 0) 68 69/* Call to re-enable temporarily-disabled cilkscreen instrumentation */ 70#define __cilkscreen_disable_checking() \ 71 __cilkscreen_metacall("cilkscreen_disable_checking", 0) 72 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) \ 76 do { \ 77 void *__data[2] = { (begin), (end) }; \ 78 __cilkscreen_metacall("cilkscreen_clean", &__data); \ 79 } while(0) 80 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. 85 */ 86#define __cilkscreen_acquire_lock(lock) \ 87 __cilkscreen_metacall("cilkscreen_acquire_lock", (lock)) 88 89#define __cilkscreen_release_lock(lock) \ 90 __cilkscreen_metacall("cilkscreen_release_lock", (lock)) 91 92/* 93 * Metacall data 94 * 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. 97 */ 98 99// Tool code for Cilkscreen 100#define METACALL_TOOL_CILKSCREEN 1 101 102// Metacall codes implemented by Cilkscreen 103#define CS_METACALL_PUTS 0 // Write string to the Cilkscreen log 104 105#define __cilkscreen_puts(text) \ 106 __cilkrts_metacall(METACALL_TOOL_CILKSCREEN, CS_METACALL_PUTS, (void *)(const char *)text) 107 108#endif /* defined(INCLUDED_CILKSCREEN_H) */ 109