From 311c5c078a9fc8ec6bb449fa685dbb1657d75d39 Mon Sep 17 00:00:00 2001
From: Benjamin Auder <benjamin.auder@somewhere>
Date: Mon, 17 Oct 2016 00:23:23 +0200
Subject: [PATCH] fix CGDS usage, compilation, check usability

---
 .gitignore                             |  3 ++-
 README.md                              |  2 +-
 code/README                            |  8 +++++---
 code/{ => src}/main.sh                 |  0
 code/src/stage1/Algorithm/pam.c        |  2 +-
 code/src/stage1/CMakeLists.txt         | 12 +++++++-----
 code/src/stage1/TimeSeries/serialize.c |  4 ++--
 code/src/stage1/Util/utils.c           |  2 +-
 code/src/stage1/main.c                 |  2 +-
 9 files changed, 20 insertions(+), 15 deletions(-)
 rename code/{ => src}/main.sh (100%)

diff --git a/.gitignore b/.gitignore
index 112c581..0372ddc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,5 @@
-/code/build/*
+/code/src/build/*
+/code/test/build/*
 /code/data/src/
 
 *.aux
diff --git a/README.md b/README.md
index d510f69..2b103b2 100644
--- a/README.md
+++ b/README.md
@@ -7,7 +7,7 @@ Joint work with [Jairo Cugliari](http://eric.univ-lyon2.fr/~jcugliari/),
 ---
 
 This program takes n time-series in input and is divided in two stages:
-  1) (Heuristic) k-medoids algorithm in parallel to obtain K centers, K << n
+	1) (Heuristic) k-medoids algorithm in parallel to obtain K centers, K << n
 	2) Filtering WER(?) to obtain the final k < K group representations.
 
 ---
diff --git a/code/README b/code/README
index ccb3a0f..5546cf6 100644
--- a/code/README
+++ b/code/README
@@ -1,14 +1,16 @@
 To compile source code :
 
-   cd build
-   cmake ../src
+   (mkdir -p (src|test)/build
+   cd (src|test)/build
+   cmake ..
    make
 
 Usage :
 
-   ppam-mpi cluster ifilename nbSeriesInChunk nbClusters randomize p_for_dissims
+   mpirun -np nbProcess ppam.exe cluster ifilename nbSeriesInChunk nbClusters randomize p_for_dissims
 
 Where :
+   nbProcess = number of simultaneous processes
    ifilename = path to serialized dataset (read below)
    nbSeriesInChunk = number of time-series to process sequentially
    nbClusters = number of clusters
diff --git a/code/main.sh b/code/src/main.sh
similarity index 100%
rename from code/main.sh
rename to code/src/main.sh
diff --git a/code/src/stage1/Algorithm/pam.c b/code/src/stage1/Algorithm/pam.c
index 4e3dfac..7cde367 100644
--- a/code/src/stage1/Algorithm/pam.c
+++ b/code/src/stage1/Algorithm/pam.c
@@ -1,6 +1,6 @@
 #include "Util/types.h"
 #include "Util/rng.h"
-#include <cds/Vector.h>
+#include <cgds/Vector.h>
 #include <stdlib.h>
 #include <math.h>
 
diff --git a/code/src/stage1/CMakeLists.txt b/code/src/stage1/CMakeLists.txt
index e69ca5d..b69602f 100644
--- a/code/src/stage1/CMakeLists.txt
+++ b/code/src/stage1/CMakeLists.txt
@@ -11,9 +11,11 @@ include_directories("${CMAKE_SOURCE_DIR}")
 #ppam executable (serialize, cluster, classif)
 
 #cds
-find_path(CDS_INCLUDE_PATH "cds/cds.h")
-find_library(CDS_LIBRARY cds)
-include_directories(${CDS_INCLUDE_PATH})
+set(CGDS_INCLUDE_PATH "/usr/local/include/cgds")
+#set(CGDS_LIBRARY "/usr/local/lib/libcgds.so")
+#find_path(CDS_INCLUDE_PATH "cgds/cgds.h")
+#find_library(CGDS_LIBRARY cgds)
+include_directories(${CGDS_INCLUDE_PATH})
 
 #GSL: standard location
 find_path(GSL_INCLUDE_PATH "gsl/gsl_linalg.h")
@@ -33,8 +35,8 @@ include_directories(${LIBXML2_INCLUDE_DIR})
 file(GLOB_RECURSE ppam_src "${CMAKE_SOURCE_DIR}/*.c")
 add_executable(ppam.exe ${ppam_src})
 add_library(ppam SHARED ${ppam_src})
-target_link_libraries(ppam.exe m cds ${MPI_LIBRARIES} ${LIBXML2_LIBRARIES} ${GSL_LIBRARIES} ${CDS_LIBRARY})
-target_link_libraries(ppam m cds ${MPI_LIBRARIES} ${LIBXML2_LIBRARIES} ${GSL_LIBRARIES} ${CDS_LIBRARY})
+target_link_libraries(ppam.exe m cgds ${MPI_LIBRARIES} ${LIBXML2_LIBRARIES} ${GSL_LIBRARIES})# ${CGDS_LIBRARY})
+target_link_libraries(ppam m cgds ${MPI_LIBRARIES} ${LIBXML2_LIBRARIES} ${GSL_LIBRARIES})# ${CGDS_LIBRARY})
 
 if (MPI_COMPILE_FLAGS)
 	set_target_properties(ppam.exe PROPERTIES
diff --git a/code/src/stage1/TimeSeries/serialize.c b/code/src/stage1/TimeSeries/serialize.c
index ab552c9..88b15f1 100644
--- a/code/src/stage1/TimeSeries/serialize.c
+++ b/code/src/stage1/TimeSeries/serialize.c
@@ -4,7 +4,7 @@
 #include <math.h>
 #include "Util/types.h"
 #include "Util/utils.h"
-#include <cds/Vector.h>
+#include <cgds/Vector.h>
 #include <string.h>
 
 // parse a line into two integers (ID, raw power)
@@ -156,7 +156,7 @@ void serialize_byCols(const char* ifileName, const char* ofileName, uint32_t nbI
 		{
 			//just starting a new time-series: must process the last one (if there is a last one !)
 			if (lastID > 0)
-			{				
+			{
 				if (tsLength == refTsLength && !overflow)
 				{
 					seriesCount++;
diff --git a/code/src/stage1/Util/utils.c b/code/src/stage1/Util/utils.c
index 3786eda..9713e30 100644
--- a/code/src/stage1/Util/utils.c
+++ b/code/src/stage1/Util/utils.c
@@ -1,6 +1,6 @@
 #include "Util/utils.h"
 #include <math.h>
-#include <cds/Vector.h>
+#include <cgds/Vector.h>
 
 void free_work(Work_t* work)
 {
diff --git a/code/src/stage1/main.c b/code/src/stage1/main.c
index bb4bd46..992b97c 100644
--- a/code/src/stage1/main.c
+++ b/code/src/stage1/main.c
@@ -10,7 +10,7 @@
 #include "TimeSeries/deserialize.h"
 #include "Classification/getClass.h"
 #include <string.h>
-#include <cds/Vector.h>
+#include <cgds/Vector.h>
 #include <libxml/xmlreader.h>
 
 // serialize text file argv[1] into a binary file argv[2]
-- 
2.44.0