/* $Id$ */
/** @file
* numa - NUMA / memory benchmark.
*/
/*
* Copyright (C) 2011-2014 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* The contents of this file may alternatively be used under the terms
* of the Common Development and Distribution License Version 1.0
* (CDDL) only, as it comes in the "COPYING.CDDL" file of the
* VirtualBox OSE distribution, in which case the provisions of the
* CDDL are applicable instead of those of the GPL.
*
* You may elect to license modified versions of this file under the
* terms and conditions of either the GPL or the CDDL or both.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
//#if defined(RT_ARCH_X86) || defined(RT_ARCH_AMD64)
//# include <iprt/asm-amd64-x86.h>
//#endif
/*******************************************************************************
* Global Variables *
*******************************************************************************/
/** The number of threads to skip when testing. */
/**
* Gets the next online CPU.
*
* @returns Next CPU index or RTCPUSET_MAX_CPUS.
* @param iCurCpu The current CPU (index).
*/
{
/* Skip to the next chip. */
/* Skip offline cpus. */
while ( iCurCpu < RTCPUSET_MAX_CPUS
&& !RTMpIsCpuOnline(iCurCpu) )
iCurCpu++;
/* Make sure we're within bounds (in case of bad input). */
if (iCurCpu > RTCPUSET_MAX_CPUS)
return iCurCpu;
}
{
while (iAllocCpu < RTCPUSET_MAX_CPUS)
{
/*
* Change CPU and allocate a chunk of memory.
*/
/*
* Do the tests.
*/
while (iAccessCpu < RTCPUSET_MAX_CPUS)
{
/*
* The write test.
*/
RTTimeNanoTS(); RTThreadYield();
for (uint32_t i = 0; i < cIterations; i++)
{
ASMCompilerBarrier(); /* paranoia */
}
/ _1M /* MB */ );
RTTestIValueF(cMBPerSec, RTTESTUNIT_MEGABYTES_PER_SEC, "cpu%02u-mem%02u-write", iAllocCpu, iAccessCpu);
/*
* The read test.
*/
RTTimeNanoTS(); RTThreadYield();
u64StartTS = RTTimeNanoTS();
for (uint32_t i = 0; i < cIterations; i++)
{
#if 1
size_t register u = 0;
u += *puCur++;
#else
ASMCompilerBarrier(); /* paranoia */
#endif
}
/ _1M /* MB */ );
RTTestIValueF(cMBPerSec, RTTESTUNIT_MEGABYTES_PER_SEC, "cpu%02u-mem%02u-read", iAllocCpu, iAccessCpu);
/*
*/
RTTimeNanoTS(); RTThreadYield();
u64StartTS = RTTimeNanoTS();
for (uint32_t i = 0; i < cIterations; i++)
{
ASMCompilerBarrier(); /* paranoia */
}
/ _1M /* MB */ );
RTTestIValueF(cMBPerSec, RTTESTUNIT_MEGABYTES_PER_SEC, "cpu%02u-mem%02u-read-write", iAllocCpu, iAccessCpu);
/*
* Total time.
*/
/* advance */
}
/*
* Clean up and advance to the next CPU.
*/
}
}
{
if (rcExit != RTEXITCODE_SUCCESS)
return rcExit;
#if defined(RT_ARCH_X86) || defined(RT_ARCH_AMD64)
/** @todo figure basic topology. */
#endif
if (argc == 2)
return RTTestSummaryAndDestroy(hTest);
}