metacall_impl.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /* metacall_impl.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. * @file metacall_impl.h
  41. *
  42. * @brief Meta-function calls to be used within the Cilk runtime system.
  43. *
  44. * These differ from the macros in cilkscreen.h and cilkview.h because they go
  45. * through the __cilkrts_metacall interface, which ensures that the operation
  46. * is performed even when instrumentation is disabled.
  47. */
  48. #ifndef INCLUDED_CILKRTS_METACALL_H
  49. #define INCLUDED_CILKRTS_METACALL_H
  50. #include "rts-common.h"
  51. #include <internal/metacall.h>
  52. #include <cilk/common.h>
  53. __CILKRTS_BEGIN_EXTERN_C
  54. /**
  55. * This function is effectively an unconditional call from the runtime into
  56. * a tool. It is used for operations that must be performed by the tool,
  57. * even when the tool is not instrumenting. For example, Cilkscreen always
  58. * recognizes the address of this function and performs the action specified
  59. * in the contained metadata.
  60. *
  61. * Note that this function MUST NOT BE INLINED within the runtime. This must
  62. * be the ONLY instance of the cilkscreen_metacall metadata.
  63. */
  64. CILK_API_VOID
  65. __cilkrts_metacall(unsigned int tool, unsigned int code, void *data);
  66. /**
  67. * Return non-zero if running under Cilkscreen or Cilkview
  68. */
  69. COMMON_PORTABLE
  70. int __cilkrts_running_under_sequential_ptool(void);
  71. /**
  72. * Disable Cilkscreen implementation
  73. */
  74. #define __cilkrts_cilkscreen_disable_instrumentation() \
  75. __cilkrts_metacall(METACALL_TOOL_SYSTEM, HYPER_DISABLE_INSTRUMENTATION, 0)
  76. /**
  77. * Enable Cilkscreen implementation
  78. */
  79. #define __cilkrts_cilkscreen_enable_instrumentation() \
  80. __cilkrts_metacall(METACALL_TOOL_SYSTEM, HYPER_ENABLE_INSTRUMENTATION, 0)
  81. /**
  82. * Set the worker on entering runtime.
  83. *
  84. * @attention Deprecated in favor of __cilkrts_cilkscreen_ignore_block. The
  85. * begin/enter pairs in the current metadata mean Cilkscreen no longer has to
  86. * have improper knowledge of the __cilkrts_worker or __cilkrts_stack_frame
  87. * structures.
  88. */
  89. #define __cilkrts_cilkscreen_establish_worker(w) \
  90. __cilkrts_metacall(METACALL_TOOL_SYSTEM, HYPER_ESTABLISH_WORKER, w)
  91. /**
  92. * Notify Cilkscreen of the extent of the stack.
  93. *
  94. * @param[in] begin Start (low address) of stack
  95. * @param[in] end One past high address of stack
  96. */
  97. void __cilkrts_cilkscreen_establish_c_stack(char *begin, char *end);
  98. /**
  99. * Tell tools to ignore a block of memory - currently the global state and
  100. * memory allocated for workers.
  101. */
  102. #define __cilkrts_cilkscreen_ignore_block(_begin, _end) \
  103. { \
  104. void *block[2] = {_begin, _end}; \
  105. __cilkrts_metacall(METACALL_TOOL_SYSTEM, \
  106. HYPER_IGNORE_MEMORY_BLOCK, \
  107. block); \
  108. }
  109. __CILKRTS_END_EXTERN_C
  110. #endif /* ! defined(INCLUDED_CILKRTS_METACALL_H) */