tlds
Transactional Operations for Linked Data Structures
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
cxxtm.hpp
Go to the documentation of this file.
1 /**
2  * Copyright (C) 2011
3  * University of Rochester Department of Computer Science
4  * and
5  * Lehigh University Department of Computer Science and Engineering
6  *
7  * License: Modified BSD
8  * Please see the file LICENSE.RSTM for licensing information
9  */
10 
11 /**
12  * Strictly speaking, any TM-supporting C++ compiler will not need this
13  * file. However, if we want a program to be compilable with our library
14  * API, but also compilable with a TM C++ compiler, then we need to map the
15  * library calls to the calls the TM compiler expects.
16  *
17  * NB: Right now this only works with the Intel compiler
18  */
19 
20 #ifndef STM_API_CXXTM_HPP
21 #define STM_API_CXXTM_HPP
22 
23 // The prototype icc stm compiler version 4.0 doesn't understand transactional
24 // malloc and free without some help. The ifdef guard could be more intelligent.
25 #if defined(__ICC)
26 extern "C" {
27  [[transaction_safe]] void* malloc(size_t) __THROW;
28  [[transaction_safe]] void free(void*) __THROW;
29 }
30 #endif
31 
32 #define TM_CALLABLE [[transaction_safe]]
33 
34 #define TM_BEGIN(TYPE) __transaction [[TYPE]] {
35 #define TM_END }
36 
37 #define TM_WAIVER __transaction [[waiver]]
38 
39 #define TM_GET_THREAD()
40 #define TM_ARG
41 #define TM_ARG_ALONE
42 #define TM_PARAM
43 #define TM_PARAM_ALONE
44 
45 #define TM_READ(x) (x)
46 #define TM_WRITE(x, y) (x) = (y)
47 
48 namespace stm
49 {
50  /**
51  * Set the current STM algorithm/policy. This should be called at the
52  * beginning of each program phase
53  */
54  void set_policy(const char*);
55 
56  /*** Report the algorithm name that was used to initialize libstm */
57  const char* get_algname();
58 }
59 
60 #if defined(ITM) || defined(ITM2STM)
61 #include <common/platform.hpp> // nop()
62 
63 #define TM_SYS_INIT _ITM_initializeProcess
64 #define TM_THREAD_INIT _ITM_initializeThread
65 #define TM_THREAD_SHUTDOWN _ITM_finalizeThread
66 #define TM_SYS_SHUTDOWN _ITM_finalizeProcess
67 #define TM_ALLOC malloc
68 #define TM_FREE free
69 #if defined(ITM2STM)
70 #define TM_SET_POLICY(P) stm::set_policy(P)
71 #define TM_GET_ALGNAME() stm::get_algname()
72 #elif defined(ITM)
73 #define TM_SET_POLICY(P)
74 #define TM_GET_ALGNAME() "icc builtin libitm.a"
75 #endif
76 #define TM_BEGIN_FAST_INITIALIZATION nop
77 #define TM_END_FAST_INITIALIZATION nop
78 #else
79 #error "We're not prepared for your implementation of the C++ TM spec."
80 #endif
81 
82 #endif // API_CXXTM_HPP
Definition: stm_fraser.c:61
const char * get_algname()
Definition: txthread.cpp:386
void set_policy(const char *)
Definition: txthread.cpp:261