Commit 0bc5140b authored by Marina Kolpakova's avatar Marina Kolpakova

allocate CPU memory if Tegra GPU allocator failed.

parent baa81de1
...@@ -217,8 +217,23 @@ void Mat::create(int d, const int* _sizes, int _type) ...@@ -217,8 +217,23 @@ void Mat::create(int d, const int* _sizes, int _type)
} }
else else
{ {
#ifdef HAVE_TGPU
try
{
allocator->allocate(dims, size, _type, refcount, datastart, data, step.p);
CV_Assert( step[dims-1] == (size_t)CV_ELEM_SIZE(flags) );
}catch(...)
{
allocator = 0;
size_t total = alignSize(step.p[0]*size.p[0], (int)sizeof(*refcount));
data = datastart = (uchar*)fastMalloc(total + (int)sizeof(*refcount));
refcount = (int*)(data + total);
*refcount = 1;
}
#else
allocator->allocate(dims, size, _type, refcount, datastart, data, step.p); allocator->allocate(dims, size, _type, refcount, datastart, data, step.p);
CV_Assert( step[dims-1] == (size_t)CV_ELEM_SIZE(flags) ); CV_Assert( step[dims-1] == (size_t)CV_ELEM_SIZE(flags) );
#endif
} }
} }
......
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