From 721aa03c7012c2ba8b06a442c99fb5d98191edd3 Mon Sep 17 00:00:00 2001 From: jason Date: Sat, 18 Nov 2017 21:25:06 -0500 Subject: [PATCH] cleaning --- README.md | 1 + mimircache/CExtension/profiler/LRUProfiler.c | 11 ++- .../CExtension/profiler/generalProfiler.c | 1 - .../CExtension/profiler/heatmap_thread.c | 1 - setup.py | 77 ++++++------------- 5 files changed, 28 insertions(+), 63 deletions(-) diff --git a/README.md b/README.md index 7d58621..0cd0138 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ mimircache ========== [![Build Status](https://travis-ci.org/1a1a11a/mimircache.svg?branch=master)](https://travis-ci.org/1a1a11a/mimircache) +[![Documentation Status](https://readthedocs.org/projects/mimircacheemory/badge/?version=develop)](http://mimircacheemory.readthedocs.io/en/develop/?badge=develop) [![GitHub version](https://badge.fury.io/gh/1a1a11a%2Fmimircache.svg)](https://badge.fury.io/gh/1a1a11a%2Fmimircache) [![PyPI version](https://badge.fury.io/py/mimirCache.svg)](https://badge.fury.io/py/mimirCache) diff --git a/mimircache/CExtension/profiler/LRUProfiler.c b/mimircache/CExtension/profiler/LRUProfiler.c index 8de83c4..72d8ec5 100644 --- a/mimircache/CExtension/profiler/LRUProfiler.c +++ b/mimircache/CExtension/profiler/LRUProfiler.c @@ -161,7 +161,7 @@ guint64* get_hitcount_withsize_seq(reader_t* reader, gint64 size, int block_unit /* for a cache_size=size, we need size+1 bucket for size 0~size(included), * the last element(size+1) is used for storing count of reuse distance > size - * if size==reader->base->total_num, then the last two is not used + * if size==reader->base->total_num, then the last two are not used */ hit_count_array = g_new0(guint64, size+3); @@ -181,13 +181,11 @@ guint64* get_hitcount_withsize_seq(reader_t* reader, gint64 size, int block_unit // create hashtable GHashTable * hash_table; if (reader->base->data_type == 'l'){ - // cp->type = 'l'; hash_table = g_hash_table_new_full(g_int64_hash, g_int64_equal, \ (GDestroyNotify)simple_g_key_value_destroyer, \ (GDestroyNotify)simple_g_key_value_destroyer); } else if (reader->base->data_type == 'c' ){ - // cp->type = 'c'; hash_table = g_hash_table_new_full(g_str_hash, g_str_equal, \ (GDestroyNotify)simple_g_key_value_destroyer, \ (GDestroyNotify)simple_g_key_value_destroyer); @@ -310,7 +308,7 @@ guint64* get_hit_count_seq_shards(reader_t* reader, /* for a cache_size=size, we need size+1 bucket for size 0~size(included), * the last element(size+1) is used for storing count of reuse distance > size - * if size==reader->base->total_num, then the last two is not used + * if size==reader->base->total_num, then the last two are not used */ hit_count_array = g_new0(guint64, size+3); @@ -322,13 +320,11 @@ guint64* get_hit_count_seq_shards(reader_t* reader, // create hashtable GHashTable * hash_table; if (reader->base->data_type == 'l'){ - // cp->type = 'l'; hash_table = g_hash_table_new_full(g_int64_hash, g_int64_equal, \ (GDestroyNotify)simple_g_key_value_destroyer, \ (GDestroyNotify)simple_g_key_value_destroyer); } else if (reader->base->data_type == 'c' ){ - // cp->type = 'c'; hash_table = g_hash_table_new_full(g_str_hash, g_str_equal, \ (GDestroyNotify)simple_g_key_value_destroyer, \ (GDestroyNotify)simple_g_key_value_destroyer); @@ -338,6 +334,9 @@ guint64* get_hit_count_seq_shards(reader_t* reader, abort(); } + // TODO: when it is not profiling with size, just use reuse distance for calculation, + // because reuse distance might be loaded without re-computation + // create splay tree sTree* splay_tree = NULL; diff --git a/mimircache/CExtension/profiler/generalProfiler.c b/mimircache/CExtension/profiler/generalProfiler.c index 0eaa566..bf60c76 100644 --- a/mimircache/CExtension/profiler/generalProfiler.c +++ b/mimircache/CExtension/profiler/generalProfiler.c @@ -71,7 +71,6 @@ static void profiler_thread_temp(gpointer data, gpointer user_data){ char* dat_name = strrchr(reader_thread->base->file_loc, '/'); sprintf(output_filename, "/home/jason/special/%s_size%ld", dat_name, cache->core->size); FILE* miss_req_output = fopen(output_filename, "w"); -// printf("this is the new one\n"); while (cp->valid){ diff --git a/mimircache/CExtension/profiler/heatmap_thread.c b/mimircache/CExtension/profiler/heatmap_thread.c index 87c5fcc..1fc1eec 100644 --- a/mimircache/CExtension/profiler/heatmap_thread.c +++ b/mimircache/CExtension/profiler/heatmap_thread.c @@ -121,7 +121,6 @@ void heatmap_LRU_hit_ratio_start_time_end_time_thread(gpointer data, gpointer us hit_count_all = 0; miss_count_all = 0; - // unnecessary ? skip_N_elements(reader_thread, g_array_index(break_points, guint64, order)); diff --git a/setup.py b/setup.py index fa66899..7bb243a 100644 --- a/setup.py +++ b/setup.py @@ -49,7 +49,7 @@ """ -def get_compiler_openmp_flag(): +def get_openmp_flag(): openmp_flag = '' tmpdir = tempfile.mkdtemp() curdir = os.getcwd() @@ -89,23 +89,23 @@ def get_compiler_openmp_flag(): return openmp_flag -def getGlibFlag(): +def get_glib_flag(): try: glib_cflag = subprocess.check_output("pkg-config --cflags glib-2.0", shell=True).decode().strip() - extra_compile_args.extend(glib_cflag.split()) + return glib_cflag.split() except Exception as e: print(e) -def getGlibLibrary(): +def get_glib_library(): try: glib_lib = subprocess.check_output("pkg-config --libs glib-2.0 --libs gthread-2.0", shell=True).decode().strip() - extra_link_args.extend(glib_lib.split()) + return glib_lib.split() except Exception as e: print(e) -def setPlatformRelatedConfig(): +def set_platform_related_config(): if sys.platform == 'darwin': from distutils import sysconfig vars = sysconfig.get_config_vars() @@ -116,7 +116,7 @@ def setPlatformRelatedConfig(): os.environ["CXX"] = "clang" -def getNumpyHeader(): +def get_numpy_header(): try: import numpy numpy_headers.append(numpy.get_include()) @@ -126,37 +126,21 @@ def getNumpyHeader(): -getGlibFlag() -getGlibLibrary() -getNumpyHeader() -setPlatformRelatedConfig() -# openmp_flag = get_compiler_openmp_flag() -# print('get_compiler_openmp_flag(): ' + openmp_flag) +extra_compile_args.extend(get_glib_flag()) +extra_link_args.extend(get_glib_library()) +# extra_compile_args.append(get_openmp_flag()) +# extra_link_args.append(get_openmp_flag()) -# extra_compile_args.append(openmp_flag) -# extra_link_args.append(openmp_flag) +numpy_headers.append(get_numpy_header()) +set_platform_related_config() -print('all compile flags: ' + str(extra_compile_args)) -print('all link flasgs: ' + str(extra_link_args)) +if _DEBUG: + print('all compile flags: {}'.format(extra_compile_args)) + print('all link flasgs: {}'.format(extra_link_args)) + print("{}".format(extensions)) -# --------------------- parda module --------------------------- -# extensions.append(Extension( -# "mimircache.profiler.libparda", -# glob("mimircache/profiler/parda/src/*.c"), -# include_dirs=["mimircache/profiler/parda/src/h/"], -# extra_compile_args=extra_compile_args, -# extra_link_args=extra_link_args, -# language="c" -# )) -# # --------------------- vscsi module --------------------------- -# extensions.append(Extension( -# "mimircache.cacheReader.libvscsi", -# glob("mimircache/cacheReader/vscsi/src/*.c"), -# include_dirs=["mimircache/cacheReader/vscsi/src/"], -# language="c" -# )) extensions.append(Extension( 'mimircache.c_cacheReader', @@ -254,18 +238,16 @@ def getNumpyHeader(): -# print("find packages: " + str( -# find_packages(exclude=(['mimircache.bin', 'mimircache.test', 'mimircache.data', 'mimircache.A1a1a11a'])))) +long_description = "" +with open("README.md") as f: + long_description = f.read() -print("Extension: " + str(extensions)) -# long_description = read('README.md', 'CHANGES') setup( name="mimircache", version=__version__, - # package_dir = {'':'src'}, - packages = ['mimircache', 'mimircache.cache', 'mimircache.cacheReader', 'mimircache.profiler', 'mimircache.profiler.abstract', 'mimircache.utils', 'mimircache.top'], + packages = ['mimircache', 'mimircache.cache', 'mimircache.cacheReader', 'mimircache.profiler', 'mimircache.utils', 'mimircache.top'], # packages=find_packages(exclude=(['mimircache.bin', 'mimircache.test', 'mimircache.data', 'mimircache.A1a1a11a'])), # modules = # package_data={'plain': ['mimircache/data/trace.txt'], @@ -280,10 +262,6 @@ def getNumpyHeader(): keywords="mimircache cache Ymir", url="http://mimircache.info", - # libraries = [libparda, libvscsi], - # cmdclass = {'build_clib' : build_clib}, - # cmdclass = {'build_ext': build_ext_subclass, 'build_clib' : build_clib_subclass}, - ext_modules=extensions, classifiers=[ 'Development Status :: 3 - Alpha', @@ -294,24 +272,13 @@ def getNumpyHeader(): 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', ], - install_requires=['heapdict', 'mmh3'] # 'numpy', 'matplotlib', 'scipy', - # long_description=long_description + install_requires=['heapdict', 'mmh3', "matplotlib", "numpy"] ) # python3 setup.py sdist upload -r pypitest -# could also try this: -# from distutils.ccompiler import new_compiler - -# # Create compiler with default options -# c = new_compiler() -# workdir = "." - -# # Optionally add include directories etc. -# # c.add_include_dir("some/include") - # # Compile into .o files # objects = c.compile(["a.c", "b.c"])