[Assorted-commits] SF.net SVN: assorted: [616] numa-bench/trunk/src/chew.cc
Brought to you by:
yangzhang
From: <yan...@us...> - 2008-03-07 02:49:01
|
Revision: 616 http://assorted.svn.sourceforge.net/assorted/?rev=616&view=rev Author: yangzhang Date: 2008-03-06 18:49:04 -0800 (Thu, 06 Mar 2008) Log Message: ----------- moved shared pretouching to shared location Modified Paths: -------------- numa-bench/trunk/src/chew.cc Modified: numa-bench/trunk/src/chew.cc =================================================================== --- numa-bench/trunk/src/chew.cc 2008-03-07 02:38:20 UTC (rev 615) +++ numa-bench/trunk/src/chew.cc 2008-03-07 02:49:04 UTC (rev 616) @@ -165,6 +165,22 @@ global_sum += sum; } +void +do_pretouch(void *p, const config & config) +{ + if (pretouch) { + int *is = (int*) p; + for (size_t i = 0; i < config.size / sizeof(int); i++) { + is[i] = i; + } + int sum = 0; + for (size_t i = 0; i < config.size / sizeof(int); i++) { + sum += is[i]; + } + global_sum += sum; + } +} + /** * \param pp The start of the buffer to chew. * \param worker From this we can determine which CPU to pin our thread to. @@ -187,17 +203,7 @@ } void* p = config.local ? alloc(config.size) : pp; - if (pretouch) { - int *is = (int*) p; - for (size_t i = 0; i < config.size / sizeof(int); i++) { - is[i] = i; - } - int sum = 0; - for (size_t i = 0; i < config.size / sizeof(int); i++) { - sum += is[i]; - } - global_sum += sum; - } + if (config.local) do_pretouch(p, config); if (debug) { check(pthread_mutex_lock(&iomutex) == 0); cout << worker << " alloc " << p << endl; @@ -288,7 +294,8 @@ check(config.shuffle || config.opcount <= config.size / sizeof(int)); - void *p = malloc(config.size); + void *p = alloc(config.size); + do_pretouch(p, config); check(p != NULL); check(pthread_mutex_init(&iomutex, NULL) == 0); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |