void setsize ( Array<Float32,100>& __data ) { if (validatesize( __data ) ) { size = __data; isSetsize = true; } else throw "Error validating size"; }
/* Validatior for all variables at once */ bool validate ( CertificateHeader& __data ) { bool bVal = true; bVal &= validatesize( __data.size ); bVal &= validateversion( __data.version ); bVal &= validatemyfield( __data.myfield ); return bVal; }
int main(int argc, char **argv){ char c; size_t object_int; size_t object_size; clock_t starttime, stoptime; double runtime; while ((c = getopt (argc, argv, "q:m:c:")) != -1){ switch (c){ case 'q': quitf = 0; break; case 'm': size = atoi(optarg); break; case 'c': proc = atoi(optarg); break; default: printf("usage: ./primemproc [-q] [-m] max # to calculate [-c] max # of process"); //http://courses.cms.caltech.edu/cs11/material/general/usage.html break; } } size = validatesize(size); proc = validateinput(proc); starttime = clock(); object_int = (int)((size / BITCOUNT) + 1); object_size = object_int * sizeof(size_t); threadstack = malloc(object_size); //from lecture http://web.engr.oregonstate.edu/~chaneyr/lectures/18-shared_memory.mp4 //initialize threadstack initialize(); //thread mpthread(); stoptime = clock(); runtime = (double)(stoptime - starttime)/CLOCKS_PER_SEC; //print printf("Program completed!\n"); printf("Runtime %f seconds\n", runtime); //unmap and unlink shared memory object free(threadstack); return 0; }