Commit a02484f8 authored by Naman Dixit's avatar Naman Dixit

Forced number of cache sets to be power of 2

parent c912887b
...@@ -17,7 +17,8 @@ Instructions: ...@@ -17,7 +17,8 @@ Instructions:
will listen) will listen)
2. -threadPoolSize=YYY (number of threads in the 2. -threadPoolSize=YYY (number of threads in the
thread pool) thread pool)
3. -numSetsInCache=ZZZ (number of sets in the cache) 3. -numSetsInCache=ZZZ (number of sets in the cache,
should be a power of 2)
4. -sizeOfSet=AAA (associativity of sets) 4. -sizeOfSet=AAA (associativity of sets)
Storage: The server stores the data in "${PWD}/data_store/" directory. Storage: The server stores the data in "${PWD}/data_store/" directory.
......
...@@ -659,5 +659,22 @@ Size strprefix(Char *pre, Char *str) ...@@ -659,5 +659,22 @@ Size strprefix(Char *pre, Char *str)
} }
} }
} }
header_function
U64 nextPowerOf2(U64 v)
{
v--;
v |= v >> 1;
v |= v >> 2;
v |= v >> 4;
v |= v >> 8;
v |= v >> 16;
v |= v >> 32;
v++;
return v;
}
#define AUX_H_INCLUDE_GUARD #define AUX_H_INCLUDE_GUARD
#endif #endif
...@@ -69,7 +69,7 @@ Sint main (Sint argc, Char *argv[]) ...@@ -69,7 +69,7 @@ Sint main (Sint argc, Char *argv[])
} else if ((arg_pos = strprefix("-threadPoolSize=", argv[i]))) { } else if ((arg_pos = strprefix("-threadPoolSize=", argv[i]))) {
thread_pool_size = (Size)strtol(&(argv[i][arg_pos]), NULL, 0); thread_pool_size = (Size)strtol(&(argv[i][arg_pos]), NULL, 0);
} else if ((arg_pos = strprefix("-numSetsInCache=", argv[i]))) { } else if ((arg_pos = strprefix("-numSetsInCache=", argv[i]))) {
cache_set_count = (Size)strtol(&(argv[i][arg_pos]), NULL, 0); cache_set_count = nextPowerOf2((Size)strtol(&(argv[i][arg_pos]), NULL, 0));
} else if ((arg_pos = strprefix("-sizeOfSet=", argv[i]))) { } else if ((arg_pos = strprefix("-sizeOfSet=", argv[i]))) {
cache_associativity = (Size)strtol(&(argv[i][arg_pos]), NULL, 0); cache_associativity = (Size)strtol(&(argv[i][arg_pos]), NULL, 0);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment