I'm attempting to benchmark some CUDA code using google benchmark. To start, I haven't written any CUDA code, and just want to make sure I can benchmark a host function compiled with nvcc
. In main.cu
I have
#include <benchmark/benchmark.h>
size_t fibr(size_t n)
{
if (n == 0)
return 0;
if (n == 1)
return 1;
return fibr(n-1)+fibr(n-2);
}
static void BM_FibRecursive(benchmark::State& state)
{
size_t y;
while (state.KeepRunning())
{
benchmark::DoNotOptimize(y = fibr(state.range(0)));
}
}
BENCHMARK(BM_FibRecursive)->RangeMultiplier(2)->Range(1, 1<<5);
BENCHMARK_MAIN();
I compile with:
nvcc -g -G -Xcompiler -Wall -Wno-deprecated-gpu-targets --std=c++11 main.cu -o main.x -lbenchmark
When I run the program, I get the following error:
./main.x
main.x: malloc.c:2405: sysmalloc: Assertion `(old_top == initial_top (av) && old_size == 0) || ((unsigned long) (old_size) >= MINSIZE && prev_inuse (old_top) && ((unsigned long) old_end & (pagesize - 1)) == 0)' failed.
[1] 11358 abort (core dumped) ./main.x
I have explicitly pointed nvcc
to g++-4.9
and g++-4.8
using -ccbin g++-4.x
and have reproduced the problem with both versions of g++
.
Is there anything obviously wrong here? How can the problem be fixed?
I'm on Ubuntu 17.04 and NVIDIA driver version 375.82, if it matters.
Update: I installed g++-5
, and the core dump went away.