void Foam::cyclicGgiPolyPatch::checkDefinition() const { // A little bit of sanity check The rotation angle/axis is // specified in both the master and slave patch of the // cyclicGgi. This is a pain, but the other alternatives // would be: // // - Specify in only of the two patches boundary // definition : - which one to chose? - which default // value to chose for the non-initialized value - Use a // specific dictionary for this... Nope, too cumbersome. // // So, we impose that the boundary definition of both // patches must specify the same information If not, well, // we stop the simulation and ask for a fix. if (!active()) { // No need to check anything, the shadow is not initialized properly. // This will happen with blockMesh when defining cyclicGGI patches. // Return quietly return; } if ( (mag(rotationAngle()) - mag(cyclicShadow().rotationAngle())) > SMALL || cmptSum(rotationAxis() - cyclicShadow().rotationAxis()) > SMALL ) { FatalErrorIn("void cyclicGgiPolyPatch::check() const") << " Rotation angle for patch name : " << name() << " is: " << rotationAngle() << " axis: " << rotationAxis() << nl << " Rotation angle for shadow patch name: " << shadowName() << " is: " << cyclicShadow().rotationAngle() << " axis: " << cyclicShadow().rotationAxis() << nl << " Both values need to be opposite in " << "the boundary file. " << abort(FatalError); } if ( (mag(separationOffset() + cyclicShadow().separationOffset())) > SMALL ) { FatalErrorIn("void cyclicGgiPolyPatch::check() const") << "Separation offset for patch name : " << name() << " is: " << separationOffset() << " Separation offset for shadow patch name: " << shadowName() << " is: " << cyclicShadow().separationOffset() << " axis: " << " Both values need to be opposite in " << "the boundary file. " << abort(FatalError); } if (debug > 1 && master()) { Info<< "Writing transformed slave patch as VTK." << nl << "Master: " << name() << " Slave: " << shadowName() << " Angle (master to slave): " << rotationAngle() << " deg" << " Axis: " << rotationAxis() << " Separation: " << separationOffset() << endl; const polyMesh& mesh = boundaryMesh().mesh(); fileName fvPath(mesh.time().path()/"VTK"); mkDir(fvPath); pointField transformedPoints = cyclicShadow().localPoints(); tensor rot = RodriguesRotation(rotationAxis_, -rotationAngle_); transform(transformedPoints, rot, transformedPoints); // Add separation offset to transformed points. HJ, 24/Nov/2009 transformedPoints += cyclicShadow().separationOffset(); standAlonePatch::writeVTK ( fvPath/fileName("cyclicGgi" + name() + cyclicShadow().name()), cyclicShadow().localFaces(), transformedPoints ); } }
static int set_filter(pam_handle_t *pamh, int flags, int ctrl , const char **evp, const char *filtername) { int status=-1; char terminal[TERMINAL_LEN]; struct termio stored_mode; /* initial terminal mode settings */ int fd[2], child=0, child2=0, aterminal; if (filtername == NULL || *filtername != '/') { _pam_log(LOG_ALERT, "filtername not permitted; require full path"); return PAM_ABORT; } if (!isatty(STDIN_FILENO) || !isatty(STDOUT_FILENO)) { aterminal = 0; } else { aterminal = 1; } if (aterminal) { /* open the master pseudo terminal */ fd[0] = master(terminal); if (fd[0] < 0) { _pam_log(LOG_CRIT,"no master terminal"); return PAM_AUTH_ERR; } /* set terminal into raw mode.. remember old mode so that we can revert to it after the child has quit. */ /* this is termio terminal handling... */ if (ioctl(STDIN_FILENO, TCGETA, (char *) &stored_mode ) < 0) { /* in trouble, so close down */ close(fd[0]); _pam_log(LOG_CRIT, "couldn't copy terminal mode"); return PAM_ABORT; } else { struct termio t_mode = stored_mode; t_mode.c_iflag = 0; /* no input control */ t_mode.c_oflag &= ~OPOST; /* no ouput post processing */ /* no signals, canonical input, echoing, upper/lower output */ t_mode.c_lflag &= ~(ISIG|ICANON|ECHO|XCASE); t_mode.c_cflag &= ~(CSIZE|PARENB); /* no parity */ t_mode.c_cflag |= CS8; /* 8 bit chars */ t_mode.c_cc[VMIN] = 1; /* number of chars to satisfy a read */ t_mode.c_cc[VTIME] = 0; /* 0/10th second for chars */ if (ioctl(STDIN_FILENO, TCSETA, (char *) &t_mode) < 0) { close(fd[0]); _pam_log(LOG_WARNING, "couldn't put terminal in RAW mode"); return PAM_ABORT; } /* * NOTE: Unlike the stream socket case here the child * opens the slave terminal as fd[1] *after* the fork... */ } } else { /* * not a terminal line so just open a stream socket fd[0-1] * both set... */ if ( socketpair(AF_UNIX, SOCK_STREAM, 0, fd) < 0 ) { _pam_log(LOG_CRIT,"couldn't open a stream pipe"); return PAM_ABORT; } } /* start child process */ if ( (child = fork()) < 0 ) { _pam_log(LOG_WARNING,"first fork failed"); if (aterminal) { (void) ioctl(STDIN_FILENO, TCSETA, (char *) &stored_mode); } return PAM_AUTH_ERR; } if ( child == 0 ) { /* child process *is* application */ if (aterminal) { /* close the controlling tty */ #if defined(__hpux) && defined(O_NOCTTY) int t = open("/dev/tty", O_RDWR|O_NOCTTY); #else int t = open("/dev/tty",O_RDWR); if (t > 0) { (void) ioctl(t, TIOCNOTTY, NULL); close(t); } #endif /* defined(__hpux) && defined(O_NOCTTY) */ /* make this process it's own process leader */ if (setsid() == -1) { _pam_log(LOG_WARNING,"child cannot become new session"); return PAM_ABORT; } /* find slave's name */ terminal[5] = 't'; /* want to open slave terminal */ fd[1] = open(terminal, O_RDWR); close(fd[0]); /* process is the child -- uses line fd[1] */ if (fd[1] < 0) { _pam_log(LOG_WARNING,"cannot open slave terminal; %s" ,terminal); return PAM_ABORT; } /* initialize the child's terminal to be the way the parent's was before we set it into RAW mode */ if (ioctl(fd[1], TCSETA, (char *) &stored_mode) < 0) { _pam_log(LOG_WARNING,"cannot set slave terminal mode; %s" ,terminal); close(fd[1]); return PAM_ABORT; } } else { /* nothing to do for a simple stream socket */ } /* re-assign the stdin/out to fd[1] <- (talks to filter). */ if ( dup2(fd[1],STDIN_FILENO) != STDIN_FILENO || dup2(fd[1],STDOUT_FILENO) != STDOUT_FILENO || dup2(fd[1],STDERR_FILENO) != STDERR_FILENO ) { _pam_log(LOG_WARNING ,"unable to re-assign STDIN/OUT/ERR...'s"); close(fd[1]); return PAM_ABORT; } /* make sure that file descriptors survive 'exec's */ if ( fcntl(STDIN_FILENO, F_SETFD, 0) || fcntl(STDOUT_FILENO,F_SETFD, 0) || fcntl(STDERR_FILENO,F_SETFD, 0) ) { _pam_log(LOG_WARNING ,"unable to re-assign STDIN/OUT/ERR...'s"); return PAM_ABORT; } /* now the user input is read from the parent/filter: forget fd */ close(fd[1]); /* the current process is now aparently working with filtered stdio/stdout/stderr --- success! */ return PAM_SUCCESS; } /* * process is the parent here. So we can close the application's * input/output */ close(fd[1]); /* Clear out passwords... there is a security problem here in * that this process never executes pam_end. Consequently, any * other sensitive data in this process is *not* explicitly * overwritten, before the process terminates */ (void) pam_set_item(pamh, PAM_AUTHTOK, NULL); (void) pam_set_item(pamh, PAM_OLDAUTHTOK, NULL); /* fork a copy of process to run the actual filter executable */ if ( (child2 = fork()) < 0 ) { _pam_log(LOG_WARNING,"filter fork failed"); child2 = 0; } else if ( child2 == 0 ) { /* exec the child filter */ if ( dup2(fd[0],APPIN_FILENO) != APPIN_FILENO || dup2(fd[0],APPOUT_FILENO) != APPOUT_FILENO || dup2(fd[0],APPERR_FILENO) != APPERR_FILENO ) { _pam_log(LOG_WARNING ,"unable to re-assign APPIN/OUT/ERR...'s"); close(fd[0]); exit(1); } /* make sure that file descriptors survive 'exec's */ if ( fcntl(APPIN_FILENO, F_SETFD, 0) == -1 || fcntl(APPOUT_FILENO,F_SETFD, 0) == -1 || fcntl(APPERR_FILENO,F_SETFD, 0) == -1 ) { _pam_log(LOG_WARNING ,"unable to retain APPIN/OUT/ERR...'s"); close(APPIN_FILENO); close(APPOUT_FILENO); close(APPERR_FILENO); exit(1); } /* now the user input is read from the parent through filter */ execle(filtername, "<pam_filter>", NULL, evp); /* getting to here is an error */ _pam_log(LOG_ALERT, "filter: %s, not executable", filtername); } else { /* wait for either of the two children to exit */ while (child && child2) { /* loop if there are two children */ int lstatus=0; int chid; chid = wait(&lstatus); if (chid == child) { if (WIFEXITED(lstatus)) { /* exited ? */ status = WEXITSTATUS(lstatus); } else if (WIFSIGNALED(lstatus)) { /* killed ? */ status = -1; } else continue; /* just stopped etc.. */ child = 0; /* the child has exited */ } else if (chid == child2) { /* * if the filter has exited. Let the child die * naturally below */ if (WIFEXITED(lstatus) || WIFSIGNALED(lstatus)) child2 = 0; } else { _pam_log(LOG_ALERT ,"programming error <chid=%d,lstatus=%x>: " __FILE__ " line %d" , lstatus, __LINE__ ); child = child2 = 0; status = -1; } } } close(fd[0]); /* if there is something running, wait for it to exit */ while (child || child2) { int lstatus=0; int chid; chid = wait(&lstatus); if (child && chid == child) { if (WIFEXITED(lstatus)) { /* exited ? */ status = WEXITSTATUS(lstatus); } else if (WIFSIGNALED(lstatus)) { /* killed ? */ status = -1; } else continue; /* just stopped etc.. */ child = 0; /* the child has exited */ } else if (child2 && chid == child2) { if (WIFEXITED(lstatus) || WIFSIGNALED(lstatus)) child2 = 0; } else { _pam_log(LOG_ALERT ,"programming error <chid=%d,lstatus=%x>: " __FILE__ " line %d" , lstatus, __LINE__ ); child = child2 = 0; status = -1; } } if (aterminal) { /* reset to initial terminal mode */ (void) ioctl(STDIN_FILENO, TCSETA, (char *) &stored_mode); } if (ctrl & FILTER_DEBUG) { _pam_log(LOG_DEBUG,"parent process exited"); /* clock off */ } /* quit the parent process, returning the child's exit status */ exit(status); }
void eval(void) {// int __VERIFIER_nondet_int()___0 ; int tmp ; { { while (1) { while_10_continue: /* CIL Label */ ; { tmp = exists_runnable_thread(); } if (tmp) { } else { goto while_10_break; } if (m_st == 0) { int tmp_ndt_1; tmp_ndt_1 = __VERIFIER_nondet_int(); if (tmp_ndt_1) { { m_st = 1; master(); } } else { } } else { } if (t1_st == 0) { int tmp_ndt_2; tmp_ndt_2 = __VERIFIER_nondet_int(); if (tmp_ndt_2) { { t1_st = 1; transmit1(); } } else { } } else { } if (t2_st == 0) { int tmp_ndt_3; tmp_ndt_3 = __VERIFIER_nondet_int(); if (tmp_ndt_3) { { t2_st = 1; transmit2(); } } else { } } else { } if (t3_st == 0) { int tmp_ndt_4; tmp_ndt_4 = __VERIFIER_nondet_int(); if (tmp_ndt_4) { { t3_st = 1; transmit3(); } } else { } } else { } if (t4_st == 0) { int tmp_ndt_5; tmp_ndt_5 = __VERIFIER_nondet_int(); if (tmp_ndt_5) { { t4_st = 1; transmit4(); } } else { } } else { } if (t5_st == 0) { int tmp_ndt_6; tmp_ndt_6 = __VERIFIER_nondet_int(); if (tmp_ndt_6) { { t5_st = 1; transmit5(); } } else { } } else { } if (t6_st == 0) { int tmp_ndt_7; tmp_ndt_7 = __VERIFIER_nondet_int(); if (tmp_ndt_7) { { t6_st = 1; transmit6(); } } else { } } else { } if (t7_st == 0) { int tmp_ndt_8; tmp_ndt_8 = __VERIFIER_nondet_int(); if (tmp_ndt_8) { { t7_st = 1; transmit7(); } } else { } } else { } if (t8_st == 0) { int tmp_ndt_9; tmp_ndt_9 = __VERIFIER_nondet_int(); if (tmp_ndt_9) { { t8_st = 1; transmit8(); } } else { } } else { } if (t9_st == 0) { int tmp_ndt_10; tmp_ndt_10 = __VERIFIER_nondet_int(); if (tmp_ndt_10) { { t9_st = 1; transmit9(); } } else { } } else { } } while_10_break: /* CIL Label */ ; } return; } }
bool Foam::repatchCoverage::changeTopology() const { // Check that masks are empty if (!uncMaster_.empty() || !uncSlave_.empty()) { FatalErrorIn("bool repatchCoverage::changeTopology() const") << "Uncovered masks are not empty. Topo change is out of sync" << abort(FatalError); } // Get mesh reference const polyMesh& mesh = topoChanger().mesh(); const pointField& allPoints = mesh.allPoints(); const faceList& allFaces = mesh.allFaces(); // Collect all faces for interpolation // Master side const polyPatch& masterCoveredPatch = mesh.boundaryMesh()[masterCoveredPatchID_.index()]; const polyPatch& masterUncoveredPatch = mesh.boundaryMesh()[masterUncoveredPatchID_.index()]; faceList masterSide ( masterCoveredPatch.size() + masterUncoveredPatch.size() ); { label nFaces = 0; // Insert covered faces for ( label faceI = masterCoveredPatch.start(); faceI < masterCoveredPatch.start() + masterCoveredPatch.size(); faceI++ ) { masterSide[nFaces] = allFaces[faceI]; nFaces++; } // Insert uncovered faces for ( label faceI = masterUncoveredPatch.start(); faceI < masterUncoveredPatch.start() + masterUncoveredPatch.size(); faceI++ ) { masterSide[nFaces] = allFaces[faceI]; nFaces++; } } // Slave side const polyPatch& slaveCoveredPatch = mesh.boundaryMesh()[slaveCoveredPatchID_.index()]; const polyPatch& slaveUncoveredPatch = mesh.boundaryMesh()[slaveUncoveredPatchID_.index()]; faceList slaveSide ( slaveCoveredPatch.size() + slaveUncoveredPatch.size() ); { label nFaces = 0; // Insert covered faces for ( label faceI = slaveCoveredPatch.start(); faceI < slaveCoveredPatch.start() + slaveCoveredPatch.size(); faceI++ ) { slaveSide[nFaces] = allFaces[faceI]; nFaces++; } // Insert uncovered faces for ( label faceI = slaveUncoveredPatch.start(); faceI < slaveUncoveredPatch.start() + slaveUncoveredPatch.size(); faceI++ ) { slaveSide[nFaces] = allFaces[faceI]; nFaces++; } } // Create interpolator primitiveFacePatch master(masterSide, allPoints); primitiveFacePatch slave(slaveSide, allPoints); if ( Pstream::parRun() && ( (masterSide.empty() && !slaveSide.empty()) || (!masterSide.empty() && slaveSide.empty()) ) ) { FatalErrorIn("bool repatchCoverage::changeTopology() const") << "Parallel run with partial visibility" << abort(FatalError); } if (masterSide.empty() && slaveSide.empty()) { // Empty master and slave patches. No local topo change return false; } GGIInterpolation<primitiveFacePatch, primitiveFacePatch> patchToPatch ( master, slave, tensorField::zero, // forwardT tensorField::zero, // reverseT vectorField::zero // separation ); // Check uncovered master and slave faces // Check uncovered master faces // All faces between 0 and masterCoveredPatch.size() - 1 should be covered // All faces between masterCoveredPatch.size() - 1 and // uncoveredMaster.size() - 1 should be uncovered // If this is not the case, faces should be changed // Master side label nMasterChanges = 0; { // Set size of uncovered master mask. This indicates a topo change // is in preparation uncMaster_.setSize(master.size(), false); const labelList& umf = patchToPatch.uncoveredMasterFaces(); forAll(umf, umfI) { uncMaster_[umf[umfI]] = true; } // Check coverage forAll (uncMaster_, mfI) { if (uncMaster_[mfI] && mfI < masterCoveredPatch.size()) { // Found uncovered master in covered section nMasterChanges++; } if (!uncMaster_[mfI] && mfI >= masterCoveredPatch.size()) { // Found covered master in uncovered section nMasterChanges++; } } } // Slave side label nSlaveChanges = 0; { // Set size of uncovered master mask. This indicates a topo change // is in preparation uncSlave_.setSize(slave.size(), false); const labelList& umf = patchToPatch.uncoveredSlaveFaces(); forAll(umf, umfI) { uncSlave_[umf[umfI]] = true; } // Check coverage forAll (uncSlave_, mfI) { if (uncSlave_[mfI] && mfI < slaveCoveredPatch.size()) { // Found uncovered slave in covered section nSlaveChanges++; } if (!uncSlave_[mfI] && mfI >= slaveCoveredPatch.size()) { // Found covered slave in uncovered section nSlaveChanges++; } } } if (nMasterChanges > 0 || nSlaveChanges > 0) { InfoIn("bool repatchCoverage::changeTopology() const") << "Changing " << nMasterChanges << " master and " << nSlaveChanges << " slave faces" << endl; return true; } else { // Clear uncovered masks to indicate that the topological change // is not required uncMaster_.clear(); uncSlave_.clear(); return false; } }
void do_tests() { #ifndef __NO_ENVIRONMENT__ ASSERT(catch(move_object("foo"))); ASSERT(catch(move_object(__FILE__))); ASSERT(catch(move_object(this_object()))); move_object(master()); ASSERT(environment(this_object()) == master()); destruct(this_object()); ASSERT(catch(move_object(master()))); #endif }
int dcpmain(int argc, char *argv[]) { char *logfile_name = NULL; KWBoolean contacted = KWFalse; int option; int pollMode = POLL_ACTIVE; /* Default = dial out to system */ time_t exitTime = LONG_MAX; char recvGrade = ALL_GRADES; KWBoolean overrideGrade = KWFalse; KWBoolean runUUXQT = KWFalse; char *hotUser = NULL; BPS hotBPS = 0; int hotHandle = -1; fwork = nil(FILE); /*--------------------------------------------------------------------*/ /* Process our options */ /*--------------------------------------------------------------------*/ while ((option = getopt(argc, argv, "d:g:h:m:l:r:s:tUw:x:z:n?")) != EOF) switch (option) { case 'd': exitTime = atoi( optarg ); exitTime = time(NULL) + hhmm2sec(exitTime); pollMode = POLL_PASSIVE; /* Implies passive polling */ break; case 'g': if (strlen(optarg) == 1 ) recvGrade = *optarg; else { recvGrade = checktime( optarg ); /* Get restriction for this hour */ if ( ! recvGrade ) /* If no class, use the default */ recvGrade = ALL_GRADES; } overrideGrade = KWTrue; break; case 'h': hotHandle = atoi( optarg ); /* Handle opened for us */ pollMode = POLL_PASSIVE; /* Implies passive polling */ break; case 'm': /* Override in modem name */ E_inmodem = optarg; pollMode = POLL_PASSIVE; /* Implies passive polling */ break; case 'l': /* Log file name */ logfile_name = optarg; break; case 'n': callnow = KWTrue; break; case 'r': pollMode = atoi(optarg); break; case 's': Rmtname = optarg; break; case 't': traceEnabled = KWTrue; break; case 'U': runUUXQT = KWTrue; break; case 'x': debuglevel = atoi(optarg); break; case 'z': hotBPS = (BPS) atoi(optarg); pollMode = POLL_PASSIVE; /* Implies passive polling */ break; case 'w': pollMode = POLL_PASSIVE; /* Implies passive polling */ hotUser = optarg; break; case '?': puts("\nUsage:\tuucico\t" "[-s [all | any | sys]] [-r 1|0] [-d hhmm]\n" "\t\t[-l logfile] [-n] [-t] [-U] [-x debug]\n" "\t\t[-h handle] [-m modem] [-z bps]"); return 4; } /*--------------------------------------------------------------------*/ /* Abort if any options were left over */ /*--------------------------------------------------------------------*/ if (optind != argc) { puts("Extra parameter(s) at end."); return 4; } /*--------------------------------------------------------------------*/ /* Initialize logging and the name of the systems file */ /*--------------------------------------------------------------------*/ openlog( logfile_name ); if (bflag[F_SYSLOG] && ! bflag[F_MULTITASK]) { syslog = FOPEN(SYSLOG, "a",TEXT_MODE); if ((syslog == nil(FILE)) || setvbuf( syslog, NULL, _IONBF, 0)) { printerr( SYSLOG ); panic(); } } PushDir(E_spooldir); atexit( PopDir ); if ( terminate_processing ) return 100; /*--------------------------------------------------------------------*/ /* Initialize security */ /*--------------------------------------------------------------------*/ if ( !LoadSecurity()) { printmsg(0,"Unable to initialize security, see previous message"); panic(); } if ( terminate_processing ) return 100; #if defined(_Windows) atexit(CloseEasyWin); /* Auto-close EasyWin window on exit */ #endif atexit( shutDown ); /* Insure port is closed by panic() */ remote_stats.hstatus = HS_NOCALL; /* Known state for automatic status update */ /*--------------------------------------------------------------------*/ /* Begin main processing loop */ /*--------------------------------------------------------------------*/ if (pollMode == POLL_ACTIVE) contacted = master(recvGrade, overrideGrade, runUUXQT ); else if (pollMode == POLL_PASSIVE) contacted = client(exitTime, hotUser, hotBPS, hotHandle, runUUXQT); else { printmsg(0,"Invalid -r flag, must be 0 or 1"); panic(); } /*--------------------------------------------------------------------*/ /* Report our results */ /*--------------------------------------------------------------------*/ if (!contacted && (pollMode == POLL_ACTIVE)) { if (dialed) printmsg(0, "Could not connect to remote system."); else printmsg(0, "No work for requested system or wrong time to call."); } dcupdate(); if (bflag[F_SYSLOG] && ! bflag[F_MULTITASK]) fclose(syslog); return terminate_processing ? 100 : (contacted ? 0 : 5); } /* dcpmain */
void embedded_fehlberg_7_8( fp timeinst, fp h, fp *initvalu, fp *finavalu, fp *error, fp *parameter, fp *com, cl_mem d_initvalu, cl_mem d_finavalu, cl_mem d_params, cl_mem d_com, cl_command_queue command_queue, cl_kernel kernel, long long *timecopyin, long long *timecopykernel, long long *timecopyout) { //====================================================================================================================================================== // VARIABLES //====================================================================================================================================================== static const fp c_1_11 = 41.0 / 840.0; static const fp c6 = 34.0 / 105.0; static const fp c_7_8= 9.0 / 35.0; static const fp c_9_10 = 9.0 / 280.0; static const fp a2 = 2.0 / 27.0; static const fp a3 = 1.0 / 9.0; static const fp a4 = 1.0 / 6.0; static const fp a5 = 5.0 / 12.0; static const fp a6 = 1.0 / 2.0; static const fp a7 = 5.0 / 6.0; static const fp a8 = 1.0 / 6.0; static const fp a9 = 2.0 / 3.0; static const fp a10 = 1.0 / 3.0; static const fp b31 = 1.0 / 36.0; static const fp b32 = 3.0 / 36.0; static const fp b41 = 1.0 / 24.0; static const fp b43 = 3.0 / 24.0; static const fp b51 = 20.0 / 48.0; static const fp b53 = -75.0 / 48.0; static const fp b54 = 75.0 / 48.0; static const fp b61 = 1.0 / 20.0; static const fp b64 = 5.0 / 20.0; static const fp b65 = 4.0 / 20.0; static const fp b71 = -25.0 / 108.0; static const fp b74 = 125.0 / 108.0; static const fp b75 = -260.0 / 108.0; static const fp b76 = 250.0 / 108.0; static const fp b81 = 31.0/300.0; static const fp b85 = 61.0/225.0; static const fp b86 = -2.0/9.0; static const fp b87 = 13.0/900.0; static const fp b91 = 2.0; static const fp b94 = -53.0/6.0; static const fp b95 = 704.0 / 45.0; static const fp b96 = -107.0 / 9.0; static const fp b97 = 67.0 / 90.0; static const fp b98 = 3.0; static const fp b10_1 = -91.0 / 108.0; static const fp b10_4 = 23.0 / 108.0; static const fp b10_5 = -976.0 / 135.0; static const fp b10_6 = 311.0 / 54.0; static const fp b10_7 = -19.0 / 60.0; static const fp b10_8 = 17.0 / 6.0; static const fp b10_9 = -1.0 / 12.0; static const fp b11_1 = 2383.0 / 4100.0; static const fp b11_4 = -341.0 / 164.0; static const fp b11_5 = 4496.0 / 1025.0; static const fp b11_6 = -301.0 / 82.0; static const fp b11_7 = 2133.0 / 4100.0; static const fp b11_8 = 45.0 / 82.0; static const fp b11_9 = 45.0 / 164.0; static const fp b11_10 = 18.0 / 41.0; static const fp b12_1 = 3.0 / 205.0; static const fp b12_6 = - 6.0 / 41.0; static const fp b12_7 = - 3.0 / 205.0; static const fp b12_8 = - 3.0 / 41.0; static const fp b12_9 = 3.0 / 41.0; static const fp b12_10 = 6.0 / 41.0; static const fp b13_1 = -1777.0 / 4100.0; static const fp b13_4 = -341.0 / 164.0; static const fp b13_5 = 4496.0 / 1025.0; static const fp b13_6 = -289.0 / 82.0; static const fp b13_7 = 2193.0 / 4100.0; static const fp b13_8 = 51.0 / 82.0; static const fp b13_9 = 33.0 / 164.0; static const fp b13_10 = 12.0 / 41.0; static const fp err_factor = -41.0 / 840.0; fp h2_7 = a2 * h; fp timeinst_temp; fp* initvalu_temp; fp** finavalu_temp; int i; //====================================================================================================================================================== // TEMPORARY STORAGE ALLOCATION //====================================================================================================================================================== initvalu_temp= (fp *) malloc(EQUATIONS* sizeof(fp)); finavalu_temp= (fp **) malloc(13* sizeof(fp *)); for (i= 0; i<13; i++){ finavalu_temp[i]= (fp *) malloc(EQUATIONS* sizeof(fp)); } //====================================================================================================================================================== // EVALUATIONS [UNROLLED LOOP] [SEQUENTIAL DEPENDENCY] //====================================================================================================================================================== //=================================================================================================== // 1 //=================================================================================================== timeinst_temp = timeinst; for(i=0; i<EQUATIONS; i++){ initvalu_temp[i] = initvalu[i] ; // printf("initvalu[%d] = %f\n", i, initvalu[i]); } master( timeinst_temp, initvalu_temp, parameter, finavalu_temp[0], com, d_initvalu, d_finavalu, d_params, d_com, command_queue, kernel, timecopyin, timecopykernel, timecopyout); //=================================================================================================== // 2 //=================================================================================================== timeinst_temp = timeinst+h2_7; for(i=0; i<EQUATIONS; i++){ initvalu_temp[i] = initvalu[i] + h2_7 * (finavalu_temp[0][i]); } master( timeinst_temp, initvalu_temp, parameter, finavalu_temp[1], com, d_initvalu, d_finavalu, d_params, d_com,\ command_queue, kernel, timecopyin, timecopykernel, timecopyout); //=================================================================================================== // 3 //=================================================================================================== timeinst_temp = timeinst+a3*h; for(i=0; i<EQUATIONS; i++){ initvalu_temp[i] = initvalu[i] + h * ( b31*finavalu_temp[0][i] + b32*finavalu_temp[1][i]); } master( timeinst_temp, initvalu_temp, parameter, finavalu_temp[2], com, d_initvalu, d_finavalu, d_params, d_com, command_queue, kernel, timecopyin, timecopykernel, timecopyout); //=================================================================================================== // 4 //=================================================================================================== timeinst_temp = timeinst+a4*h; for(i=0; i<EQUATIONS; i++){ initvalu_temp[i] = initvalu[i] + h * ( b41*finavalu_temp[0][i] + b43*finavalu_temp[2][i]) ; } master( timeinst_temp, initvalu_temp, parameter, finavalu_temp[3], com, d_initvalu, d_finavalu, d_params, d_com, command_queue, kernel, timecopyin, timecopykernel, timecopyout); //=================================================================================================== // 5 //=================================================================================================== timeinst_temp = timeinst+a5*h; for(i=0; i<EQUATIONS; i++){ initvalu_temp[i] = initvalu[i] + h * ( b51*finavalu_temp[0][i] + b53*finavalu_temp[2][i] + b54*finavalu_temp[3][i]) ; } master( timeinst_temp, initvalu_temp, parameter, finavalu_temp[4], com, d_initvalu, d_finavalu, d_params, d_com, command_queue, kernel, timecopyin, timecopykernel, timecopyout); //=================================================================================================== // 6 //=================================================================================================== timeinst_temp = timeinst+a6*h; for(i=0; i<EQUATIONS; i++){ initvalu_temp[i] = initvalu[i] + h * ( b61*finavalu_temp[0][i] + b64*finavalu_temp[3][i] + b65*finavalu_temp[4][i]) ; } master( timeinst_temp, initvalu_temp, parameter, finavalu_temp[5], com, d_initvalu, d_finavalu, d_params, d_com, command_queue, kernel, timecopyin, timecopykernel, timecopyout); //=================================================================================================== // 7 //=================================================================================================== timeinst_temp = timeinst+a7*h; for(i=0; i<EQUATIONS; i++){ initvalu_temp[i] = initvalu[i] + h * ( b71*finavalu_temp[0][i] + b74*finavalu_temp[3][i] + b75*finavalu_temp[4][i] + b76*finavalu_temp[5][i]); } master( timeinst_temp, initvalu_temp, parameter, finavalu_temp[6], com, d_initvalu, d_finavalu, d_params, d_com, command_queue, kernel, timecopyin, timecopykernel, timecopyout); //=================================================================================================== // 8 //=================================================================================================== timeinst_temp = timeinst+a8*h; for(i=0; i<EQUATIONS; i++){ initvalu_temp[i] = initvalu[i] + h * ( b81*finavalu_temp[0][i] + b85*finavalu_temp[4][i] + b86*finavalu_temp[5][i] + b87*finavalu_temp[6][i]); } master( timeinst_temp, initvalu_temp, parameter, finavalu_temp[7], com, d_initvalu, d_finavalu, d_params, d_com, command_queue, kernel, timecopyin, timecopykernel, timecopyout); //=================================================================================================== // 9 //=================================================================================================== timeinst_temp = timeinst+a9*h; for(i=0; i<EQUATIONS; i++){ initvalu_temp[i] = initvalu[i] + h * ( b91*finavalu_temp[0][i] + b94*finavalu_temp[3][i] + b95*finavalu_temp[4][i] + b96*finavalu_temp[5][i] + b97*finavalu_temp[6][i]+ b98*finavalu_temp[7][i]) ; } master( timeinst_temp, initvalu_temp, parameter, finavalu_temp[8], com, d_initvalu, d_finavalu, d_params, d_com, command_queue, kernel, timecopyin, timecopykernel, timecopyout); //=================================================================================================== // 10 //=================================================================================================== timeinst_temp = timeinst+a10*h; for(i=0; i<EQUATIONS; i++){ initvalu_temp[i] = initvalu[i] + h * ( b10_1*finavalu_temp[0][i] + b10_4*finavalu_temp[3][i] + b10_5*finavalu_temp[4][i] + b10_6*finavalu_temp[5][i] + b10_7*finavalu_temp[6][i] + b10_8*finavalu_temp[7][i] + b10_9*finavalu_temp[8] [i]) ; } master( timeinst_temp, initvalu_temp, parameter, finavalu_temp[9], com, d_initvalu, d_finavalu, d_params, d_com, command_queue, kernel, timecopyin, timecopykernel, timecopyout); //=================================================================================================== // 11 //=================================================================================================== timeinst_temp = timeinst+h; for(i=0; i<EQUATIONS; i++){ initvalu_temp[i] = initvalu[i] + h * ( b11_1*finavalu_temp[0][i] + b11_4*finavalu_temp[3][i] + b11_5*finavalu_temp[4][i] + b11_6*finavalu_temp[5][i] + b11_7*finavalu_temp[6][i] + b11_8*finavalu_temp[7][i] + b11_9*finavalu_temp[8][i]+ b11_10 * finavalu_temp[9][i]); } master( timeinst_temp, initvalu_temp, parameter, finavalu_temp[10], com, d_initvalu, d_finavalu, d_params, d_com, command_queue, kernel, timecopyin, timecopykernel, timecopyout); //=================================================================================================== // 12 //=================================================================================================== timeinst_temp = timeinst; for(i=0; i<EQUATIONS; i++){ initvalu_temp[i] = initvalu[i] + h * ( b12_1*finavalu_temp[0][i] + b12_6*finavalu_temp[5][i] + b12_7*finavalu_temp[6][i] + b12_8*finavalu_temp[7][i] + b12_9*finavalu_temp[8][i] + b12_10 * finavalu_temp[9][i]) ; } master( timeinst_temp, initvalu_temp, parameter, finavalu_temp[11], com, d_initvalu, d_finavalu, d_params, d_com, command_queue, kernel, timecopyin, timecopykernel, timecopyout); //=================================================================================================== // 13 //=================================================================================================== timeinst_temp = timeinst+h; for(i=0; i<EQUATIONS; i++){ initvalu_temp[i] = initvalu[i] + h * ( b13_1*finavalu_temp[0][i] + b13_4*finavalu_temp[3][i] + b13_5*finavalu_temp[4][i] + b13_6*finavalu_temp[5][i] + b13_7*finavalu_temp[6][i] + b13_8*finavalu_temp[7][i] + b13_9*finavalu_temp[8][i] + b13_10*finavalu_temp[9][i] + finavalu_temp[11][i]) ; } master( timeinst_temp, initvalu_temp, parameter, finavalu_temp[12], com, d_initvalu, d_finavalu, d_params, d_com, command_queue, kernel, timecopyin, timecopykernel, timecopyout); //====================================================================================================================================================== // FINAL VALUE //====================================================================================================================================================== for(i=0; i<EQUATIONS; i++){ finavalu[i]= initvalu[i] + h * (c_1_11 * (finavalu_temp[0][i] + finavalu_temp[10][i]) + c6 * finavalu_temp[5][i] + c_7_8 * (finavalu_temp[6][i] + finavalu_temp[7][i]) + c_9_10 * (finavalu_temp[8][i] + finavalu_temp[9][i]) ); } //====================================================================================================================================================== // RETURN //====================================================================================================================================================== for(i=0; i<EQUATIONS; i++){ error[i] = fabs(err_factor * (finavalu_temp[0][i] + finavalu_temp[10][i] - finavalu_temp[11][i] - finavalu_temp[12][i])); } //====================================================================================================================================================== // DEALLOCATION //====================================================================================================================================================== free(initvalu_temp); free(finavalu_temp); }
QList<AppSetupLink *> AppSetupLink::list() { return master()->findChildren<AppSetupLink *>(); }
int main(int argc, char *argv[]) { int k; /* FILE *fd; */ /*fprintf(stderr,"%s starting.\n", argv[0]);*/ /* Send error output to Console (instead of VnmrJ) */ /*freopen("/dev/console", "w", stderr);*/ setupsys(); userdir[ 0 ] = '\0'; /* fd = fopen("/tmp/argb", "w"); for (k = 0; k < argc; k++) { fprintf(fd, " arg %d: %s\n", k, argv[k]); } fclose(fd); */ isMaster = 0; #ifdef DBXTOOL if ((strcmp(argv[0],"Vnmrch")!=0) && (argc>1)) { if (strcmp(argv[1],"master") == 0) { argv[1] = "Vnmrbg"; isMaster = 1; master(argc,argv); } else fprintf(stderr,"Main VNMR Program failure: argc=%d arg0='%s'\n", argc,argv[0]); } else if (strcmp(argv[0],"Vnmrch") == 0) { isMaster = 0; vnmr(argc,argv); } else fprintf(stderr,"Main VNMR Program failure: argc=%d arg0='%s'\n", argc,argv[0]); #else #ifdef VMS isMaster = 0; vf_init(); vnmr(argc,argv); #else if ((strcmp(argv[0],"Vnmrch")!=0) && (argc>1)) { for (k = 0; k < argc; k++) { if (strcmp("-mserver", argv[k]) == 0) isMaster = 1; else if (strcmp("master", argv[k]) == 0) isMaster = 1; if (isMaster) break; } if (strcmp(argv[1],"master") == 0) { argv[1] = "Vnmrbg"; isMaster = 1; /* master(argc,argv); */ } if (isMaster) { master(argc,argv); } else if (argc>1) { isMaster = 0; vnmr(argc,argv); } else { fprintf(stderr,"Main VNMR Program failure: argc=%d arg0='%s'\n", argc,argv[0]); } } else if (strcmp(argv[0],"Vnmrch") == 0) { isMaster = 0; vnmr(argc,argv); } else fprintf(stderr,"Main VNMR Program failure: argc=%d arg0='%s'\n", argc,argv[0]); #endif #endif exit(EXIT_SUCCESS); }
int member_group(string user, string group) { return (int)master()->query_member_group(user, group); }
void trecruit::pre_show(CVideo& /*video*/, twindow& window) { // int side_num = city_.side(); std::stringstream str; tlistbox* list = find_widget<tlistbox>(&window, "type_list", false, true); int gold = current_team_.gold(); tlabel* label = find_widget<tlabel>(&window, "title", false, true); str << _("Recruit") << "(" << gold << sngettext("unit^Gold", "Gold", gold) << ")"; label->set_label(str.str()); switch_type_internal(window); list->set_callback_value_change(dialog_callback<trecruit, &trecruit::type_selected>); hero_table_ = find_widget<tlistbox>(&window, "hero_table", false, true); fresh_heros_ = city_.fresh_heros(); std::sort(fresh_heros_.begin(), fresh_heros_.end(), compare_recruit); // fill data to hero_table catalog_page(window, ABILITY_PAGE, false); connect_signal_mouse_left_click( find_widget<tbutton>(&window, "ability", false) , boost::bind( &trecruit::catalog_page , this , boost::ref(window) , (int)ABILITY_PAGE , true)); connect_signal_mouse_left_click( find_widget<tbutton>(&window, "adaptability", false) , boost::bind( &trecruit::catalog_page , this , boost::ref(window) , (int)ADAPTABILITY_PAGE , true)); connect_signal_mouse_left_click( find_widget<tbutton>(&window, "personal", false) , boost::bind( &trecruit::catalog_page , this , boost::ref(window) , (int)PERSONAL_PAGE , true)); connect_signal_mouse_left_click( find_widget<tbutton>(&window, "relation", false) , boost::bind( &trecruit::catalog_page , this , boost::ref(window) , (int)RELATION_PAGE , true)); // prev/next connect_signal_mouse_left_click( find_widget<tbutton>(&window, "prev", false) , boost::bind( &trecruit::switch_type , this , boost::ref(window) , false)); connect_signal_mouse_left_click( find_widget<tbutton>(&window, "next", false) , boost::bind( &trecruit::switch_type , this , boost::ref(window) , true)); tbutton* ok = find_widget<tbutton>(&window, "ok", false, true); const unit_type* t = unit_types_[type_index_]; if (!checked_heros_.empty() && gold >= t->cost() * cost_exponent_ / 100) { if (!t->leader() || master()->official_ == hero_official_leader) { ok->set_active(true); } else { ok->set_active(false); } } else { ok->set_active(false); } tbutton* cancel = find_widget<tbutton>(&window, "cancel", false, true); cancel->set_visible(rpg_mode_? twidget::INVISIBLE: twidget::VISIBLE); if (rpg_mode_) { refresh_tooltip(window); } }
Pokemon::gen MoveProxy::gen() const { return master()->gen(); }
void eval(void) {// int __VERIFIER_nondet_int() ; int tmp ; { { while (1) { while_3_continue: /* CIL Label */ ; { tmp = exists_runnable_thread(); } if (tmp) { } else { goto while_3_break; } if (m_st == 0) { int tmp_ndt_1; tmp_ndt_1 = __VERIFIER_nondet_int(); if (tmp_ndt_1) { { m_st = 1; master(); } } else { } } else { } if (t1_st == 0) { int tmp_ndt_2; tmp_ndt_2 = __VERIFIER_nondet_int(); if (tmp_ndt_2) { { t1_st = 1; transmit1(); } } else { } } else { } if (t2_st == 0) { int tmp_ndt_3; tmp_ndt_3 = __VERIFIER_nondet_int(); if (tmp_ndt_3) { { t2_st = 1; transmit2(); } } else { } } else { } } while_3_break: /* CIL Label */ ; } return; } }
Module::ReturnType SubgraphPlanarizerUML::doCall( PlanRepUML &pr, int cc, const EdgeArray<int> *pCostOrig, int &crossingNumber) { OGDF_ASSERT(m_permutations >= 1); PlanarSubgraphModule &subgraph = m_subgraph.get(); UMLEdgeInsertionModule &inserter = m_inserter.get(); unsigned int nThreads = min(m_maxThreads, (unsigned int)m_permutations); int64_t startTime; System::usedRealTime(startTime); int64_t stopTime = (m_timeLimit >= 0) ? (startTime + int64_t(1000.0*m_timeLimit)) : -1; // // Compute subgraph // if(m_setTimeout) subgraph.timeLimit(m_timeLimit); pr.initCC(cc); // gather generalization edges, which should all be in the planar subgraph List<edge> preferedEdges; for(edge e : pr.edges) { if (pr.typeOf(e) == Graph::generalization) preferedEdges.pushBack(e); } List<edge> delEdges; ReturnType retValue; if(pCostOrig) { EdgeArray<int> costPG(pr); for(edge e : pr.edges) costPG[e] = (*pCostOrig)[pr.original(e)]; retValue = subgraph.call(pr, costPG, preferedEdges, delEdges); } else retValue = subgraph.call(pr, preferedEdges, delEdges); if(isSolution(retValue) == false) return retValue; const int m = delEdges.size(); for(ListIterator<edge> it = delEdges.begin(); it.valid(); ++it) *it = pr.original(*it); // // Permutation phase // int seed = rand(); minstd_rand rng(seed); if(nThreads > 1) { // // Parallel implementation // ThreadMaster master( pr, cc, pCostOrig, delEdges, seed, m_permutations - nThreads, stopTime); Array<Worker *> worker(nThreads-1); Array<Thread> thread(nThreads-1); for(unsigned int i = 0; i < nThreads-1; ++i) { worker[i] = new Worker(i, &master, inserter.clone()); thread[i] = Thread(*worker[i]); } doWorkHelper(master, inserter, rng); for(unsigned int i = 0; i < nThreads-1; ++i) { thread[i].join(); delete worker[i]; } master.restore(pr, crossingNumber); } else { // // Sequential implementation // PlanRepLight prl(pr); Array<edge> deletedEdges(m); int j = 0; for(ListIterator<edge> it = delEdges.begin(); it.valid(); ++it) deletedEdges[j++] = *it; bool foundSolution = false; CrossingStructure cs; for(int i = 1; i <= m_permutations; ++i) { int cr; bool ok = doSinglePermutation(prl, cc, pCostOrig, deletedEdges, inserter, rng, cr); if(ok && (foundSolution == false || cr < cs.weightedCrossingNumber())) { foundSolution = true; cs.init(prl, cr); } if(stopTime >= 0 && System::realTime() >= stopTime) { if(foundSolution == false) return retTimeoutInfeasible; // not able to find a solution... break; } } cs.restore(pr,cc); // restore best solution in PG crossingNumber = cs.weightedCrossingNumber(); OGDF_ASSERT(isPlanar(pr) == true); } return retFeasible; }
unsigned long quadratic_sieve(mpz_t N, unsigned int n, unsigned interval, unsigned int max_fact, unsigned int block_size, mpz_t m, unsigned int print_fact) { double t1, t2; int rank; int comm_size; MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_size(MPI_COMM_WORLD, & comm_size); /* Controllo con test di pseudoprimalità di rabin */ if(mpz_probab_prime_p(N, 25)) { return NUM_PRIMO; } /* Radice intera di N */ mpz_t s; mpz_init(s); mpz_sqrt(s, N); t1 = MPI_Wtime(); /* Individuazione primi in [2, n] */ unsigned int * primes = malloc(sizeof(unsigned int) * n); eratosthenes_sieve(primes, n); /* Compattiamo i numeri primi in primes */ unsigned j = 0; for(int i = 2; i < n; ++i) if(primes[i] == 1) { primes[j++] = i; } unsigned int n_all_primes = j; /* Fattorizzazione eseguita da tutti, gli slave ritornano IM_A_SLAVE mentre il main il fattore */ unsigned int simple_factor = trivial_fact(N, primes, n_all_primes); if(simple_factor != 0) { mpz_set_ui(m, simple_factor); return rank == 0 ? OK : IM_A_SLAVE; } /* Calcolo base di fattori e soluzioni dell'eq x^2 = N mod p */ pair * solutions = malloc(sizeof(pair) * n_all_primes); unsigned int * factor_base = primes; unsigned n_primes = base_fattori(N, s, factor_base, solutions, primes, n_all_primes); t2 = MPI_Wtime(); double t_base = t2 - t1; if(rank == 0) printf("#Dimensione base di fattori: %d\n", n_primes); /* Vettore degli esponenti in Z */ unsigned int ** exponents; /* Vettore degli (Ai + s) */ mpz_t * As; /* Parte di crivello: troviamo le k+n fattorizzazioni complete */ unsigned int n_fatt; t1 = MPI_Wtime(); if(rank == 0){ /* Inizializzazioni vettori */ init_matrix(& exponents, n_primes + max_fact, n_primes); init_vector_mpz(& As, n_primes + max_fact); /* Procedura master che riceve le fatt. complete */ n_fatt = master(n_primes, max_fact, exponents, As, comm_size, print_fact); } else { mpz_t begin; mpz_init(begin); mpz_t counter; mpz_init(counter); mpz_set_ui(begin, interval * (rank - 1)); //gmp_printf("%d) begin=%Zd interval=%d\n", rank, begin, interval); int stop_flag = 0; do { //gmp_printf("\t%d) [%Zd, %Zd+%d] - (flag=%d)\n", rank, begin, begin, interval, flag); stop_flag = smart_sieve(N, factor_base, n_primes, solutions, begin, interval, block_size, max_fact); mpz_add_ui(begin, begin, interval * (comm_size-1)); } while(!stop_flag); //printf("#%d) Termina\n", rank); return IM_A_SLAVE; } t2 = MPI_Wtime(); double t_sieve = t2 - t1; printf("#Numero fattorizzazioni complete trovate: %d\n", n_fatt); t1 = MPI_Wtime(); /* Matrice di esponenti in Z_2 organizzata a blocchi di bit */ word ** M; /* Numero di blocchi di bit da utilizzare */ unsigned long n_blocchi = n_primes / N_BITS + 1; /* Inizializzazione egli esponenti mod 2 */ init_matrix_l(& M, n_fatt, n_blocchi); for(int i = 0; i < n_fatt; ++i) for(int j = 0; j < n_primes; ++j) { unsigned int a = get_matrix(exponents, i, j); set_k_i(M, i, j, a); } /* Vettore con le info (bit piu' a dx e num bit a 1) su M */ struct row_stats * wt = malloc(sizeof(struct row_stats) * n_fatt); for(int i = 0; i < n_fatt; ++i) get_wt_k(M, i, n_primes, & wt[i]); /* In gauss gli esponenti sommati possono andare in overflow, li converto dunque in mpz */ mpz_t ** exponents_mpz; mpz_t temp; mpz_init_set_ui(temp, 2); unsigned int a; init_matrix_mpz(& exponents_mpz, n_fatt, n_primes); for(unsigned i = 0; i < n_fatt; ++i) for(unsigned j = 0; j < n_primes; ++j) { a = get_matrix(exponents, i, j); mpz_set_ui(temp, a); set_matrix_mpz(exponents_mpz, i, j, temp); } /* Eliminazione gaussiana */ gaussian_elimination(exponents_mpz, M, As, N, n_fatt, n_primes, n_blocchi, wt); t2 = MPI_Wtime(); double t_gauss = t2 - t1; /* In m ritorno un fattore non banale di N */ unsigned int n_fact_non_banali = factorization(N, factor_base, M, exponents_mpz, As, wt, n_fatt, n_primes, m); printf("#time_base time_sieve time_gauss time_totale\n"); printf("%.6f ", t_base); printf("%.6f ", t_sieve); printf("%.6f ", t_gauss); printf("%.6f\n", t_base + t_gauss + t_sieve); if(n_fact_non_banali > 0) { return OK; } else { return SOLO_FATTORIZZAZIONI_BANALI; } }
AppSetupLink *AppSetupLink::factory(const QString &path) { if(path.isEmpty()) return 0; AppSetupLink *link = master()->findChild<AppSetupLink *>(path); return link ? link : new AppSetupLink(path); }
int main (int argc, char **argv) { if (argc < 3) { fprintf (stderr, "Not enough arguments. \nUsage: summation_mpi <Number of elements in array> <Send Method> [verbose output, 0 = false, 1 = true]\n"); fprintf (stderr, "where Send Method is d for MPI_SEND, s for MPI_SSEND, b for MPI_BSEND, r for MPI_RSEND\n"); exit (EXIT_FAILURE); } // initialize MPI MPI_Init (&argc, &argv); int size = 1; assert (argc > 1); size = atoi (argv[1]); // determine the send function // TODO thread safe..? My local openmpi implementation creates one process for each PE. assert (argc > 2); sendfunction send = NULL; switch (*argv[2]) { case 'd': send = MPI_Send; break; case 's': send = MPI_Ssend; break; case 'b': send = MPI_Bsend; break; case 'r': send = MPI_Rsend; break; default: fprintf (stderr, "Option for sendmethod not recognized.Allowed values are d,s,b,r\n"); exit (EXIT_FAILURE); } if (argc > 3) { verbose = atoi (argv[3]); } // we have to remember the number of PEs int numpes; MPI_Comm_size (MPI_COMM_WORLD, &numpes); // which rank does this process have? int myid; MPI_Comm_rank (MPI_COMM_WORLD, &myid); if (!myid) { /* master */ // TODO fix bug - if size < numpes, it crashes master (size, numpes, send); } else { /* slave */ slave (myid, send); } MPI_Finalize (); return EXIT_SUCCESS; }
AppSetupLink::AppSetupLink(const QString &path) : QObject(master()) { setObjectName(path); }
bool Foam::splitCell::isUnrefined() const { return !master() && !slave(); }
int main(int argc, char **argv) { return master(argc,argv); }
string player_save_file(string who){ if( !stringp(who) ) error("Bad argument 1 to save_file()."); who = convert_name(who); return master()->player_save_file(who); }
bool ShaderInstance::mergeable (const ShaderInstance &b, const ShaderGroup &g) const { // Must both be instances of the same master -- very fast early-out // for most potential pair comparisons. if (master() != b.master()) return false; // If the shaders haven't been optimized yet, they don't yet have // their own symbol tables and instructions (they just refer to // their unoptimized master), but they may have an "instance // override" vector that describes which parameters have // instance-specific values or connections. bool optimized = (m_instsymbols.size() != 0 || m_instops.size() != 0); // Same instance overrides if (m_instoverrides.size() || b.m_instoverrides.size()) { ASSERT (! optimized); // should not be post-opt ASSERT (m_instoverrides.size() == b.m_instoverrides.size()); for (size_t i = 0, e = m_instoverrides.size(); i < e; ++i) { if ((m_instoverrides[i].valuesource() == Symbol::DefaultVal || m_instoverrides[i].valuesource() == Symbol::InstanceVal) && (b.m_instoverrides[i].valuesource() == Symbol::DefaultVal || b.m_instoverrides[i].valuesource() == Symbol::InstanceVal)) { // If both params are defaults or instances, let the // instance parameter value checking below handle // things. No need to reject default-vs-instance // mismatches if the actual values turn out to be the // same later. continue; } if (! (equivalent(m_instoverrides[i], b.m_instoverrides[i]))) { const Symbol *sym = mastersymbol(i); // remember, it's pre-opt const Symbol *bsym = b.mastersymbol(i); if (! sym->everused_in_group() && ! bsym->everused_in_group()) continue; return false; } // But still, if they differ in their lockgeom'edness, we can't // merge the instances. if (m_instoverrides[i].lockgeom() != b.m_instoverrides[i].lockgeom()) { return false; } } } // Make sure that the two nodes have the same parameter values. If // the group has already been optimized, it's got an // instance-specific symbol table to check; but if it hasn't been // optimized, we check the symbol table in the master. for (int i = firstparam(); i < lastparam(); ++i) { const Symbol *sym = optimized ? symbol(i) : mastersymbol(i); if (! sym->everused_in_group()) continue; if (sym->typespec().is_closure()) continue; // Closures can't have instance override values if ((sym->valuesource() == Symbol::InstanceVal || sym->valuesource() == Symbol::DefaultVal) && memcmp (param_storage(i), b.param_storage(i), sym->typespec().simpletype().size())) { return false; } } if (m_run_lazily != b.m_run_lazily) { return false; } // The connection list need to be the same for the two shaders. if (m_connections.size() != b.m_connections.size()) { return false; } if (m_connections != b.m_connections) { return false; } // Make sure system didn't ask for instances that query userdata to be // immune from instance merging. if (! shadingsys().m_opt_merge_instances_with_userdata && (userdata_params() || b.userdata_params())) { return false; } // If there are no "local" ops or symbols, this instance hasn't been // optimized yet. In that case, we've already done enough checking, // since the masters being the same and having the same instance // params and connections is all it takes. The rest (below) only // comes into play after instances are more fully elaborated from // their masters in order to be optimized. if (!optimized) { return true; } // Same symbol table if (! equivalent (m_instsymbols, b.m_instsymbols)) { return false; } // Same opcodes to run if (! equivalent (m_instops, b.m_instops)) { return false; } // Same arguments to the ops if (m_instargs != b.m_instargs) { return false; } // Parameter and code ranges if (m_firstparam != b.m_firstparam || m_lastparam != b.m_lastparam || m_maincodebegin != b.m_maincodebegin || m_maincodeend != b.m_maincodeend || m_Psym != b.m_Psym || m_Nsym != b.m_Nsym) { return false; } // Nothing left to check, they must be identical! return true; }
int main(int argc, char *argv[]) { MasterServer master(25112, 25113); master.run(); return 0; }
void eval(void) { int tmp ; { { while (1) { while_7_continue: /* CIL Label */ ; { tmp = exists_runnable_thread(); } if (tmp) { } else { goto while_7_break; } if (m_st == 0) { int tmp_ndt_1; tmp_ndt_1 = __VERIFIER_nondet_int(); if (tmp_ndt_1) { { m_st = 1; master(); } } else { } } else { } if (t1_st == 0) { int tmp_ndt_2; tmp_ndt_2 = __VERIFIER_nondet_int(); if (tmp_ndt_2) { { t1_st = 1; transmit1(); } } else { } } else { } if (t2_st == 0) { int tmp_ndt_3; tmp_ndt_3 = __VERIFIER_nondet_int(); if (tmp_ndt_3) { { t2_st = 1; transmit2(); } } else { } } else { } if (t3_st == 0) { int tmp_ndt_4; tmp_ndt_4 = __VERIFIER_nondet_int(); if (tmp_ndt_4) { { t3_st = 1; transmit3(); } } else { } } else { } if (t4_st == 0) { int tmp_ndt_5; tmp_ndt_5 = __VERIFIER_nondet_int(); if (tmp_ndt_5) { { t4_st = 1; transmit4(); } } else { } } else { } if (t5_st == 0) { int tmp_ndt_6; tmp_ndt_6 = __VERIFIER_nondet_int(); if (tmp_ndt_6) { { t5_st = 1; transmit5(); } } else { } } else { } } while_7_break: /* CIL Label */ ; } return; } }
int main(int argc, char* argv[]) { // Configure EasyLogger++ el::Configurations defaultConf; defaultConf.setGlobally( el::ConfigurationType::Format, "%datetime %msg"); defaultConf.setGlobally( el::ConfigurationType::ToFile, "true"); defaultConf.setGlobally( el::ConfigurationType::Filename, "./fh.log"); el::Loggers::reconfigureLogger("default", defaultConf); // Init MPI MpiBase mpi_o(&argc, &argv); mpiS = &mpi_o; int mpi_rank; MPI_Comm_rank (MPI_COMM_WORLD, &mpi_rank); int mpi_size; MPI_Comm_size (MPI_COMM_WORLD, &mpi_size); // Search parameters Cnf cnf; int scans_limit; int sample_size; int num_iterations; int sat_threshold; char filename[4096]; // Maximum Linux path length. No need to conserve bytes nowadays... int core_len; int out_len; int guessing_layer ; std::vector <int> guessing_vars; // Read command line parameters via TCLAP try { TCLAP::CmdLine cmd("This program is used to search for 'inverse backdoor sets'.", ' ', "0.1"); TCLAP::UnlabeledValueArg<std::string> filename_arg("filename","Path to SAT problem file in DIMACS CNF format.", true, "","CNF_FILENAME"); cmd.add( filename_arg); TCLAP::ValueArg<int> scans_limit_arg ("w", "scans", "Watched literal scans limit for individual solver process.", false, 200000,"SCANS_LIMIT"); cmd.add( scans_limit_arg); TCLAP::ValueArg<int> sample_size_arg ("s", "samplesize","Total sample size.", false, 10,"SAMPLE_SIZE"); cmd.add(sample_size_arg); TCLAP::ValueArg<int> num_iterations_arg ("i", "iter","Search iterations limit.", false, 1000,"ITERATIONS_LIMIT"); cmd.add(num_iterations_arg); TCLAP::ValueArg<int> sat_threshold_arg ("t", "thresh","Ignore point results if less than this number of units were solved.", false, 1,"SAT_THRESH"); cmd.add(sat_threshold_arg); TCLAP::ValueArg<int> corelen_arg ("c", "corelen","Num of core vars.", true, 0,"CORE_LEN"); cmd.add(corelen_arg); TCLAP::ValueArg<int> outlen_arg ("o", "outlen","Num of out vars.", true, 0,"OUT_LEN"); cmd.add(outlen_arg); TCLAP::ValueArg<int> guessing_layer_arg ("l", "layer","Index of var layer to search on.", false, 0,"LAYER"); cmd.add(guessing_layer_arg); cmd.parse( argc, argv ); strcpy(filename, filename_arg.getValue().c_str()); // hackish! scans_limit = scans_limit_arg.getValue(); sample_size = sample_size_arg.getValue(); num_iterations = num_iterations_arg.getValue() ; sat_threshold = sat_threshold_arg.getValue() ; core_len = corelen_arg.getValue(); out_len = outlen_arg.getValue(); guessing_layer = guessing_layer_arg.getValue(); }catch (TCLAP::ArgException &e){ std::cerr << "error: " << e.error() << " for arg " << e.argId() << std::endl; } std::vector < std::vector <int> > var_layers; ReadCNFile(filename, cnf, var_layers); if (var_layers.size()==0){ LOG(INFO) << " No variable layers data found in CNF file. Will solve on core variables."; for (int i=0; i<core_len; ++i) guessing_vars.push_back(i+1); }else{ assert(guessing_layer<var_layers.size()); guessing_vars = var_layers[guessing_layer]; } if (mpi_rank==0){ // Generate sample Sample sample; MakeSample(cnf, core_len, sample, sample_size); int num_vars = sample[0].size(); BitMask out_mask; for (int i=0; i<num_vars; ++i) out_mask.push_back(i<(num_vars-out_len) ? 0:1); assert(out_mask.size()==sample[0].size()); // Define starting point PointId starting_point; for (int i=0; i<guessing_vars.size(); ++i) starting_point.push_back(1); Master master(mpi_size); master.search_engine_.sat_threshold_= sat_threshold; master.Search(num_iterations, starting_point, guessing_vars, out_mask, sample); master.SendExitSignal(); }else{ Worker worker(cnf, scans_limit); worker.MainJobCycle(); } return 0; }
int main(int argc, char *argv[]) { std::ios::sync_with_stdio(false); // Examine any option settings made by the user. -f is the only // required one. Options opts; bool skip_preflight = false; bool verify = false; int start = -1; int cutoff = -1; filesystem::path authors_file; filesystem::path branches_file; filesystem::path modules_file; std::vector<std::string> args; for (int i = 1; i < argc; ++i) { if (argv[i][0] == '-') { if (argv[i][1] == '-') { if (std::strcmp(&argv[i][2], "verify") == 0) verify = true; else if (std::strcmp(&argv[i][2], "verbose") == 0) opts.verbose = true; else if (std::strcmp(&argv[i][2], "quiet") == 0) opts.quiet = true; else if (std::strcmp(&argv[i][2], "debug") == 0) opts.debug = 1; else if (std::strcmp(&argv[i][2], "skip") == 0) skip_preflight = 1; else if (std::strcmp(&argv[i][2], "start") == 0) start = std::atoi(argv[++i]); else if (std::strcmp(&argv[i][2], "cutoff") == 0) cutoff = std::atoi(argv[++i]); else if (std::strcmp(&argv[i][2], "authors") == 0) authors_file = argv[++i]; else if (std::strcmp(&argv[i][2], "branches") == 0) branches_file = argv[++i]; else if (std::strcmp(&argv[i][2], "modules") == 0) modules_file = argv[++i]; else if (std::strcmp(&argv[i][2], "gc") == 0) opts.collect = lexical_cast<int>(argv[++i]); } else if (std::strcmp(&argv[i][1], "v") == 0) opts.verbose = true; else if (std::strcmp(&argv[i][1], "q") == 0) opts.quiet = true; else if (std::strcmp(&argv[i][1], "d") == 0) opts.debug = 1; else if (std::strcmp(&argv[i][1], "A") == 0) authors_file = argv[++i]; else if (std::strcmp(&argv[i][1], "B") == 0) branches_file = argv[++i]; else if (std::strcmp(&argv[i][1], "M") == 0) modules_file = argv[++i]; } else { args.push_back(argv[i]); } } // Any remaining arguments are the command verb and its particular // arguments. if (args.size() < 2) { std::cerr << "usage: subconvert [options] COMMAND DUMP-FILE" << std::endl; return 1; } std::string cmd(args[0]); if (cmd == "git-test") { StatusDisplay status(std::cerr); Git::Repository repo(args[1], status); std::cerr << "Creating initial commit..." << std::endl; Git::CommitPtr commit = repo.create_commit(); struct tm then; strptime("2005-04-07T22:13:13", "%Y-%m-%dT%H:%M:%S", &then); std::cerr << "Adding blob to commit..." << std::endl; commit->update("foo/bar/baz.c", repo.create_blob("baz.c", "#include <stdio.h>\n", 19)); commit->update("foo/bar/bar.c", repo.create_blob("bar.c", "#include <stdlib.h>\n", 20)); commit->set_author("John Wiegley", "*****@*****.**", std::mktime(&then)); commit->set_message("This is a sample commit.\n"); Git::Branch branch(&repo, "feature"); std::cerr << "Updating feature branch..." << std::endl; branch.commit = commit; commit->write(); branch.update(); std::cerr << "Cloning commit..." << std::endl; commit = commit->clone(); // makes a new commit based on the old one std::cerr << "Removing file..." << std::endl; commit->remove("foo/bar/baz.c"); strptime("2005-04-10T22:13:13", "%Y-%m-%dT%H:%M:%S", &then); commit->set_author("John Wiegley", "*****@*****.**", std::mktime(&then)); commit->set_message("This removes the previous file.\n"); Git::Branch master(&repo, "master"); std::cerr << "Updating master branch..." << std::endl; master.commit = commit; commit->write(); master.update(); return 0; } try { SvnDump::File dump(args[1]); if (cmd == "print") { SvnDump::FilePrinter printer(dump); while (dump.read_next(/* ignore_text= */ true)) printer(dump.get_curr_node()); } else if (cmd == "authors") { invoke_scanner<Authors>(dump); } else if (cmd == "branches") { invoke_scanner<Branches>(dump); } else if (cmd == "convert") { StatusDisplay status(std::cerr, opts); ConvertRepository converter (args.size() == 2 ? filesystem::current_path() : args[2], status, opts); // Load any information provided by the user to assist with the // migration. int errors = 0; if (! authors_file.empty() && filesystem::is_regular_file(authors_file)) errors += converter.authors.load_authors(authors_file); if (! branches_file.empty() && filesystem::is_regular_file(branches_file)) errors += Branches::load_branches(branches_file, converter, status); if (! modules_file.empty() && filesystem::is_regular_file(modules_file)) errors += Submodule::load_modules(modules_file, converter); // Validate this information as much as possible before possibly // wasting the user's time with useless work. if (! skip_preflight) { status.verb = "Scanning"; while (dump.read_next(/* ignore_text= */ false, /* verify= */ true)) { int final_rev = dump.get_last_rev_nr(); if (cutoff != -1 && cutoff < final_rev) final_rev = cutoff; status.set_final_rev(final_rev); int rev = dump.get_rev_nr(); if (cutoff != -1 && rev >= cutoff) break; if (start == -1 || rev >= start) errors += converter.prescan(dump.get_curr_node()); } status.newline(); converter.copy_from.sort(comparator()); if (status.debug_mode()) { for (ConvertRepository::copy_from_list::iterator i = converter.copy_from.begin(); i != converter.copy_from.end(); ++i) { std::ostringstream buf; buf << (*i).first << " <- " << (*i).second; status.info(buf.str()); } } errors += status.count_errors(); if (errors > 0) { status.warn("Please correct the errors listed above and run again."); return 1; } status.warn("Note: --skip can be used to skip this pre-scan."); dump.rewind(); } // If everything passed the preflight, perform the conversion. status.verb = "Converting"; while (dump.read_next(/* ignore_text= */ false)) { int final_rev = dump.get_last_rev_nr(); if (cutoff != -1 && cutoff < final_rev) final_rev = cutoff; status.set_final_rev(final_rev); int rev = dump.get_rev_nr(); if (cutoff != -1 && rev >= cutoff) break; if (start == -1 || rev >= start) converter(dump.get_curr_node()); else status.update(rev); } converter.finish(); } else if (cmd == "scan") { StatusDisplay status(std::cerr, opts); while (dump.read_next(/* ignore_text= */ !verify, /* verify= */ verify)) { status.set_final_rev(dump.get_last_rev_nr()); if (opts.verbose) status.update(dump.get_rev_nr()); } if (opts.verbose) status.finish(); } } catch (const std::exception& err) { std::cerr << "Error: " << err.what() << std::endl; return 1; } return 0; }
void Foam::cyclicGgiPolyPatch::calcTransforms() const { if (active() && debug) { // Check definition of the cyclic pair checkDefinition(); } // For computing the rotation tensors forwardT and reverseT, we // can see from Robert Magnan's post on the Forum dated // 27/May/2008 that we cannot use the actual implementation of // calcTransformTensors and rotationTensor. // // It is also not possible to use Robert solution because for // non-conformal cyclic meshes, we cannot usualy find a pair of // matching faces for computing the tensors. So we are using // user-supplied values instead. // // Since these tensors are defined as private in the // coupledPolyPatch class definition, we will override these // values here and compute the tensors ourselves using the // Rodrigues Rotation formula. // We compute the rotationTensor from rotationAxis_ and // rotationAngle_ We compute the separation vector from // separationOffset_ // All transforms are constant: size = 1. HJ, 18/Feb/2009 if (mag(rotationAngle_) > SMALL) { // Rotation tensor computed from rotationAxis_ and rotationAngle_ // Note: cyclics already have opposing signs for the rotation // so there is no need for a special practice. HJ, 30/Jun/2009 forwardT_ = tensorField ( 1, RodriguesRotation(rotationAxis_, -rotationAngle_) ); reverseT_ = tensorField ( 1, RodriguesRotation(rotationAxis_, rotationAngle_) ); } else { forwardT_.setSize(0); reverseT_.setSize(0); } // Handling the separation offset separatly if (mag(separationOffset_) > SMALL) { separation_ = vectorField(1, separationOffset_); } else { separation_.setSize(0); } if (debug > 1 && master()) { if (patchToPatch().uncoveredMasterFaces().size() > 0) { // Write uncovered master faces Info<< "Writing uncovered master faces for patch " << name() << " as VTK." << endl; const polyMesh& mesh = boundaryMesh().mesh(); fileName fvPath(mesh.time().path()/"VTK"); mkDir(fvPath); indirectPrimitivePatch::writeVTK ( fvPath/fileName("uncoveredCyclicGgiFaces" + name()), IndirectList<face> ( localFaces(), patchToPatch().uncoveredMasterFaces() ), localPoints() ); } if (patchToPatch().uncoveredSlaveFaces().size() > 0) { // Write uncovered master faces Info<< "Writing uncovered shadow faces for patch " << shadowName() << " as VTK." << endl; const polyMesh& mesh = boundaryMesh().mesh(); fileName fvPath(mesh.time().path()/"VTK"); mkDir(fvPath); indirectPrimitivePatch::writeVTK ( fvPath/fileName("uncoveredCyclicGgiFaces" + shadowName()), IndirectList<face> ( shadow().localFaces(), patchToPatch().uncoveredSlaveFaces() ), shadow().localPoints() ); } // Check for bridge overlap if (!bridgeOverlap()) { if ( patchToPatch().uncoveredMasterFaces().size() > 0 || patchToPatch().uncoveredSlaveFaces().size() > 0 ) { FatalErrorIn("label cyclicGgiPolyPatch::shadowIndex() const") << "cyclic ggi patch " << name() << " with shadow " << shadowName() << " has " << patchToPatch().uncoveredMasterFaces().size() << " uncovered master faces and " << patchToPatch().uncoveredSlaveFaces().size() << " uncovered slave faces. Bridging is switched off. " << abort(FatalError); } } } }