-3

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.

talonmies
  • 70,661
  • 34
  • 192
  • 269
user14717
  • 4,757
  • 2
  • 44
  • 68
  • 1
    If you compile the code directly with g++ rather than nvcc, does the core dump occur? – talonmies Oct 11 '17 at 23:19
  • No, it does not. I am going to close since it doesn't core dump using g++-5. – user14717 Oct 11 '17 at 23:22
  • I'm willing to close this question, but it's not totally useless for people to know that nvcc+gcc-4 segfaults on Ubuntu 17. . . lemme know your opinion. – user14717 Oct 11 '17 at 23:31

1 Answers1

-2

Almost 99% of the time, this error means that you broke something or you are accessing corrupted memory zones (or even too many recursion with went over the stack limit).

Use free tools like Valgrind or your favorite IDE debugger to get a hint on where this is happenning and why.

rak007
  • 973
  • 12
  • 26