/** * \brief Function to generate a password * \fn generatePassword(std::string value1, std::string value2) * \param value1 a string used to generate the password * \param value2 a string used to generate the password * \return an encrypted message */ std::string UserServer::generatePassword(std::string value1, std::string value2) { std::string salt = "$1$"+value1 + convertToString(generateNumbers())+value2+"$"; std::string clef = value2+convertToString(generateNumbers()); return (std::string(crypt(clef.c_str(), salt.c_str())+salt.length())); }
int main(int argc, char **argv) { int rank, size; int i; double *A; double tick, tock, maxVal = -1.0; int root_hist[K], hist[K]; A = (double*)malloc(dimension*sizeof(double)); MPI_Init(&argc, &argv); MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_size(MPI_COMM_WORLD, &size); MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_RETURN); for (i = 0; i < K; i++) hist[i] = 0; for(i = 0; i < K; i++) root_hist[i] = 0; printf("dimension=%d\n", dimension); if(rank == 0) { generateNumbers(6935, A); } tick = MPI_Wtime(); MPI_Bcast(A, dimension, MPI_DOUBLE, 0, MPI_COMM_WORLD); tock = MPI_Wtime(); if(rank==0) printf("Processor %d, distribute to all proc: %f sec\n", rank, tock-tick); tick = MPI_Wtime(); histogram(A, hist, rank, size); tock = MPI_Wtime(); if(rank==0) printf("Processor %d, local histogram : %f sec\n", rank, tock-tick); tick = MPI_Wtime(); MPI_Reduce(hist, root_hist, K, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD); tock = MPI_Wtime(); if(rank == 0) printf("MPI_Reduce: %f sec\n", tock-tick); //Bcast tick = MPI_Wtime(); MPI_Bcast(root_hist, K, MPI_INT, 0, MPI_COMM_WORLD); tock = MPI_Wtime(); if(rank == 0) { printf("MPI_Bcast took %f sec\n", tock-tick); for (i = 0; i < K; i++) printf("Processor %d, hist[%d]: %d\n", rank, i, root_hist[i]); } MPI_Finalize(); return EXIT_SUCCESS; }
void MWC64XRandomNumberGenerator::generate(Buffer<float>& randomNumbersOut, const VECTOR_CLASS<cl::Event>* waitForEvents /*= nullptr*/, cl::Event* event /*= nullptr*/) { if (randomNumbersOut.getSize() != randomState_.getSize()) { randomState_.setSize(randomNumbersOut.getSize()); MWC64XSeedGenerator seedGenerator; seedGenerator.generateRandomSeeds(&randomState_, seed_, false); } BufferCL* rndState = randomState_.getEditableRepresentation<BufferCL>(); if (useGLSharing_) { SyncCLGL glSync; BufferCLGL* data = randomNumbersOut.getEditableRepresentation<BufferCLGL>(); // Acquire shared representations before using them in OpenGL // The SyncCLGL object will take care of synchronization between OpenGL and OpenCL glSync.addToAquireGLObjectList(data); glSync.aquireAllObjects(); generateNumbers(rndState, data, waitForEvents, event); } else { BufferCL* data = randomNumbersOut.getEditableRepresentation<BufferCL>(); generateNumbers(rndState, data, waitForEvents, event); } }
int main(int argc, char *argv[]) { srand((unsigned)time(NULL)); n = rand() % 30 + 1; if(argc == 2) { sscanf(argv[1], "%d", &n); } generateNumbers(a, 1, n); //printf("n= %d\n", n); //printf("original data\n"); printf("%d\n", n); display(a, 1, n); qsort(a+1, n, sizeof(a[1]), intsCmp); //printf("after sort\n"); //display(a, 1, n); s = sumInts(a, 1, n); intsCopy(b, a, 1, n); for(int i=1; i<=n; i++) { b[i] += b[i-1]; } //printf("list sum\n"); //display(b, 1, n); half = (double)s / 2; avg = (double)s / n; //printf("total weight:: %d\n", s); //printf("halg weight:: %.2lf\n", half); //printf("avg weight:: %.2lf\n", avg); clock_t t; t = clock(); trace(1, 0); t = clock() - t; printf("%lu clicks (%f secs)\n", t, (float)t / CLOCKS_PER_SEC); printf("%d %d\n", res, s - res); return 0; }
Graph( typename AdjacList::size_type const vertexSize = 0 ) { generateNumbers(vertexSize); }