Ajout des cas de tests pour les TP non-graphiques. Cleanage en tous genres.
[GPU.git] / WCudaMSE / Student_Cuda / src / cpp / main.cpp
index 495aa65..7c3dc42 100755 (executable)
@@ -1,14 +1,13 @@
 #include <iostream>
+#include <vector>
 #include <stdlib.h>
 #include <assert.h>
+using namespace std;
 
 #include "cudaTools.h"
 #include "Device.h"
 #include "LimitsTools.h"
 
-using std::cout;
-using std::endl;
-
 /*----------------------------------------------------------------------*\
  |*                    Declaration                                     *|
  \*---------------------------------------------------------------------*/
@@ -17,21 +16,21 @@ using std::endl;
  |*            Imported                *|
  \*-------------------------------------*/
 
-extern int mainCore();
+extern int mainCore(const vector<string>& args);
 extern int mainTest();
 
 /*--------------------------------------*\
  |*            Public                  *|
  \*-------------------------------------*/
 
-int main(void);
+int main(int argc, char** argv);
 
 /*--------------------------------------*\
  |*            Private                 *|
  \*-------------------------------------*/
 
 static void initCuda(int deviceId);
-static int start(void);
+static int start(const vector<string>& args);
 
 /*----------------------------------------------------------------------*\
  |*                    Implementation                                  *|
@@ -41,10 +40,14 @@ static int start(void);
  |*            Public                  *|
  \*-------------------------------------*/
 
-int main(void)
+int main(int argc, char** argv)
     {
     cout << "main" << endl;
 
+    vector<string> args;
+    for (int i = 1; i < argc; ++i)
+        args.push_back(argv[i]);
+
     // LimitsTools::rappelTypeSize();
 
     if (Device::isCuda())
@@ -56,7 +59,7 @@ int main(void)
        // Server Cuda2: in [0,2]
        int deviceId = 0;
 
-       int isOk = start();
+       int isOk = start(args);
 
        //cudaDeviceReset causes the driver to clean up all state.
        // While not mandatory in normal operation, it is good practice.
@@ -86,19 +89,17 @@ void initCuda(int deviceId)
     // Device::loadCudaDriverAll();// Force driver to be load for all GPU
     }
 
-int start(void)
+int start(const vector<string>& args)
     {
     Device::printCurrent();
 
-    bool IS_TEST = false;
-
-    if (IS_TEST)
-       {
+    if (args.size() == 0 || args[0] == "tests")
+        {
        return mainTest();
        }
     else
        {
-       return mainCore();
+       return mainCore(args);
        }
     }