Why ignore my changes?

I am trying to use E²LSH , here is the manual . When unpacked, this library folder contains a Makefile, a bin folder, and a source folder (among other things).

There is one in the original folder LSHMain.cpp

which I have to change.

I deleted the project (just to make sure I didn't destroy anything), reload it by modifying the file and then I hit make, but when I run the executable it looks like all my modifications are gone, and source code only counts!

This happens regardless of creating a project from scratch or not.

I suspect it has to do with scripts inside the bin folder because I have to run it like this:

bin/lsh argument_list

      

What should I change?

Here is the Makefile (minified as some things don't matter)

SOURCES_DIR:=sources
OBJ_DIR:=bin
OUT_DIR:=bin
TEST_DIR:=$(SOURCES_DIR)

#H_SOURCES:=`find $(SOURCES_DIR) -name "*.h"`
#CPP_SOURCES:=`find $(SOURCES_DIR) -name "*.cpp"`
#TEST_SOURCES:=`find $(TEST_DIR) -name "*.cpp"`
OBJ_SOURCES:=$(SOURCES_DIR)/BucketHashing.cpp \
         $(SOURCES_DIR)/Geometry.cpp \
         $(SOURCES_DIR)/LocalitySensitiveHashing.cpp \
         $(SOURCES_DIR)/Random.cpp \
         $(SOURCES_DIR)/Util.cpp \
         $(SOURCES_DIR)/GlobalVars.cpp \
         $(SOURCES_DIR)/SelfTuning.cpp \
         $(SOURCES_DIR)/NearNeighbors.cpp

LSH_BUILD:=LSHMain

TEST_BUILDS:=exactNNs \
            genDS \
        compareOutputs \
        genPlantedDS

GCC:=g++
OPTIONS:=-O3 -DREAL_FLOAT -DDEBUG
# -march=athlon -msse -mfpmath=sse
LIBRARIES:=-lm 
#-ldmalloc

all: 
    bin/compile

c: compile

compile:
    @mkdir -p $(OUT_DIR)
    $(GCC) -o $(OUT_DIR)/$(LSH_BUILD) $(OPTIONS) $(OBJ_SOURCES) $(SOURCES_DIR)/$(LSH_BUILD).cpp $(LIBRARIES)
    chmod g+rwx $(OUT_DIR)/$(LSH_BUILD)

      

and here are the compilation and lsh scripts (inside bin folder, Makefile was in the same directory with source and bin folders):

#!/bin/bash

OUT_DIR=bin
SOURCES_DIR=sources
OBJ_SOURCES="$SOURCES_DIR/BucketHashing.cpp \
            $SOURCES_DIR/Geometry.cpp \
            $SOURCES_DIR/LocalitySensitiveHashing.cpp \
            $SOURCES_DIR/Random.cpp \
            $SOURCES_DIR/Util.cpp \
            $SOURCES_DIR/GlobalVars.cpp \
            $SOURCES_DIR/SelfTuning.cpp \
            $SOURCES_DIR/NearNeighbors.cpp"

TEST_BUILDS="exactNNs \
            genDS \
            compareOutputs \
            genPlantedDS"

defineFloat=REAL_FLOAT

g++ -o $OUT_DIR/testFloat -DREAL_FLOAT $OBJ_SOURCES $SOURCES_DIR/testFloat.cpp -lm >/dev/null 2>&1 || defineFloat=REAL_DOUBLE

OPTIONS="-O3 -D$defineFloat"

g++ -o $OUT_DIR/LSHMain $OPTIONS $OBJ_SOURCES $SOURCES_DIR/LSHMain.cpp -lm

chmod g+rwx $OUT_DIR/LSHMain

for i in $TEST_BUILDS; do
   g++ -o ${OUT_DIR}/$i $OPTIONS ${SOURCES_DIR}/${i}.cpp $OBJ_SOURCES -lm; chmod g+rwx $OUT_DIR/${i}; 

done

      

lsh script

#!/bin/bash

dir=bin

if [ $# -le 2 ]; then
  echo Usage: $0 radius data_set_file query_set_file "[successProbability]"
  exit
fi

paramsFile=$2.params

if [ $# -ge 4 ]; then
 # success probability supplied
 $dir/lsh_computeParams $1 "$2" "$3" $4 > "$paramsFile" || exit 1
else
 # success probability not supplied
 $dir/lsh_computeParams $1 "$2" "$3" > "$paramsFile" || exit 1
fi

chmod g+rw "$paramsFile"

echo "R*******" >/dev/stderr
echo "R*********************" >/dev/stderr
echo "R-NN DS params computed." >/dev/stderr
echo "R*********************" >/dev/stderr
echo "R*******" >/dev/stderr

$dir/lsh_fromParams "$2" "$3" "$paramsFile"

      


EDIT_1

When I run make

I get:

bin/compile
sources/LocalitySensitiveHashing.cpp: In function ‘RNNParametersT readRNNParameters(FILE*)’:
sources/LocalitySensitiveHashing.cpp:62:22: warning: ignoring return value of ‘int fscanf(FILE*, const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
(many many warnings, but no errors, I have checked that I can execute the program afterwards)

      

With make c

I got:

g++ -o bin/LSHMain -O3 -DREAL_FLOAT -DDEBUG sources/BucketHashing.cpp sources/Geometry.cpp sources/LocalitySensitiveHashing.cpp sources/Random.cpp sources/Util.cpp sources/GlobalVars.cpp sources/SelfTuning.cpp sources/NearNeighbors.cpp sources/LSHMain.cpp -lm 
warnings
chmod g+rwx bin/LSHMain

      

I really don't understand why it didn't work ....

With make compile

I got:

g++ -o bin/LSHMain -O3 -DREAL_FLOAT -DDEBUG sources/BucketHashing.cpp sources/Geometry.cpp sources/LocalitySensitiveHashing.cpp sources/Random.cpp sources/Util.cpp sources/GlobalVars.cpp sources/SelfTuning.cpp sources/NearNeighbors.cpp sources/LSHMain.cpp -lm
warnings
chmod g+rwx bin/LSHMain

      


EDIT_2

lsh_comouteParams:

#!/bin/bash

successProbability=0.9


if [ $# -le 1 ]; then
  echo Usage: $0 radius data_set_file "{query_set_file | .} [successProbability]"
  exit
fi

if [ $# -ge 4 ]; then
 # success probability supplied
 successProbability=$4
fi

arch=`uname`
nDataSet=` wc -l "$2"`
for x in $nDataSet; do nDataSet=$x; break; done
if [ "$3" != "." ]; then
  nQuerySet=` wc -l "$3"`
  for x in $nQuerySet; do nQuerySet=$x; break; done
else
  nQuerySet=0
fi
dimension=`head -1 "$2" | wc -w`

#echo $nDataSet $nQuerySet $dimension



if [ -e bin/mem ]; then
  m=`cat bin/mem`;
elif [ "$arch" = "Darwin" ]
then
  #http://discussions.apple.com/thread.jspa?threadID=1608380&tstart=0
  m=`top -l 1 | grep PhysMem | awk -F "[M,]" ' {print$10 }'`
  let m=m*1024*1024
  echo $m > bin/mem
else
  s=`free -m | grep "Mem:"`
  for i in $s; do m=$i; if [ "$i" != "Mem:" ]; then break; fi; done
  m=${m}000000
  echo $m > bin/mem
fi


bin/LSHMain $nDataSet $nQuerySet $dimension $successProbability "$1" "$2" "$3" $m -c

      

+3


source to share


1 answer


I changed the file as such:

int main(int nargs, char **args){
printf("uoo\n");return 0;
  if(nargs < 9){
    usage(args[0]);
    exit(1);
  }
  ...
}

      

When E²LSH does not receive the correct arguments, it will not run its LSHMain (regardless of the fact that there is corresponding code in that file), which I tricked me so much because I thought I was getting that point inside main()

).

There is a script folder in the bin folder that will take over and print the same message as usage()

, so I thought I achieved this call. The function call lies inside if(nargs < 9)

, which made me give fewer arguments in return so that he was sure that the algorithm (which takes time) would and would not be executed inside it.




In short:

To achieve what the code is executing source/LSHMain.cpp

, one must pass the correct arguments to bin/lsh

. If not, the bin/lsh

script will only execute, thereby obscuring the changes made to source/LSHMain.cpp

.

Hopefully this answer will motivate future users to avoid such a pitfall. Special thanks to Etan Reisner who helped me out and ultimately got me thinking about deleting source/LSHMain.cpp

, which made me figure out what was going on.

+1


source







All Articles