<commit_before>package generic;

import java.util.Enumeration;
import java.util.Hashtable;

import memorysystem.CoreMemorySystem;

import memorysystem.Cache;
import memorysystem.MemorySystem;
import config.SystemConfig;

public class GlobalClock {
	
	static long currentTime;
	static int stepSize;
	static double stepValue;

	public static void systemTimingSetUp(Core[] cores, Hashtable<String, Cache> cacheList)
	{
		currentTime = 0;
		stepSize = 1;
		
		//TODO setting up of a heterogeneous clock environment
		
		//populate time_periods[]
		int[] time_periods = new int[SystemConfig.NoOfCores + SystemConfig.declaredCaches.size() + 1];
		int i = 0;
		int seed = Integer.MAX_VALUE;
		String cacheName;
		Cache cache;
		
		for(i = 0; i < SystemConfig.NoOfCores; i++)
		{
			time_periods[i] = Math.round(100000/cores[i].getFrequency());
			if(time_periods[i] < seed)
			{
				seed = time_periods[i];
			}
		}
		for (Enumeration<String> cacheNameSet = cacheList.keys(); cacheNameSet.hasMoreElements(); /*Nothing*/)
		{
			cacheName = cacheNameSet.nextElement();
			cache = cacheList.get(cacheName);
			time_periods[i] = Math.round(100000/cache.getFrequency());
			if(time_periods[i] < seed)
			{
				seed = time_periods[i];
			}
			i++;
		}
		time_periods[i] = Math.round(100000/MemorySystem.mainMemory.getFrequency());
		if(time_periods[i] < seed)
		{
			seed = time_periods[i];
		}
				
		//compute HCF
		//TODO look for a better algorithm
		int j;
		boolean flag;
		int HCF = 1;
		for(i = 1; seed/i > 1; i++)
		{
			if(seed%i == 0)
			{
				flag = true;
				for(j = 0; j < SystemConfig.NoOfCores + SystemConfig.declaredCaches.size() + 1; j++)
				{
					if(time_periods[j]%(seed/i) != 0)
					{
						flag = false;
						break;
					}
				}
				if(flag == true)
				{
					HCF = (seed/i);
					break;
				}
			}
		}
		
		//set step sizes of components
		for(i = 0; i < SystemConfig.NoOfCores; i++)
		{
			cores[i].setStepSize(time_periods[i]/HCF);
			CoreMemorySystem coreMemSys;
			
			if (cores[i].isPipelineStatistical)
				coreMemSys = cores[i].getStatisticalPipeline().coreMemSys;
			else
				coreMemSys = cores[i].getExecEngine().coreMemSys;
			
			coreMemSys.getL1Cache().setStepSize(cores[i].getStepSize());
			coreMemSys.getLsqueue().setStepSize(cores[i].getStepSize());
			coreMemSys.getTLBuffer().setStepSize(cores[i].getStepSize());
			//System.out.println(cores[i].getStepSize());
		}
		for (Enumeration<String> cacheNameSet = cacheList.keys(); cacheNameSet.hasMoreElements(); /*Nothing*/)
		{
			cacheName = cacheNameSet.nextElement();
			cache = cacheList.get(cacheName);
			cache.setStepSize(time_periods[i++]/HCF);
			//System.out.println(cache.getStepSize());
		}
		MemorySystem.mainMemory.setStepSize(time_periods[i]/HCF);
		//System.out.println(MemorySystem.mainMemStepSize);
		
		stepValue = HCF/100000.0;
		
	}

	public static long getCurrentTime() {
		return GlobalClock.currentTime;
	}

	public static void setCurrentTime(long currentTime) {<commit_msg>Testing the link with mem of inorder<commit_after>package generic;

import java.util.Enumeration;
import java.util.Hashtable;

import memorysystem.CoreMemorySystem;

import memorysystem.Cache;
import memorysystem.MemorySystem;
import config.SystemConfig;

public class GlobalClock {
	
	static long currentTime;
	static int stepSize;
	static double stepValue;

	public static void systemTimingSetUp(Core[] cores, Hashtable<String, Cache> cacheList)
	{
		currentTime = 0;
		stepSize = 1;
		
		//TODO setting up of a heterogeneous clock environment
		
		//populate time_periods[]
		int[] time_periods = new int[SystemConfig.NoOfCores + SystemConfig.declaredCaches.size() + 1];
		int i = 0;
		int seed = Integer.MAX_VALUE;
		String cacheName;
		Cache cache;
		
		for(i = 0; i < SystemConfig.NoOfCores; i++)
		{
			time_periods[i] = Math.round(100000/cores[i].getFrequency());
			if(time_periods[i] < seed)
			{
				seed = time_periods[i];
			}
		}
		for (Enumeration<String> cacheNameSet = cacheList.keys(); cacheNameSet.hasMoreElements(); /*Nothing*/)
		{
			cacheName = cacheNameSet.nextElement();
			cache = cacheList.get(cacheName);
			time_periods[i] = Math.round(100000/cache.getFrequency());
			if(time_periods[i] < seed)
			{
				seed = time_periods[i];
			}
			i++;
		}
		time_periods[i] = Math.round(100000/MemorySystem.mainMemory.getFrequency());
		if(time_periods[i] < seed)
		{
			seed = time_periods[i];
		}
				
		//compute HCF
		//TODO look for a better algorithm
		int j;
		boolean flag;
		int HCF = 1;
		for(i = 1; seed/i > 1; i++)
		{
			if(seed%i == 0)
			{
				flag = true;
				for(j = 0; j < SystemConfig.NoOfCores + SystemConfig.declaredCaches.size() + 1; j++)
				{
					if(time_periods[j]%(seed/i) != 0)
					{
						flag = false;
						break;
					}
				}
				if(flag == true)
				{
					HCF = (seed/i);
					break;
				}
			}
		}
		
		//set step sizes of components
		for(i = 0; i < SystemConfig.NoOfCores; i++)
		{
			cores[i].setStepSize(time_periods[i]/HCF);
			CoreMemorySystem coreMemSys;
			
			if (cores[i].isPipelineStatistical)
				coreMemSys = cores[i].getStatisticalPipeline().coreMemSys;
			else if(cores[i].isPipelineInorder)
				coreMemSys = cores[i].getExecutionEngineIn().coreMemorySystem;
			else
				coreMemSys = cores[i].getExecEngine().coreMemSys;
			
			coreMemSys.getL1Cache().setStepSize(cores[i].getStepSize());
			coreMemSys.getLsqueue().setStepSize(cores[i].getStepSize());
			coreMemSys.getTLBuffer().setStepSize(cores[i].getStepSize());
			//System.out.println(cores[i].getStepSize());
		}
		for (Enumeration<String> cacheNameSet = cacheList.keys(); cacheNameSet.hasMoreElements(); /*Nothing*/)
		{
			cacheName = cacheNameSet.nextElement();
			cache = cacheList.get(cacheName);
			cache.setStepSize(time_periods[i++]/HCF);
			//System.out.println(cache.getStepSize());
		}
		MemorySystem.mainMemory.setStepSize(time_periods[i]/HCF);
		//System.out.println(MemorySystem.mainMemStepSize);
		
		stepValue = HCF/100000.0;
		
	}

	public static long getCurrentTime() {
		return GlobalClock.currentTime;
	}

	public static void setCurrentTime(long currentTime) {
{'fraction_non_alphanumeric': 0.1384918679152292, 'fraction_numerical': 0.012814194184327254, 'mean_word_length': 3.683076923076923, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1352902', 'n_tokens_mistral': 2602, 'n_tokens_neox': 2116, 'n_words': 390}