Exemplo n.º 1
0
TestControl::TestControl(const InputParameters & parameters)
  : Control(parameters), _test_type(getParam<MooseEnum>("test_type")), _alias("this/is/alias")
{
  if (_test_type == "real")
    getControllableValue<Real>("parameter");

  else if (_test_type == "variable")
    getControllableValue<NonlinearVariableName>("parameter");

  else if (_test_type == "tid_warehouse_error")
    _fe_problem.getControlWarehouse().initialSetup(12345);

  else if (_test_type == "disable_executioner")
    getControllableValue<bool>("parameter");

  else if (_test_type == "connection")
  {
    MooseObjectParameterName master(MooseObjectName("Kernels", "diff"), "coef");
    MooseObjectParameterName slave(MooseObjectName("BCs", "left"), "value");
    _app.getInputParameterWarehouse().addControllableParameterConnection(master, slave);
  }

  else if (_test_type == "alias")
  {
    MooseObjectParameterName slave(MooseObjectName("BCs", "left"), "value");
    _app.getInputParameterWarehouse().addControllableParameterConnection(_alias, slave);
  }

  else if (_test_type == "mult")
    getControllableValue<Real>("parameter");

  else if (_test_type != "point")
    mooseError("Unknown test type.");
}
Exemplo n.º 2
0
int main(int argc, char **argv) 
{
  int rank, comm_sz, r_status;
  
  MPI_Init(&argc, &argv);
  MPI_Comm_rank(MPI_COMM_WORLD, &rank);
  MPI_Comm_size(MPI_COMM_WORLD, &comm_sz);
  
  // MPI_Errhandlerset(MPI_COMM_WORLD, MPI_ERRORS_RETURN);

  if (argc != 2) {
    fprintf(stderr, "Usage: krig n_iter\n");
    exit(1);
  }
  int n = atoi(argv[1]);
  if (rank == 0)
    printf("Begin %d iterations of %d processes\n", n, comm_sz);
  int i;
  for (i = 0; i < n; i++) {   
    slave(rank, comm_sz);
  }
  
  if (errno)
    perror("pre-finalize");
  if (MPI_Finalize() != 0) {
      perror("MPI_Finalize");
  }

  return 0;
}
Exemplo n.º 3
0
int main(void) {
#else
int main(int argc, char **argv) {
#endif

#ifdef __patmos__
  // nothing special to initialize
#else /* __patmos__ */
  core_id = strtol(argv[1], NULL, 0);
  // initialize MPBs
  shm_init();
#endif /* __patmos__ */

  if (core_id == 0) {
    master();
  } else {
    slave();
  }

#ifdef __patmos__
  // nothing to clean up
#else /* __patmos__ */
  shm_clean();
#endif /* __patmos__ */

  return 0;

}
Exemplo n.º 4
0
int main ()
{
    I2CSlave slave(I2C_SDA, I2C_SCL);
    
    char buf[10];
    char msg[] = "Slave!";

    slave.address(LM75_ADDR);
    while (1) {
        int i = slave.receive();
        switch (i) {
            case I2CSlave::ReadAddressed:
                slave.write(msg, strlen(msg) + 1); // Includes null char
                //printf ( "read me %s.\n", msg );
                break;
            case I2CSlave::WriteGeneral:
                slave.read(buf, 3);
                //printf("Read G: %s\n", buf);
                break;
            case I2CSlave::WriteAddressed:
                slave.read(buf, 3);
                //printf("Read A: %s\n", buf);
                break;
            default:
                //printf ( "unknown ins: %d\n", i );
                //slave.stop ();
                break;
        }
        for(int i = 0; i < 10; i++) buf[i] = 0;    // Clear buffer
        
        myled = !myled;
        //wait (2);
    }
}
Exemplo n.º 5
0
int main(int argc, char **argv)
{

    /* Initialize MPI */
    MPI_Init(&argc, &argv);
  
    /* Find out my identity in the default communicator */
    MPI_Comm_rank(MPI_COMM_WORLD, &myrank);

    /*************** SPRNG Initialization *************************/
      //init_sprng(SPRNG_LCG, static_cast<int>(curTime) , SPRNG_DEFAULT);
      //init_sprng(SPRNG_LCG, 1938 , SPRNG_DEFAULT);
	// srand(1938);
	time_t curTime = time(0);
#ifndef _NO_SPRNG
      //init_sprng(SPRNG_LCG, static_cast<int>(curTime) , SPRNG_DEFAULT);
	CSE::Math::Seeder(static_cast<unsigned int>(curTime), curTime);
#else
	CSE::Math::Seeder(static_cast<unsigned int>(curTime)*myrank, curTime);
#endif    
    //srand(static_cast<unsigned int>(curTime)*myrank);
    //printf("Process %d, print information about stream:\n", myid);
    //print_sprng();

    if (myrank == 0)
        master();
    else
        slave();

    /* Shut down MPI */
    MPI_Finalize();
  
    return 0;
}
Exemplo n.º 6
0
int main(int argc, char *argv[]) {
    int    proc_id;       // Process ID number
    int    n_proc;        // Number of processes
    int    n_rows = 1000; // Number of rows
    int    n_cols = 1000; // Number of columns

    // Initialize MPI
    MPI_Init(&argc, &argv);
    MPI_Comm_size(MPI_COMM_WORLD, &n_proc);
    MPI_Comm_rank(MPI_COMM_WORLD, &proc_id);

    if (n_proc == 1) {
        puts("Error: requires two or more processes (no work will be done).");
        MPI_Finalize();
        exit(1);
    }

    if (proc_id == MASTER) {
        master(n_proc, n_rows, n_cols);
    }
    else {
        slave(proc_id, n_rows, n_cols);
    }

    MPI_Finalize();
    return 0;
}
Exemplo n.º 7
0
main(int argc, char* argv[]) {

  int myrank;

  /* read in command-line arguments and check validity */
  if ( argc < 3 ) {
    printf( "usage: %s <matrix_size> <block_size>\n", argv[0] ) ;
    exit( -1 );
  } else {
    matrix_size = atoi( argv[1] ) ;
    block_size = atoi( argv[2] ) ;
    if ( (matrix_size == 0) || (block_size == 0) ||
	 ((matrix_size-((matrix_size/block_size)*block_size)) != 0) ) {
      printf( "arguments do not satisfy program assumptions:\n"
	      "\t matrix_size > 0, block_size > 0, and\n"
	      "\t block_size perfectly divides matrix_size\n" ) ;
      exit( -1 ) ;
    }
  }

  MPI_Init(&argc,&argv);
  MPI_Comm_rank(MPI_COMM_WORLD,&myrank);

  if (myrank==0) {
    master();
  } else {
    slave();
  }

  MPI_Finalize();
}
Exemplo n.º 8
0
void main(int argc, char *argv[])
{
    char *str1 = "master";
    char *str2 = "slave";
    if(argc == 2)
        printf("The argument supplied is %s\n", argv[1]);
    else if(argc > 2)
    {
        printf("Too many arguments\n");
        exit(0);
    }
    else
    {
        printf("One argument expected (slave/master)\n");
        exit(0);
    }
    if(strcmp(argv[1], str1) == 0)
    {
        printf("This instance of the program will take the role as master\n");
        master();
    }
    else if (strcmp(argv[1], str2) == 0)
    {
        printf("This instance of the program will take the role as slave\n");
        slave();
    }
}
int main(int argc, char *argv[])
{
  Slave slave(argc, argv);

  QStringList args = QCoreApplication::arguments();

  if (args.contains("--help")
   || args.contains("-h")) {
    printf("Usage: %s [ip of relay server]\n",
      qPrintable(QFileInfo(argv[0]).baseName()));
    return 0;
  }

  if (!slave.init()) {
	qFatal("Failed to init slave class. Exiting..");
	return 1;
  }

  QString relay = "127.0.0.1";
  if (args.length() > 1) {
	relay = args.at(1);
  }

  slave.connect(relay, 8500);

  return slave.exec();
}
Exemplo n.º 10
0
QList<QAction *> QMultiInputContext::actions()
{
    QList<QAction *> a = slave()->actions();
    a.append(separator);
    a.append(menu->menuAction());
    return a;
}
Exemplo n.º 11
0
/* Main */
int main(int argc, char *argv[])
{
    int rank;
    int size;
    /* Initialize MPI */
    if(MPI_Init(&argc, &argv) != MPI_SUCCESS)
    {
        fprintf(stderr, "Unable to initialize MPI!\n");
        return -1;
    }
    /* Get rank and size */
    MPI_Comm_rank(MPI_COMM_WORLD, &rank);
    MPI_Comm_size(MPI_COMM_WORLD, &size);
    

    /* Populate the parameters with default values */
    Params p;

    /* Don't be verbose by default */
    p.verbose = 0;
    p.rank = rank;

    // Used for cleaner code later on
    p.size = size - 1;
    
    p.array_size = DEFAULT_ARRAY_SIZE;
    p.max_num = MAX_NUM_SIZE;
    /* Check for user options */
    parse_args(argc,argv,&p);
    slave(&p);
    MPI_Finalize();
    return 0;

}
Exemplo n.º 12
0
int main(int argc, char **argv)
{

    /* Initialize MPI */
    MPI_Init(&argc, &argv);

    /* Find out my identity in the default communicator */
    MPI_Comm_rank(MPI_COMM_WORLD, &myrank);

    /*************** SPRNG Initialization *************************/
    time_t curTime = time(0);
#ifndef _NO_SPRNG
    init_sprng(SPRNG_LCG, static_cast<int>(curTime) , SPRNG_DEFAULT);
#else
    CSE::Math::Seeder(static_cast<unsigned int>(curTime)*myrank, curTime);
#endif

    if (myrank == 0)
        master();
    else
        slave();

    /* Shut down MPI */
    MPI_Finalize();

    return 0;
}
Exemplo n.º 13
0
task main()
{
	//waitForStart();// Waiting for start command from FCS
	while(true)// Command recieved start loop untill FCS closes program
	{
		g = SensorValue(Gyro);
		i = SensorValue(IR);
  	getJoystickSettings(joystick); //Refresh joystick values

  	if (joy1Btn(6) || joy1Btn(8)) {drive_power = drive_max_power;} //If joystick 1 button TR or BR are pushed set drive power to boost mode, otherwise set it to normal power
		else {drive_power = drive_min_power;} //If joystick 1 button TR or BR are pushed set drive power to boost mode, otherwise set it to normal power

		initial_power(); //Set the global power values

		if (joy1Btn(7) || joy1Btn(5)) {inverse_slave();} //If joystick 1 button RL or BL are pushed run the subrutine to rotate in place

		if (joy1Btn(3) || joy2Btn(3)) {reset();} //If joystick 1 or joystick 2 push the red b button set all motor speeds to 0 unitll release

		if (joy1Btn(1) || joy1Btn(2)) {slave();} //If joystick 1 button A or X are pressed, slave the two drive motors together

		if (joy2Btn(5)) {paddeler(1);} //If joystick 2 button TL is pushed, move the paddles at speed tower_paddle_power

		if (joy2Btn(7)) {paddeler(-1);} //If joystick 2 button TL is pushed, move the paddles at negative speed tower_paddle_power

		if (joy2Btn(2)) {tower_flag = tower_flag_power;} //If joystick 2 button A is pressed, run flag motor forward

		if (joy2Btn(4)) {tower_flag = -1* tower_flag_power;} //If joystick 2 button Y is pressed, run flag motor backwards

		send_debug();//Send Debugging info to debugger nxt
		enact_power();//Enact the power variables layed out by the previous subrutines
  }
}
Exemplo n.º 14
0
int main(int argc, char* argv[])
{
	int proc_id;            // Process rank
	int n_proc;             // Number of processes

	// Initialize MPI
	MPI_Init(&argc, &argv);

	// Get the current process id
	MPI_Comm_rank(MPI_COMM_WORLD, &proc_id);

	// Get the current number of processes
	MPI_Comm_size(MPI_COMM_WORLD, &n_proc);

	if (proc_id == MASTER)
	{
			master(n_proc);
	}
	else
	{
			slave(proc_id);
	}

	// Required to terminate all MPI processes
	MPI_Finalize();
	return 0;
}
Exemplo n.º 15
0
void RoomPropertySetter::parseProperty(const QByteArray &command, const Coordinate &roomPos)
{
    QList<QByteArray> words = command.simplified().split(' ');
    AbstractAction *action = 0;
    QByteArray property = words[1];
    uint pos = propPositions[property];
    if (words.size() == 4) {
        //change exit property
        ExitDirection dir = Mmapper2Exit::dirForChar(words[2][0]);
        switch (pos) {
        case E_FLAGS:
        case E_DOORFLAGS:
            action = new ModifyExitFlags(fieldValues[property], dir, pos, FMM_TOGGLE);
            break;
        case E_DOORNAME:
            action = new UpdateExitField(property, dir, pos);
            break;
        default:
            emit sendToUser("unknown property: " + property + "\r\n");
            return;
        }
    } else if (words.size() == 3) {
        //change room property
        switch (pos) {
        case R_TERRAINTYPE:
            action = new UpdatePartial(fieldValues[property], pos);
            break;
        case R_NAME:
        case R_DESC:
            action = new UpdatePartial(property, pos);
            break;
        case R_MOBFLAGS:
        case R_LOADFLAGS:
            action = new ModifyRoomFlags(fieldValues[property], pos, FMM_TOGGLE);
            break;
        case R_DYNAMICDESC:
        case R_NOTE:
            action = new UpdateRoomField(property, pos);
            break;
        case R_PORTABLETYPE:
        case R_LIGHTTYPE:
        case R_ALIGNTYPE:
        case R_RIDABLETYPE:
            action = new UpdateRoomField(fieldValues[property], pos);
            break;
        default:
            emit sendToUser("unknown property: " + property + "\r\n");
            return;
        }

        RoomPropertySetterSlave slave(action);
        emit lookingForRooms(&slave, roomPos);

        if (slave.getResult()) {
            emit sendToUser("OK\r\n");
        } else {
            emit sendToUser("setting " + property + " failed!\r\n");
        }
    }
}
Exemplo n.º 16
0
int kdemain( int argc, char **argv )
{
  KAboutData aboutData ( ABOUT_APP_NAME,
                         ABOUT_CATALOG_NAME,
                         ki18n(ABOUT_PROGRAM_NAME),
                         ABOUT_VERSION,
                         ki18n(ABOUT_DESCRIPTION),
                         ABOUT_LICENCE_TYPE,
                         ki18n(ABOUT_COPYRIGHT),
                         ki18n(ABOUT_INFORMATION),
                         ABOUT_WEBPAGE,
                         ABOUT_EMAIL );
  KComponentData componentData ( aboutData );

  QCoreApplication app( argc, argv );

  if (argc != 4)
  {
    fprintf(stderr, i18n("Usage: ").arg("kio_klipper protocol domain-socket1 domain-socket2\n").toUtf8() );
    exit(-1);
  }

  kDebug() << QString("started kio slave '%1' with PID %2").arg(argv[0]).arg(getpid());
  KIO_CLIPBOARD::KIOKlipperProtocol slave(argv[2], argv[3]);
  slave.dispatchLoop();

  kDebug() << "slave done";
  return ( 0 );
} // kdemain
Exemplo n.º 17
0
int main(int argc, char **argv)
{
  int myrank, nslaves;
  double t1, t2;

  MPI_Init(&argc, &argv);
  MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
  t1 = MPI_Wtime();

  //Get number of slaves by getting total number and subtracting 1
  MPI_Comm_size(MPI_COMM_WORLD, &nslaves);
  nslaves = nslaves - 1;

  if (myrank==0)
    {
      master(nslaves, argv[1]);
    }
  else
    {
      slave(myrank, argv[2]);
    }

  t2 = MPI_Wtime();
  if(myrank==0)
    fprintf(stdout, "Elapsed time is %f \n", t2-t1);

  MPI_Finalize();
  return 0;
}
Exemplo n.º 18
0
 KDE_EXPORT int kdemain( int, char **argv )
 {
     KComponentData componentData( "kio_applications" );
     ApplicationsProtocol slave(argv[1], argv[2], argv[3]);
     slave.dispatchLoop();
     return 0;
 }
Exemplo n.º 19
0
int main(int argc, char **argv) {
    /////////////////////////////
    // Initialize MPI
    MPI_Init(&argc, &argv);
    int rank, nprocs;
    MPI_Comm_rank(MPI_COMM_WORLD, &rank);
    MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
    if (argc < 2)
        die("ERROR: Must provide 2 arguments\n\tmpirun -n {num procs} EXEC"
                    " {number of cities} {distance file}\n");
    const int num_of_cities = atoi(argv[1]);
    char *file_location = argv[2];
    //
    /////////////////////////////

    /////////////////////////////
    // Array Init
    int **cityDistances = allocate_cells(num_of_cities, num_of_cities);
    initialize_city_distances(file_location, cityDistances, num_of_cities);
    //
    /////////////////////////////

    /////////////////////////////
    // Pick a coordination node / or just make it 0
    // TODO refactor this to be distributed
    time_t start_time = time(NULL);
    if (rank == 0) // Make the first processor the master
        master(cityDistances, num_of_cities, nprocs, 10);
    else // Otherwise their supporting roles
        slave(cityDistances, num_of_cities, rank, nprocs, 10);
    if (rank == 0) printf("Time to calc: %li\n", time(NULL) - start_time);
    /////////////////////////////

    MPI_Finalize(); // Close MPI
}
Exemplo n.º 20
0
void MW_Run (int argc, char** argv, struct mw_api_spec *f) {
	
	int sz,myid;
	MPI_Comm_size(MPI_COMM_WORLD, &sz);
	MPI_Comm_rank(MPI_COMM_WORLD, &myid);
	//MPI_Barrier(MPI_COMM_WORLD); 
	srand(time(NULL)*(myid+1));

  	id = myid;

  	WORK_NUM = std::stoi(*(argv+1));
  	master_fail_p = std::stod(*(argv+2));
	slave_fail_p = std::stod(*(argv+3));
	

	if(myid <= 1){
		master(f, sz, myid);	
	} 
	else {
		slave(f, sz, myid);
	}

  	//MPI_Barrier(MPI_COMM_WORLD);
  	MPI_Finalize (); 
  	
}
Exemplo n.º 21
0
main(int argc, char** argv)
{
  int my_rank, proc_n, job_count, job_size;
  double t1, t2;

  MPI_Init(&argc , &argv);
  MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);
  MPI_Comm_size(MPI_COMM_WORLD, &proc_n);

  job_count = atoi(argv[1]);
  job_size = atoi(argv[2]);

  if (my_rank == 0)
  {
    t1 = MPI_Wtime();
    Master master(my_rank, proc_n - 1, job_count, job_size);
    // printf("Before:\n");
    // master.printJobs();
    master.mainLoop();
    // printf("After:\n");
    //master.printJobs();
    t2 = MPI_Wtime();
    printf("time elapsed: %f\n", t2 - t1);
  }
  else
  {
    Slave slave(my_rank, job_size);
    slave.mainLoop();
  }

  MPI_Finalize();
}
Exemplo n.º 22
0
bool
verifySlaveLoad(BaseString &table)
{
  //BaseString  sqlStm;
  BaseString  db;
  unsigned int masterCount = 0;
  unsigned int slaveCount  = 0;
 
  db.assign("TEST_DB");
  //sqlStm.assfmt("SELECT COUNT(*) FROM %s", table);

  //First thing to do is sync slave
  printf("Calling syncSlave\n");
  if(!syncSlaveWithMaster())
  {
    g_err << "Verify Load -> Syncing with slave failed" << endl;
    return false;
  }

  //Now that slave is sync we can verify load
  DbUtil master(db.c_str());

  //Login to Master
  if (!master.connect())
  {
    g_err << "Verify Load -> connect to master failed" << endl;
    return false;
  }

  if((masterCount = master.selectCountTable(table.c_str())) == 0 )
  {
    g_err << "Verify Load -> masterCount == ZERO!" << endl;
    return false;
  }
  
  //Create a DB Object for slave
  DbUtil slave(db.c_str(), ".1.slave");

  //Login to slave
  if (!slave.connect())
  {
    g_err << "Verify Load -> connect to master failed" << endl;
    return false;
  }

  if((slaveCount = slave.selectCountTable(table.c_str())) == 0 )
  {
    g_err << "Verify Load -> slaveCount == ZERO" << endl;
    return false;
  }
  
  if(slaveCount != masterCount)
  {
    g_err << "Verify Load -> Slave Count != Master Count "
          << endl;
    return false;
  }
  return true;
}
Exemplo n.º 23
0
int main(int argc, char *argv[])
{
    if (argc < 2)
        master();
    else
        slave();
    return 0;
}
Exemplo n.º 24
0
void *bootstrap(void *arg){
	int id = *(int*)arg;
	if(id == 0){
		master(&id);
	} else {
		slave(&id);
	}
}
Exemplo n.º 25
0
int main(int argc, char **argv)
{
//# What if directory is half done then what happens, check if corresponding out exists first
//# master creates the new directory, others write their output there.
//# Argument parsing is going to be in the sge side or this side
//# Crash can happen in one of the processors, then the others take over and finish?
//# Crash can happen in the SGE, than some of them are finished, when we come back do we restart?
// 3-> we check first, if the output exists or not

/*
blast_quality_rescorer354.pl -in batch000000.bo.gz.parse  -out batch000000.bo.gz.parse.out -minquality 30 -qual2db
/home/zhaoshi/macaque/Oct-04/Macaque.qual  -header -columns 4:5:6:0:1:2  -inputtype blastparser -alignments 15:14
-qdecode_program base2qual_compact_acgt -globalfast
*/

  char *rescoreparameters;
  char *inputdir;
  char *outputdir;
  char *MPIparameters;
  char **MPIargv;

  int myrank;
  int i;

  rescoreparameters = (char *) malloc(sizeof(char)*1000);
  inputdir = (char *) malloc(sizeof(char)*1000);
  outputdir = (char *) malloc(sizeof(char)*1000);

  strcpy(rescoreparameters,argv[1]);
  strcpy(inputdir,argv[2]);
  strcpy(outputdir,argv[3]);


 /* Initialize MPI */

  MPI_Init(&argc,&argv);


  /* Find out my identity in the default communicator */

  MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
  if (myrank == 0) {
    master(inputdir,outputdir,rescoreparameters);
  } else {

    printf("slave is started\n");
    slave();
  }

  /* Shut down MPI */

  MPI_Finalize(); 




  return 0;
}
Exemplo n.º 26
0
QList<QAction *> QMultiInputContext::actions()
{
    QList<QAction *> a = slave()->actions();
    a.append(separator);
#ifndef QT_NO_MENU // for QT_WEBOS	
    a.append(menu->menuAction());
#endif // QT_NO_MENU // for QT_WEBOS
    return a;
}
Exemplo n.º 27
0
extern "C" int Q_DECL_EXPORT kdemain(int argc, char **argv)
{
    if (argc != 4) {
        fprintf(stderr, "Usage: kio_kdeconnect protocol pool app\n");
        exit(-1);
    }

    KioKdeconnect slave(argv[2], argv[3]);
    slave.dispatchLoop();
    return 0;
}
Exemplo n.º 28
0
int main(int argc, char **argv) {
	int rtnval, rank;

	MPI_Init(&argc, &argv)
	MPI_Comm_rank(MPI_COMM_WORLD,&rank);
	
	rtnval = (rank == 0) ? master(argc,argv) : slave();

	MPI_Finalize();
	return rtnval;
}
Exemplo n.º 29
0
    int KDE_EXPORT kdemain( int argc, char **argv )
    {
        // necessary to use other kio slaves
        KComponentData componentData("kio_zeroconf");
        QCoreApplication app(argc,argv);

        // start the slave
        ZeroConfProtocol slave(argv[1],argv[2],argv[3]);
        slave.dispatchLoop();
        return 0;
    }
Exemplo n.º 30
0
int main(int argc, char** argv) {
    MPI_Init(&argc, &argv);
    int num;
    MPI_Comm_rank(MPI_COMM_WORLD,&num);
    
    if (num==0)
        master();
    else
        slave();
    
    MPI_Finalize();
}