Skip to content

Demo produces different results in DEBUG and non-DEBUG mode #1

@zzxx-husky

Description

@zzxx-husky

Hi, this work is very interesting to me and I wanna try this in one of our project, where I need to frequently answer whether a vertex (i.e., an integer) exists in the adjacency list (i.e., a sorted integer array) of another vertex.

However, I find a problem when running the demo example in my personal laptop. If I compile in non-DEBUG mode, the demo compains about incorrect result, while if I compile in DEBUG mode, the demo runs successfully and correctly. The problem seems bin_searcher.scalar(...) does not return correct results under non-DEBUG mode.

zzxx@DESKTOP-75K7HNQ:~/repos/FastBinarySearch/source/demo | master
$ git log -n 1
commit ce8e7fe1801968170b866430cfef1939ee99ae23 (HEAD -> master, origin/master, origin/HEAD)
Author: fabiocannizzo <fabio_cannizzo@yahoo.com>
Date:   Thu Aug 8 13:17:33 2019 +0800

    update links in readme
zzxx@DESKTOP-75K7HNQ:~/repos/FastBinarySearch/source/demo | master
$ git status
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean
zzxx@DESKTOP-75K7HNQ:~/repos/FastBinarySearch/source/demo | master
$ make all
platform=Linux
compiler=g++
g++ -c -std=c++0x -I../include -mfma -mavx2 -O3 demo.cpp -o bin/demo.o
g++  bin/demo.o -o bin/demo
rm bin/demo.o
zzxx@DESKTOP-75K7HNQ:~/repos/FastBinarySearch/source/demo | master
$ ./bin/demo
scalar results:
4 <= 1 < 5
incorrect result!zzxx@DESKTOP-75K7HNQ:~/repos/FastBinarySearch/source/demo | master
$ DEBUG=1 make all
platform=Linux
compiler=g++
make: Nothing to be done for 'all'.
zzxx@DESKTOP-75K7HNQ:~/repos/FastBinarySearch/source/demo | master
$ touch Makefile
zzxx@DESKTOP-75K7HNQ:~/repos/FastBinarySearch/source/demo | master
$ DEBUG=1 make all
platform=Linux
compiler=g++
g++ -c -std=c++0x -I../include -mfma -mavx2 -g -DDEBUG demo.cpp -o bin/demo.o
g++  bin/demo.o -o bin/demo
rm bin/demo.o
zzxx@DESKTOP-75K7HNQ:~/repos/FastBinarySearch/source/demo | master
$ ./bin/demo
scalar results:
1 <= 1 < 2
2 <= 2 < 4
4 <= 4 < 5
5 <= 5 < 9
1 <= 1.5 < 2
2 <= 2.5 < 4
4 <= 4.8 < 5
5 <= 8.2 < 9
vectorial results:
1 <= 1 < 2
2 <= 2 < 4
4 <= 4 < 5
5 <= 5 < 9
1 <= 1.5 < 2
2 <= 2.5 < 4
4 <= 4.8 < 5
5 <= 8.2 < 9
zzxx@DESKTOP-75K7HNQ:~/repos/FastBinarySearch/source/demo | master
$

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions