usermode/library/configuration/mtm.py

00001 import os
00002 import string
00003 import SCons.Environment
00004 from SCons.Script import ARGUMENTS, Dir
00005 from SCons.Variables import Variables, EnumVariable, BoolVariable
00006 import helper
00007 import mnemosyne
00008 
00009 class Environment(mnemosyne.Environment):
00010         """
00011                 A specialization of the SCons Environment class which does some particular
00012                 munging of the build variables needed in the source files.
00013         """
00014         
00015         def __init__(self, mainEnv, configuration_name = 'default'):
00016                 """
00017                         Applies the definitions in configuration_name to generate a correct
00018                         environment (specificall the set of compilation flags() for the
00019                         TinySTM library. That environment is returned
00020                 """
00021                 mnemosyne.Environment.__init__(self, mainEnv, configuration_name)
00022                 
00023                 # Generate build directives 
00024                 directives = helper.Directives(configuration_name, 'mtm', ARGUMENTS, self._boolean_directive_vars, self._enumerable_directive_vars, self._numerical_directive_vars)
00025 
00026 
00027                 # Bring in appropriate environment variables and preprocessor definitions.
00028                 # Note: the inclusion of the OS environment reportedly threatens to make
00029                 # this build more brittle, but otherwise I have to write an SCons builder
00030                 # for libatomic_ops as well. Instead, I let the system paths make it
00031                 # visible and assume that the user has installed libatomic_ops themselves.
00032                 if ('INCLUDE' in os.environ):
00033                         osinclude = string.split(os.environ['INCLUDE'], ':')
00034                 else:
00035                         osinclude = []
00036                 self.Append(
00037                         CPPDEFINES = directives.getPreprocessorDefinitions(),
00038                         CPPPATH = ['include'] + osinclude,
00039                         ENV = os.environ)
00040 
00041 
00042         #: BUILD DIRECTIVES
00043 
00044         #: Build directives which are either on or off.
00045         _boolean_directive_vars = [
00046                 ('ROLLOVER_CLOCK',           'Roll over clock when it reaches its maximum value.  Clock rollover can be safely disabled on 64 bits to save a few cycles, but it is necessary on 32 bits if the application executes more than 2^28 (write-through) or 2^31 (write-back) transactions.',
00047                         True),
00048                 ('CLOCK_IN_CACHE_LINE',      'Ensure that the global clock does not share the same cache line than some other variable of the program.  This should be normally enabled.',
00049                         True),
00050                 ('NO_DUPLICATES_IN_RW_SETS', 'Prevent duplicate entries in read/write sets when accessing the same address multiple times.  Enabling this option may reduce performance so leave it disabled unless transactions repeatedly read or write the same address.',
00051                         True),
00052                 ('WAIT_YIELD',               'Yield the processor when waiting for a contended lock to be released. This only applies to the CM_WAIT and CM_PRIORITY contention managers.',
00053                         True),
00054                 ('EPOCH_GC',                 'Use an epoch-based memory allocator and garbage collector to ensure that accesses to the dynamic memory allocated by a transaction from another transaction are valid.  There is a slight overhead from enabling this feature.',
00055                         False),
00056                 ('CONFLICT_TRACKING',        'Keep track of conflicts between transactions and notifies the application (using a callback), passing the identity of the two conflicting transaction and the associated threads.  This feature requires EPOCH_GC.',
00057                         False),
00058                 ('READ_LOCKED_DATA',         'Allow transactions to read the previous version of locked memory locations, as in the original LSA algorithm (see [DISC-06]). This is achieved by peeking into the write set of the transaction that owns the lock.  There is a small overhead with non-contended workloads but it may significantly reduce the abort rate, especially with transactions that read much data.  This feature only works with the WRITE_BACK_ETL design and requires EPOCH_GC.',
00059                         False),
00060                 ('LOCK_IDX_SWAP',            'Tweak the hash function that maps addresses to locks so that consecutive addresses do not map to consecutive locks. This can avoid cache line invalidations for application that perform sequential memory accesses. The last byte of the lock index is swapped with the previous byte.',
00061                         True),
00062                 ('ALLOW_ABORTS',       'Allows transaction aborts. When disabled and combined with no-isolation, the TM system does not need to perform version management for volatile data.',
00063                         False),
00064                 ('SYNC_TRUNCATION',          'Synchronously flushes the write set out of the HW cache and truncates the persistent log.',
00065                         True),
00066                 ('FLUSH_CACHELINE_ONCE',          'When asynchronously truncating the log, the log manager flushes each cacheline of the write set only once by keeping track flushed cachelines.',
00067                         False),
00068 
00069         ]
00070         
00071         #: Build directives which have enumerated values.
00072         _enumerable_directive_vars = [
00073                 ('CM',
00074                                  'Determines the conflict_management policy for the STM.',
00075                                  'CM_SUICIDE',
00076                                  ['CM_SUICIDE', 'CM_DELAY', 'CM_BACKOFF', 'CM_PRIORITY']),
00077                 ('TMLOG_TYPE',
00078                                  'Determines the type of the persistent log used.',
00079                                  'TMLOG_TYPE_BASE',
00080                                  ['TMLOG_TYPE_BASE', 'TMLOG_TYPE_TORNBIT'])
00081         ]
00082         
00083         #: Build directives which have numerical values
00084         _numerical_directive_vars = [
00085                 ('RW_SET_SIZE',
00086                  'Initial size of the read and write sets. These sets will grow dynamically when they become full.',
00087                  16384 # Default
00088                                  ),
00089                 ('LOCK_ARRAY_LOG_SIZE',
00090                  'Number of bits used for indexes in the lock array. The size of the array will be 2 to the power of LOCK_ARRAY_LOG_SIZE.',
00091                  20 # Default
00092                                  ),
00093                 ('PRIVATE_LOCK_ARRAY_LOG_SIZE',
00094                  'Number of bits used for indexes in the private pseudo-lock array. The size of the array will be 2 to the power of PRIVATE_LOCK_ARRAY_LOG_SIZE.',
00095                  8 # Default
00096                                  ),
00097                 ('MIN_BACKOFF',
00098                  'Minimum value of the exponential backoff delay. This parameter is only used with the CM_BACKOFF contention manager.',
00099                  0x4 # Default
00100                  ),
00101                 ('MAX_BACKOFF',
00102                  'Maximum value of the exponential backoff delay. This parameter is only used with the CM_BACKOFF contention manager.',
00103                  0x80000000 # Default
00104                  ),
00105                 ('VR_THRESHOLD_DEFAULT', 
00106                  'Number of aborts due to failed validation before switching to visible reads. A value of 0 indicates no limit. This parameter is only used with the CM_PRIORITY contention manager. It can also be set using an environment variable of the same name.',
00107                  3 # Default
00108                  ),
00109                 ('CM_THRESHOLD_DEFAULT',
00110                  'Number of executions of the transaction with a CM_SUICIDE contention management strategy before switching to CM_PRIORITY. This parameter is only used with the CM_PRIORITY contention manager. It can also be set using an environment variable of the same name.',
00111                  0 # Default
00112                  )
00113         ]

Generated on Sat Apr 23 11:43:35 2011 for Mnemosyne by  doxygen 1.4.7