def downloadUarchSpec(uarchSpec): """ Downloads specifications and topdown metrics for a cpu micro architecture :param uarchSpec: Name of the cpu micro architecture """ LOGGER.info('\tdownloading uarch spec for %s -> ', uarchSpec.name) from xpedite.util import mkdir begin = time.time() path = os.path.join(uarchSpecPath(), uarchSpec.name) mkdir(path) url = '{}{}/{}'.format(CONFIG.uarchSpecRepoUrl, uarchSpec.name, os.path.basename(uarchSpec.coreEventsDbFile)) rc = downloadFile(url, os.path.join(path, uarchSpec.coreEventsDbFile)) elapsed = time.time() - begin LOGGER.completed('completed in %0.2f sec.', elapsed) if rc: ratiosModuleName = TOPDOWN_RATIOS_MODULES.get(uarchSpec.name) if ratiosModuleName: url = '{}{}'.format(CONFIG.topdownRatiosRepoUrl, ratiosModuleName) LOGGER.info('\tdownloading topdown ratios for %s -> ', uarchSpec.name) begin = time.time() rc = downloadFile(url, os.path.join(path, '__init__.py')) elapsed = time.time() - begin uarchSpec.ratiosModule = '' LOGGER.completed('completed in %0.2f sec.', elapsed) return rc
def makeUarchSpecDir(): """Creates a directory for storing micro architecture specifications""" from xpedite.util import mkdir, touch path = uarchSpecPath() try: mkdir(path, clean=True) except OSError: LOGGER.exception('failed to create dir - %s', path) return None touch(os.path.join(path, '__init__.py')) return path
def makeSampleFilePath(path, threadId, tlsAddr): """ Creates a new csv sample source file path for the given thread :param path: Path of the data source directory :param threadId: Id of thread collecting the samples :param tlsAddr: Address of thread local storage of thread collecting the samples """ path = os.path.join(path, '{}-{}'.format(threadId, tlsAddr)) mkdir(path) return os.path.join(path, 'samples-0000.csv')
def openInflateFile(dataSourcePath, threadId, tlsAddr): """ Creates a new data source file for the given thread :param dataSourcePath: Path of the data source directory :param threadId: Id of thread collecting the samples :param tlsAddr: Address of thread local storage of thread collecting the samples """ path = os.path.join(dataSourcePath, '{}-{}'.format(threadId, tlsAddr)) mkdir(path) filePath = os.path.join(path, 'samples-0000.csv') return open(filePath, 'w')
def downloadUarchSpec(uarchSpec): """ Downloads uarc specifications for a cpu micro architecture :param uarchSpec: Name of the cpu micro architecture """ from xpedite.util import mkdir begin = time.time() LOGGER.info('\tdownloading uarch spec for %s -> ', uarchSpec.name) path = os.path.dirname(uarchSpec.coreEventsDbFile) mkdir(path) url = '{}{}/{}'.format(CONFIG.uarchSpecRepoUrl, uarchSpec.name, os.path.basename(uarchSpec.coreEventsDbFile)) rc = downloadFile(url, os.path.join(path, uarchSpec.coreEventsDbFile)) elapsed = time.time() - begin LOGGER.completed('%s in %0.2f sec.', 'completed' if rc else ' --> failed', elapsed) return rc
def downloadtopdownMetrics(uarchSpec): """ Downloads topdown metrics for a cpu micro architecture :param uarchSpec: Name of the cpu micro architecture """ from xpedite.util import mkdir ratiosModuleName = TOPDOWN_RATIOS_MODULES.get(uarchSpec.name) path = os.path.join(uarchSpecPath(), uarchSpec.name) if ratiosModuleName and not os.path.exists(path): mkdir(path) url = '{}{}'.format(CONFIG.topdownRatiosRepoUrl, ratiosModuleName) LOGGER.info('\tdownloading topdown ratios for %s -> ', uarchSpec.name) begin = time.time() rc = downloadFile(url, os.path.join(path, '__init__.py')) elapsed = time.time() - begin uarchSpec.ratiosModule = '' LOGGER.completed('completed in %0.2f sec.', elapsed) return rc return None
def downloadManifest(): """ Downloads manifest for all known micro architecture specifications from internet""" from xpedite.util import mkdir mkdir(os.path.dirname(manifestFilePath())) return downloadFile(CONFIG.uarchSpecRepoUrl + CONFIG.manifestFileName, manifestFilePath())