Skip to content

Commit

Permalink
cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
jason committed Nov 19, 2017
1 parent 6834426 commit 721aa03
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 63 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
11 changes: 5 additions & 6 deletions mimircache/CExtension/profiler/LRUProfiler.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);
Expand Down Expand Up @@ -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);

Expand All @@ -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);
Expand All @@ -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;

Expand Down
1 change: 0 additions & 1 deletion mimircache/CExtension/profiler/generalProfiler.c
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down
1 change: 0 additions & 1 deletion mimircache/CExtension/profiler/heatmap_thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
77 changes: 22 additions & 55 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"""


def get_compiler_openmp_flag():
def get_openmp_flag():
openmp_flag = ''
tmpdir = tempfile.mkdtemp()
curdir = os.getcwd()
Expand Down Expand Up @@ -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()
Expand All @@ -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())
Expand All @@ -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',
Expand Down Expand Up @@ -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'],
Expand All @@ -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',
Expand All @@ -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"])

Expand Down

0 comments on commit 721aa03

Please sign in to comment.