-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Larson sized deallocation test #25
Conversation
Looks interesting to me as a test. I have posted a diff here to make it easier to see what you have changed. --- larson\larson.cpp 2021-02-26 10:16:01.360644200 +0000
+++ larson_sized\larson.cpp 2021-03-04 11:20:20.151509500 +0000
@@ -29,7 +29,6 @@
#include <pthread.h>
#endif
-
typedef void * LPVOID;
typedef long long LONGLONG;
typedef long DWORD;
@@ -177,7 +176,7 @@
int max_size ;
char * *array ;
- int *blksize ;
+ size_t *blksize ;
int asize ;
long cAllocs ;
@@ -200,7 +199,7 @@
ULONG CountReservedSpace() ;
char * blkp[MAX_BLOCKS] ;
-int blksize[MAX_BLOCKS] ;
+size_t blksize[MAX_BLOCKS] ;
long seqlock=0 ;
struct lran2_st rgen ;
int min_size=10, max_size=500 ;
@@ -353,7 +352,7 @@
{
int cblks ;
int victim ;
- int blk_size ;
+ size_t blk_size ;
#ifdef __WIN32__
_LARGE_INTEGER ticks_per_sec, start_cnt, end_cnt;
#else
@@ -388,7 +387,7 @@
for( cblks=0; cblks<num_chunks; cblks++){
victim = lran2(&rgen)%num_chunks ;
#if defined(CPP)
- delete[] blkp[victim] ;
+ operator delete[] (blkp[victim], blksize[victim]);
#elif defined(USE_MALLOC)
free(blkp[victim]);
#else
@@ -578,7 +577,7 @@
thread_data *pdea;
int cblks=0 ;
int victim ;
- long blk_size ;
+ size_t blk_size;
int range ;
if( stopflag ) return 0;
@@ -592,7 +591,7 @@
for( cblks=0; cblks<pdea->NumBlocks; cblks++){
victim = lran2(&pdea->rgen)%pdea->asize ;
#ifdef CPP
- delete[] pdea->array[victim] ;
+ operator delete[] (pdea->array[victim], pdea->blksize[victim]);
#else
CUSTOM_FREE(pdea->array[victim]) ;
#endif
@@ -652,8 +651,9 @@
{
int cblks ;
int victim ;
- int blk_size ;
+ size_t blk_size ;
LPVOID tmp ;
+ size_t tmp_sz;
for( cblks=0; cblks<num_chunks; cblks++){
@@ -675,14 +675,17 @@
for( cblks=num_chunks; cblks > 0 ; cblks--){
victim = lran2(&rgen)%cblks ;
tmp = blkp[victim] ;
+ tmp_sz = blksize[victim];
blkp[victim] = blkp[cblks-1] ;
+ blksize[victim] = blksize[cblks-1];
blkp[cblks-1] = (char *) tmp ;
+ blksize[cblks-1] = tmp_sz;
}
for( cblks=0; cblks<4*num_chunks; cblks++){
victim = lran2(&rgen)%num_chunks ;
#ifdef CPP
- delete[] blkp[victim] ;
+ operator delete[] (blkp[victim], blksize[victim]);
#else
CUSTOM_FREE(blkp[victim]) ;
#endif |
Just realized that we could have used the same source file even though there are two tests. I'll fix this, then the diff will be obvious. |
Below is an example test run. Especially
|
Apologies for the super late reply :-( I remember being a tad hesitant when I first saw this as Larson is used in many papers and if we change it we should perhaps rename it? So, I think it would be better as larson2 or something? not sure |
I have already renamed this to Larson-sized. The original Larson-test remains there. I can change this to Larson2, if you prefer that one, but I personally cannot see how it is better. Naming is always hard :) |
Ah, I did not notice that -- this is great. Thanks so much! |
Larson sized deallocation test. This will call delete[] operator with size to test sized deallocation path.
The test can be run with following: