@@ -1761,6 +1761,57 @@ def test_prepare_step_hmns(self):
17611761 self .assertEqual (len (loaded_modules ), 1 )
17621762 self .assertEqual (loaded_modules [0 ]['mod_name' ], 'GCC/6.4.0-2.28' )
17631763
1764+ def test_prepare_step_cuda_cache (self ):
1765+ """Test handling cuda-cache-maxsize option."""
1766+
1767+ init_config (build_options = {'cuda_cache_maxsize' : None }) # Automatic mode
1768+
1769+ test_ecs = os .path .join (os .path .abspath (os .path .dirname (__file__ )), 'easyconfigs' , 'test_ecs' )
1770+ toy_ec = os .path .join (test_ecs , 't' , 'toy' , 'toy-0.0.eb' )
1771+ ec = process_easyconfig (toy_ec )[0 ]
1772+ eb = EasyBlock (ec ['ec' ])
1773+ eb .silent = True
1774+ eb .make_builddir ()
1775+
1776+ eb .prepare_step (start_dir = False )
1777+ logtxt = read_file (eb .logfile )
1778+ self .assertNotIn ('Disabling CUDA PTX cache' , logtxt )
1779+ self .assertNotIn ('Enabling CUDA PTX cache' , logtxt )
1780+
1781+ # Now with CUDA
1782+ test_ec = os .path .join (self .test_prefix , 'test.eb' )
1783+ test_ectxt = re .sub ('^toolchain = .*' , "toolchain = {'name': 'gcccuda', 'version': '2018a'}" ,
1784+ read_file (toy_ec ), flags = re .M )
1785+ write_file (test_ec , test_ectxt )
1786+ ec = process_easyconfig (test_ec )[0 ]
1787+ eb = EasyBlock (ec ['ec' ])
1788+ eb .silent = True
1789+ eb .make_builddir ()
1790+
1791+ write_file (eb .logfile , '' )
1792+ eb .prepare_step (start_dir = False )
1793+ logtxt = read_file (eb .logfile )
1794+ self .assertNotIn ('Disabling CUDA PTX cache' , logtxt )
1795+ self .assertIn ('Enabling CUDA PTX cache' , logtxt )
1796+ self .assertEqual (os .environ ['CUDA_CACHE_DISABLE' ], '0' )
1797+
1798+ init_config (build_options = {'cuda_cache_maxsize' : 0 }) # Disable
1799+ write_file (eb .logfile , '' )
1800+ eb .prepare_step (start_dir = False )
1801+ logtxt = read_file (eb .logfile )
1802+ self .assertIn ('Disabling CUDA PTX cache' , logtxt )
1803+ self .assertNotIn ('Enabling CUDA PTX cache' , logtxt )
1804+ self .assertEqual (os .environ ['CUDA_CACHE_DISABLE' ], '1' )
1805+
1806+ init_config (build_options = {'cuda_cache_maxsize' : 1234567890 }) # Specified size
1807+ write_file (eb .logfile , '' )
1808+ eb .prepare_step (start_dir = False )
1809+ logtxt = read_file (eb .logfile )
1810+ self .assertNotIn ('Disabling CUDA PTX cache' , logtxt )
1811+ self .assertIn ('Enabling CUDA PTX cache' , logtxt )
1812+ self .assertEqual (os .environ ['CUDA_CACHE_DISABLE' ], '0' )
1813+ self .assertEqual (os .environ ['CUDA_CACHE_MAXSIZE' ], '1234567890' )
1814+
17641815 def test_checksum_step (self ):
17651816 """Test checksum step"""
17661817 testdir = os .path .abspath (os .path .dirname (__file__ ))
0 commit comments