diff options
Diffstat (limited to 'msvc/projects/vc2015')
7 files changed, 10 insertions, 112 deletions
diff --git a/msvc/projects/vc2015/jemalloc/jemalloc.vcxproj b/msvc/projects/vc2015/jemalloc/jemalloc.vcxproj index 2addd29..78f92c9 100644 --- a/msvc/projects/vc2015/jemalloc/jemalloc.vcxproj +++ b/msvc/projects/vc2015/jemalloc/jemalloc.vcxproj @@ -48,6 +48,7 @@ <ClCompile Include="..\..\..\..\src\hooks.c" /> <ClCompile Include="..\..\..\..\src\jemalloc.c" /> <ClCompile Include="..\..\..\..\src\large.c" /> + <ClCompile Include="..\..\..\..\src\log.c" /> <ClCompile Include="..\..\..\..\src\malloc_io.c" /> <ClCompile Include="..\..\..\..\src\mutex.c" /> <ClCompile Include="..\..\..\..\src\mutex_pool.c" /> @@ -56,7 +57,6 @@ <ClCompile Include="..\..\..\..\src\prng.c" /> <ClCompile Include="..\..\..\..\src\prof.c" /> <ClCompile Include="..\..\..\..\src\rtree.c" /> - <ClCompile Include="..\..\..\..\src\spin.c" /> <ClCompile Include="..\..\..\..\src\stats.c" /> <ClCompile Include="..\..\..\..\src\sz.c" /> <ClCompile Include="..\..\..\..\src\tcache.c" /> diff --git a/msvc/projects/vc2015/jemalloc/jemalloc.vcxproj.filters b/msvc/projects/vc2015/jemalloc/jemalloc.vcxproj.filters index 4edf09b..dba976e 100644 --- a/msvc/projects/vc2015/jemalloc/jemalloc.vcxproj.filters +++ b/msvc/projects/vc2015/jemalloc/jemalloc.vcxproj.filters @@ -70,9 +70,6 @@ <ClCompile Include="..\..\..\..\src\rtree.c"> <Filter>Source Files</Filter> </ClCompile> - <ClCompile Include="..\..\..\..\src\spin.c"> - <Filter>Source Files</Filter> - </ClCompile> <ClCompile Include="..\..\..\..\src\stats.c"> <Filter>Source Files</Filter> </ClCompile> @@ -91,5 +88,8 @@ <ClCompile Include="..\..\..\..\src\witness.c"> <Filter>Source Files</Filter> </ClCompile> + <ClCompile Include="..\..\..\..\src\log.c"> + <Filter>Source Files</Filter> + </ClCompile> </ItemGroup> </Project>
\ No newline at end of file diff --git a/msvc/projects/vc2015/test_threads/test_threads.cpp b/msvc/projects/vc2015/test_threads/test_threads.cpp deleted file mode 100644 index 92e3162..0000000 --- a/msvc/projects/vc2015/test_threads/test_threads.cpp +++ /dev/null @@ -1,88 +0,0 @@ -// jemalloc C++ threaded test -// Author: Rustam Abdullaev -// Public Domain - -#include <atomic> -#include <functional> -#include <future> -#include <random> -#include <thread> -#include <vector> -#include <stdio.h> -#include <jemalloc/jemalloc.h> - -using std::vector; -using std::thread; -using std::uniform_int_distribution; -using std::minstd_rand; - -int test_threads() { - je_malloc_conf = "narenas:3"; - int narenas = 0; - size_t sz = sizeof(narenas); - je_mallctl("opt.narenas", (void *)&narenas, &sz, NULL, 0); - if (narenas != 3) { - printf("Error: unexpected number of arenas: %d\n", narenas); - return 1; - } - static const int sizes[] = { 7, 16, 32, 60, 91, 100, 120, 144, 169, 199, 255, 400, 670, 900, 917, 1025, 3333, 5190, 13131, 49192, 99999, 123123, 255265, 2333111 }; - static const int numSizes = (int)(sizeof(sizes) / sizeof(sizes[0])); - vector<thread> workers; - static const int numThreads = narenas + 1, numAllocsMax = 25, numIter1 = 50, numIter2 = 50; - je_malloc_stats_print(NULL, NULL, NULL); - size_t allocated1; - size_t sz1 = sizeof(allocated1); - je_mallctl("stats.active", (void *)&allocated1, &sz1, NULL, 0); - printf("\nPress Enter to start threads...\n"); - getchar(); - printf("Starting %d threads x %d x %d iterations...\n", numThreads, numIter1, numIter2); - for (int i = 0; i < numThreads; i++) { - workers.emplace_back([tid=i]() { - uniform_int_distribution<int> sizeDist(0, numSizes - 1); - minstd_rand rnd(tid * 17); - uint8_t* ptrs[numAllocsMax]; - int ptrsz[numAllocsMax]; - for (int i = 0; i < numIter1; ++i) { - thread t([&]() { - for (int i = 0; i < numIter2; ++i) { - const int numAllocs = numAllocsMax - sizeDist(rnd); - for (int j = 0; j < numAllocs; j += 64) { - const int x = sizeDist(rnd); - const int sz = sizes[x]; - ptrsz[j] = sz; - ptrs[j] = (uint8_t*)je_malloc(sz); - if (!ptrs[j]) { - printf("Unable to allocate %d bytes in thread %d, iter %d, alloc %d. %d\n", sz, tid, i, j, x); - exit(1); - } - for (int k = 0; k < sz; k++) - ptrs[j][k] = tid + k; - } - for (int j = 0; j < numAllocs; j += 64) { - for (int k = 0, sz = ptrsz[j]; k < sz; k++) - if (ptrs[j][k] != (uint8_t)(tid + k)) { - printf("Memory error in thread %d, iter %d, alloc %d @ %d : %02X!=%02X\n", tid, i, j, k, ptrs[j][k], (uint8_t)(tid + k)); - exit(1); - } - je_free(ptrs[j]); - } - } - }); - t.join(); - } - }); - } - for (thread& t : workers) { - t.join(); - } - je_malloc_stats_print(NULL, NULL, NULL); - size_t allocated2; - je_mallctl("stats.active", (void *)&allocated2, &sz1, NULL, 0); - size_t leaked = allocated2 - allocated1; - printf("\nDone. Leaked: %zd bytes\n", leaked); - bool failed = leaked > 65536; // in case C++ runtime allocated something (e.g. iostream locale or facet) - printf("\nTest %s!\n", (failed ? "FAILED" : "successful")); - printf("\nPress Enter to continue...\n"); - getchar(); - return failed ? 1 : 0; -} diff --git a/msvc/projects/vc2015/test_threads/test_threads.h b/msvc/projects/vc2015/test_threads/test_threads.h deleted file mode 100644 index 64d0cdb..0000000 --- a/msvc/projects/vc2015/test_threads/test_threads.h +++ /dev/null @@ -1,3 +0,0 @@ -#pragma once - -int test_threads(); diff --git a/msvc/projects/vc2015/test_threads/test_threads.vcxproj b/msvc/projects/vc2015/test_threads/test_threads.vcxproj index f5e9898..325876d 100644 --- a/msvc/projects/vc2015/test_threads/test_threads.vcxproj +++ b/msvc/projects/vc2015/test_threads/test_threads.vcxproj @@ -310,8 +310,8 @@ </Link> </ItemDefinitionGroup> <ItemGroup> - <ClCompile Include="test_threads.cpp" /> - <ClCompile Include="test_threads_main.cpp" /> + <ClCompile Include="..\..\..\test_threads\test_threads.cpp" /> + <ClCompile Include="..\..\..\test_threads\test_threads_main.cpp" /> </ItemGroup> <ItemGroup> <ProjectReference Include="..\jemalloc\jemalloc.vcxproj"> @@ -319,7 +319,7 @@ </ProjectReference> </ItemGroup> <ItemGroup> - <ClInclude Include="test_threads.h" /> + <ClInclude Include="..\..\..\test_threads\test_threads.h" /> </ItemGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <ImportGroup Label="ExtensionTargets"> diff --git a/msvc/projects/vc2015/test_threads/test_threads.vcxproj.filters b/msvc/projects/vc2015/test_threads/test_threads.vcxproj.filters index 4c23340..fa4588f 100644 --- a/msvc/projects/vc2015/test_threads/test_threads.vcxproj.filters +++ b/msvc/projects/vc2015/test_threads/test_threads.vcxproj.filters @@ -11,15 +11,15 @@ </Filter> </ItemGroup> <ItemGroup> - <ClCompile Include="test_threads.cpp"> + <ClCompile Include="..\..\..\test_threads\test_threads.cpp"> <Filter>Source Files</Filter> </ClCompile> - <ClCompile Include="test_threads_main.cpp"> + <ClCompile Include="..\..\..\test_threads\test_threads_main.cpp"> <Filter>Source Files</Filter> </ClCompile> </ItemGroup> <ItemGroup> - <ClInclude Include="test_threads.h"> + <ClInclude Include="..\..\..\test_threads\test_threads.h"> <Filter>Header Files</Filter> </ClInclude> </ItemGroup> diff --git a/msvc/projects/vc2015/test_threads/test_threads_main.cpp b/msvc/projects/vc2015/test_threads/test_threads_main.cpp deleted file mode 100644 index 0a022fb..0000000 --- a/msvc/projects/vc2015/test_threads/test_threads_main.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "test_threads.h" -#include <future> -#include <functional> -#include <chrono> - -using namespace std::chrono_literals; - -int main(int argc, char** argv) { - int rc = test_threads(); - return rc; -} |