diff options
Diffstat (limited to 'drivers/nedmalloc')
-rw-r--r-- | drivers/nedmalloc/Benchmarks.xls | bin | 36352 -> 0 bytes | |||
-rw-r--r-- | drivers/nedmalloc/SCsub | 1 | ||||
-rw-r--r-- | drivers/nedmalloc/nedmalloc.sln | 19 | ||||
-rw-r--r-- | drivers/nedmalloc/nedmalloc.vcproj | 259 | ||||
-rw-r--r-- | drivers/nedmalloc/test.c | 356 |
5 files changed, 0 insertions, 635 deletions
diff --git a/drivers/nedmalloc/Benchmarks.xls b/drivers/nedmalloc/Benchmarks.xls Binary files differdeleted file mode 100644 index 5001a18a22..0000000000 --- a/drivers/nedmalloc/Benchmarks.xls +++ /dev/null diff --git a/drivers/nedmalloc/SCsub b/drivers/nedmalloc/SCsub index 8e6edd1f96..6699efef75 100644 --- a/drivers/nedmalloc/SCsub +++ b/drivers/nedmalloc/SCsub @@ -2,4 +2,3 @@ Import('env') Export('env'); env.add_source_files(env.drivers_sources,"*.cpp") -#env.add_source_files(env.drivers_sources,"*.c") diff --git a/drivers/nedmalloc/nedmalloc.sln b/drivers/nedmalloc/nedmalloc.sln deleted file mode 100644 index 6ffd9fb83f..0000000000 --- a/drivers/nedmalloc/nedmalloc.sln +++ /dev/null @@ -1,19 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 10.00
-# Visual Studio 2008
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nedmalloc", "nedmalloc.vcproj", "{B89384F5-360B-4AB2-8F43-2F5F98A947FE}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Win32 = Debug|Win32
- Release|Win32 = Release|Win32
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {B89384F5-360B-4AB2-8F43-2F5F98A947FE}.Debug|Win32.ActiveCfg = Debug|Win32
- {B89384F5-360B-4AB2-8F43-2F5F98A947FE}.Debug|Win32.Build.0 = Debug|Win32
- {B89384F5-360B-4AB2-8F43-2F5F98A947FE}.Release|Win32.ActiveCfg = Release|Win32
- {B89384F5-360B-4AB2-8F43-2F5F98A947FE}.Release|Win32.Build.0 = Release|Win32
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
diff --git a/drivers/nedmalloc/nedmalloc.vcproj b/drivers/nedmalloc/nedmalloc.vcproj deleted file mode 100644 index c5b0563d4f..0000000000 --- a/drivers/nedmalloc/nedmalloc.vcproj +++ /dev/null @@ -1,259 +0,0 @@ -<?xml version="1.0" encoding="Windows-1252"?>
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="9.00"
- Name="nedmalloc"
- ProjectGUID="{B89384F5-360B-4AB2-8F43-2F5F98A947FE}"
- Keyword="Win32Proj"
- TargetFrameworkVersion="131072"
- >
- <Platforms>
- <Platform
- Name="Win32"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="Debug"
- IntermediateDirectory="Debug"
- ConfigurationType="1"
- InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
- MinimalRebuild="true"
- BasicRuntimeChecks="3"
- RuntimeLibrary="3"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DebugInformationFormat="4"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- OutputFile="$(OutDir)/nedmalloc.exe"
- LinkIncremental="2"
- GenerateDebugInformation="true"
- ProgramDatabaseFile="$(OutDir)/nedmalloc.pdb"
- SubSystem="1"
- RandomizedBaseAddress="1"
- DataExecutionPrevention="0"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="Release"
- IntermediateDirectory="Release"
- ConfigurationType="1"
- InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- AdditionalOptions="/Ow"
- InlineFunctionExpansion="0"
- EnableIntrinsicFunctions="true"
- FavorSizeOrSpeed="1"
- OmitFramePointers="true"
- PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
- StringPooling="true"
- RuntimeLibrary="2"
- BufferSecurityCheck="false"
- EnableEnhancedInstructionSet="1"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- OutputFile="$(OutDir)/nedmalloc.exe"
- LinkIncremental="1"
- GenerateDebugInformation="true"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- RandomizedBaseAddress="1"
- DataExecutionPrevention="0"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
- UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
- >
- <File
- RelativePath=".\nedmalloc.c"
- >
- <FileConfiguration
- Name="Debug|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath=".\test.c"
- >
- </File>
- </Filter>
- <Filter
- Name="Header Files"
- Filter="h;hpp;hxx;hm;inl;inc;xsd"
- UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
- >
- <File
- RelativePath=".\malloc.c.h"
- >
- </File>
- <File
- RelativePath=".\nedmalloc.h"
- >
- </File>
- </Filter>
- <Filter
- Name="Resource Files"
- Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
- UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
- >
- </Filter>
- <File
- RelativePath="..\..\..\..\gcLink.cc"
- >
- <FileConfiguration
- Name="Debug|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath=".\Readme.txt"
- >
- </File>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
diff --git a/drivers/nedmalloc/test.c b/drivers/nedmalloc/test.c deleted file mode 100644 index 8b9fed81d0..0000000000 --- a/drivers/nedmalloc/test.c +++ /dev/null @@ -1,356 +0,0 @@ -/* test.c
-An example of how to use nedalloc
-(C) 2005-2007 Niall Douglas
-*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include "nedmalloc.c"
-
-#define THREADS 5
-#define RECORDS (100000/THREADS)
-#define TORTURETEST 1
-
-static int whichmalloc;
-static int doRealloc;
-static struct threadstuff_t
-{
- int ops;
- unsigned int *toalloc;
- void **allocs;
- char cachesync1[128];
- int done;
- char cachesync2[128];
-} threadstuff[THREADS];
-
-static void threadcode(int);
-
-#ifdef WIN32
-static DWORD WINAPI _threadcode(LPVOID a)
-{
- threadcode((int)(size_t) a);
- return 0;
-}
-#define THREADVAR HANDLE
-#define THREADINIT(v, id) (*v=CreateThread(NULL, 0, _threadcode, (LPVOID)(size_t) id, 0, NULL))
-#define THREADSLEEP(v) SleepEx(v, FALSE)
-#define THREADWAIT(v) (WaitForSingleObject(v, INFINITE), 0)
-
-typedef unsigned __int64 usCount;
-static FORCEINLINE usCount GetUsCount()
-{
- static LARGE_INTEGER ticksPerSec;
- static double scalefactor;
- LARGE_INTEGER val;
- if(!scalefactor)
- {
- if(QueryPerformanceFrequency(&ticksPerSec))
- scalefactor=ticksPerSec.QuadPart/1000000000000.0;
- else
- scalefactor=1;
- }
- if(!QueryPerformanceCounter(&val))
- return (usCount) GetTickCount() * 1000000000;
- return (usCount) (val.QuadPart/scalefactor);
-}
-
-static HANDLE win32heap;
-static void *win32malloc(size_t size)
-{
- return HeapAlloc(win32heap, 0, size);
-}
-static void *win32realloc(void *p, size_t size)
-{
- return HeapReAlloc(win32heap, 0, p, size);
-}
-static void win32free(void *mem)
-{
- HeapFree(win32heap, 0, mem);
-}
-
-static void *(*const mallocs[])(size_t size)={ malloc, nedmalloc, win32malloc };
-static void *(*const reallocs[])(void *p, size_t size)={ realloc, nedrealloc, win32realloc };
-static void (*const frees[])(void *mem)={ free, nedfree, win32free };
-#else
-static void *_threadcode(void *a)
-{
- threadcode((int)(size_t) a);
- return 0;
-}
-#define THREADVAR pthread_t
-#define THREADINIT(v, id) pthread_create(v, NULL, _threadcode, (void *)(size_t) id)
-#define THREADSLEEP(v) usleep(v*1000)
-#define THREADWAIT(v) pthread_join(v, NULL)
-
-typedef unsigned long long usCount;
-static FORCEINLINE usCount GetUsCount()
-{
- struct timeval tv;
- gettimeofday(&tv, 0);
- return ((usCount) tv.tv_sec*1000000000000LL)+tv.tv_usec*1000000LL;
-}
-
-static void *(*const mallocs[])(size_t size)={ malloc, nedmalloc };
-static void *(*const reallocs[])(void *p, size_t size)={ realloc, nedrealloc };
-static void (*const frees[])(void *mem)={ free, nedfree };
-#endif
-static usCount times[THREADS];
-
-
-static FORCEINLINE unsigned int myrandom(unsigned int *seed)
-{
- *seed=1664525UL*(*seed)+1013904223UL;
- return *seed;
-}
-
-static void threadcode(int threadidx)
-{
- int n;
- unsigned int *toallocptr=threadstuff[threadidx].toalloc;
- void **allocptr=threadstuff[threadidx].allocs;
- unsigned int seed=threadidx;
- usCount start;
- threadstuff[threadidx].done=0;
- /*neddisablethreadcache(0);*/
- THREADSLEEP(100);
- start=GetUsCount();
-#ifdef TORTURETEST
- /* A randomised malloc/realloc/free test (torture test) */
- for(n=0; n<RECORDS*100; n++)
- {
- unsigned int r=myrandom(&seed), i;
- i=(int)(r % RECORDS);
- if(!allocptr[i])
- {
- allocptr[i]=mallocs[whichmalloc](r & 0x1FFF);
- threadstuff[threadidx].ops++;
- }
- else if(r & (1<<31))
- {
- allocptr[i]=reallocs[whichmalloc](allocptr[i], r & 0x1FFF);
- threadstuff[threadidx].ops++;
- }
- else
- {
- frees[whichmalloc](allocptr[i]);
- allocptr[i]=0;
- }
- }
- for(n=0; n<RECORDS; n++)
- {
- if(allocptr[n])
- {
- frees[whichmalloc](allocptr[n]);
- allocptr[n]=0;
- }
- }
-#else
- /* A simple stack which allocates and deallocates off the top (speed test) */
- for(n=0; n<RECORDS;)
- {
-#if 1
- r=myrandom(&seed);
- if(allocptr>threadstuff[threadidx].allocs && (r & 65535)<32760) /*<32760)*/
- { /* free */
- --toallocptr;
- --allocptr;
- --n;
- frees[whichmalloc](*allocptr);
- *allocptr=0;
- }
- else
-#endif
- {
- if(doRealloc && allocptr>threadstuff[threadidx].allocs && (r & 1))
- {
- allocptr[-1]=reallocs[whichmalloc](allocptr[-1], *toallocptr);
- }
- else
- {
- allocptr[0]=mallocs[whichmalloc](*toallocptr);
- allocptr++;
- }
- n++;
- toallocptr++;
- threadstuff[threadidx].ops++;
- }
- }
- while(allocptr>threadstuff[threadidx].allocs)
- {
- frees[whichmalloc](*--allocptr);
- }
-#endif
- times[threadidx]+=GetUsCount()-start;
- neddisablethreadcache(0);
- threadstuff[threadidx].done=1;
-}
-
-static double runtest()
-{
- unsigned int seed=1;
- int n, i;
- double opspersec=0;
- THREADVAR threads[THREADS];
- for(n=0; n<THREADS; n++)
- {
- unsigned int *toallocptr;
- int m;
- threadstuff[n].ops=0;
- times[n]=0;
- threadstuff[n].toalloc=toallocptr=calloc(RECORDS, sizeof(unsigned int));
- threadstuff[n].allocs=calloc(RECORDS, sizeof(void *));
- for(m=0; m<RECORDS; m++)
- {
- unsigned int size=myrandom(&seed);
- if(size<(1<<30))
- { /* Make it two power multiple of less than 512 bytes to
- model frequent C++ new's */
- size=4<<(size & 7);
- }
- else
- {
- size&=0x3FFF; /* < 16Kb */
- /*size&=0x1FFF;*/ /* < 8Kb */
- /*size=(1<<6)<<(size & 7);*/ /* < 8Kb */
- }
- *toallocptr++=size;
- }
- }
-#ifdef TORTURETEST
- for(n=0; n<THREADS; n++)
- {
- THREADINIT(&threads[n], n);
- }
- for(i=0; i<32; i++)
- {
- int found=-1;
- do
- {
- for(n=0; n<THREADS; n++)
- {
- THREADSLEEP(100);
- if(threadstuff[n].done)
- {
- found=n;
- break;
- }
- }
- } while(found<0);
- THREADWAIT(threads[found]);
- threads[found]=0;
- THREADINIT(&threads[found], found);
- printf("Relaunched thread %d\n", found);
- }
- for(n=THREADS-1; n>=0; n--)
- {
- THREADWAIT(threads[n]);
- threads[n]=0;
- }
-#else
-#if 1
- for(n=0; n<THREADS; n++)
- {
- THREADINIT(&threads[n], n);
- }
- for(n=THREADS-1; n>=0; n--)
- {
- THREADWAIT(threads[n]);
- threads[n]=0;
- }
-#else
- /* Quick realloc() test */
- doRealloc=1;
- for(n=0; n<THREADS; n++)
- {
- THREADINIT(&threads[n], n);
- }
- for(n=THREADS-1; n>=0; n--)
- {
- THREADWAIT(threads[n]);
- threads[n]=0;
- }
-#endif
-#endif
- {
- usCount totaltime=0;
- int totalops=0;
- for(n=0; n<THREADS; n++)
- {
- totaltime+=times[n];
- totalops+=threadstuff[n].ops;
- }
- opspersec=1000000000000.0*totalops/totaltime*THREADS;
- printf("This allocator achieves %lfops/sec under %d threads\n", opspersec, THREADS);
- }
- for(n=THREADS-1; n>=0; n--)
- {
- free(threadstuff[n].allocs); threadstuff[n].allocs=0;
- free(threadstuff[n].toalloc); threadstuff[n].toalloc=0;
- }
- return opspersec;
-}
-
-int main(void)
-{
- double std=0, ned=0;
-
-#if 0
- {
- usCount start, end;
- start=GetUsCount();
- THREADSLEEP(5000);
- end=GetUsCount();
- printf("Wait was %lf\n", (end-start)/1000000000000.0);
- }
-#endif
-#ifdef WIN32
- { /* Force load of user32.dll so we can debug */
- BOOL v;
- SystemParametersInfo(SPI_GETBEEP, 0, &v, 0);
- }
-#endif
-
- if(0)
- {
- printf("\nTesting standard allocator with %d threads ...\n", THREADS);
- std=runtest();
- }
- if(1)
- {
- printf("\nTesting nedmalloc with %d threads ...\n", THREADS);
- whichmalloc=1;
- ned=runtest();
- }
-#ifdef WIN32
- if(0)
- {
- ULONG data=2;
- win32heap=HeapCreate(0, 0, 0);
- HeapSetInformation(win32heap, HeapCompatibilityInformation, &data, sizeof(data));
- HeapQueryInformation(win32heap, HeapCompatibilityInformation, &data, sizeof(data), NULL);
- if(2!=data)
- {
- printf("The win32 low frag allocator won't work under a debugger!\n");
- }
- else
- {
- printf("Testing win32 low frag allocator with %d threads ...\n\n", THREADS);
- whichmalloc=2;
- runtest();
- }
- HeapDestroy(win32heap);
- }
-#endif
- if(std && ned)
- { // ned should have more ops/sec
- printf("\n\nnedmalloc allocator is %lf times faster than standard\n", ned/std);
- }
- printf("\nPress a key to trim\n");
- getchar();
- nedmalloc_trim(0);
-#ifdef _MSC_VER
- printf("\nPress a key to end\n");
- getchar();
-#endif
- return 0;
-}
|