inject soft and hard failures according to exponential and weibull distribution
[charm.git] / src / ck-core / init.C
index aa21e78eb1c1a220b8ebf98bfc228e7ad3a8acec..fa7fc13d5fbbc25314c856d565b6e08e0e4adcf8 100644 (file)
@@ -209,6 +209,11 @@ extern char *killFile;
 extern char * failureDist;
 //mean time between failure in seconds
 extern int MTBF;
+extern int SMTBF;
+//shape and scale parameter for Weibull distribution
+extern double beta;
+extern double alpha;
+extern double s_alpha;
 // function for reading the kill file
 void readKillFile();
 // function to genrate failures according to distribution
@@ -285,20 +290,45 @@ static inline void _parseCommandLineOpts(char **argv)
   //reading failure distribution
   if(CmiGetArgStringDesc(argv,"+failureInject", &failureDist,"Runtime system injects failure")){
     if (CmiGetArgIntDesc(argv,"+MTBF",&MTBF,"Mean time between failures")){
+      if(CmiMyPe()==0)
+        printf("Mean time between hard failures is %d\n",MTBF);
       killFlag = 2;
-      if(CmiMyPe()==0){
-        if(strcmp(failureDist, "E")==0){
+      if(strcmp(failureDist, "E")==0){
+        if(CmiMyPe()==0)
           printf("Runtime system generates faiures according to exponential distribution\n");
-        }else if(strcmp(failureDist, "W")==0){
+      }else if(strcmp(failureDist, "W")==0){
+        if(CmiMyPe()==0)
           printf("Runtime system generates faiures according to weibull distribution\n");
+        if(!CmiGetArgDoubleDesc(argv,"+shape",&beta,"shape parameter for Weibull distribution")){
+          if(CmiMyPe()==0)
+            CmiAbort("should provide shape parameter for Weibull distribution");
+        }else{
+          alpha = MTBF/tgammaf(1+1/beta);
         }
+      }else{
+        if(CmiMyPe()==0)
+          CmiAbort("unknown failure distribution");
       }
       int seed;
       if (!CmiGetArgIntDesc(argv,"+failureSeed",&seed,"seed to generate the random sequencea")){
-        CkAbort("Needs to provide failure seed");
+        if(CmiMyPe()==0)
+          CmiAbort("Needs to provide failure seed");
       }else{
         failureSeed = seed;
       }
+      if (CmiGetArgIntDesc(argv,"+SMTBF",&SMTBF,"Mean time between failures")){
+        if(CmiMyPe()==0)
+          printf("Mean time between soft failures is %d\n",SMTBF);
+        if(strcmp(failureDist,"W")==0){
+          s_alpha = SMTBF/tgammaf(1+1/beta);
+        }
+      }else{
+        SMTBF = -1;
+      }
+    }
+    else{
+      if(CmiMyPe()==0)
+        CmiAbort("should specify the MTBF for failure injections");
     }
   }