Commit 25445ab3 authored by incardon's avatar incardon
Browse files

Adding garbage injector option

parent 5156694a
Pipeline #2715 passed with stages
in 13 seconds
......@@ -174,6 +174,9 @@ ${DEFINE_STDC_HEADERS}
/* If an error occur stop the program */
${DEFINE_STOP_ON_ERROR}
/* Garbage injector*/
${DEFINE_GARBAGE_INJECTOR}
/* Test coverage mode */
${DEFINE_TEST_COVERAGE_MODE}
......
......@@ -43,7 +43,12 @@ bool CudaMemory::allocate(size_t sz)
CUDA_SAFE_CALL(cudaMalloc(&dm,sz));
#else
if (sz != 0)
{dm = new unsigned char[sz];}
{
dm = new unsigned char[sz];
#ifdef GARBAGE_INJECTOR
memset(dm,0xFF,sz);
#endif
}
#endif
}
else
......@@ -126,6 +131,9 @@ void CudaMemory::allocate_host(size_t sz) const
CUDA_SAFE_CALL(cudaHostAlloc(&hm,sz,cudaHostAllocMapped))
#else
hm = new unsigned char[sz];
#ifdef GARBAGE_INJECTOR
memset(hm,0xFF,sz);
#endif
#endif
}
}
......@@ -264,6 +272,9 @@ bool CudaMemory::resize(size_t sz)
CUDA_SAFE_CALL(cudaMalloc(&tdm,sz));
#else
tdm = new unsigned char [sz];
#ifdef GARBAGE_INJECTOR
memset(tdm,0xFF,sz);
#endif
#endif
#ifdef FILL_CUDA_MEMORY_WITH_MINUS_ONE
......@@ -291,6 +302,9 @@ bool CudaMemory::resize(size_t sz)
CUDA_SAFE_CALL(cudaHostAlloc(&thm,sz,cudaHostAllocMapped));
#else
thm = new unsigned char [sz];
#ifdef GARBAGE_INJECTOR
memset(thm,0xFF,sz);
#endif
#endif
}
......
......@@ -34,7 +34,12 @@ bool HeapMemory::allocate(size_t sz)
{
//! Allocate the device memory
if (dm == NULL)
{dmOrig = new byte[sz+alignement+extra_pad];}
{
dmOrig = new byte[sz+alignement+extra_pad];
#ifdef GARBAGE_INJECTOR
memset(dmOrig,0xFF,sz+alignement+extra_pad);
#endif
}
else
{
std::cerr << __FILE__ << ":" << __LINE__ << " error memory already allocated\n";
......@@ -174,6 +179,9 @@ bool HeapMemory::resize(size_t sz)
byte * tdm;
byte * tdmOrig;
tdmOrig = new byte[sz+alignement+extra_pad];
#ifdef GARBAGE_INJECTOR
memset(tdmOrig,0xFF,sz+alignement+extra_pad);
#endif
tdm = tdmOrig;
//! size plus alignment
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment