Esempio n. 1
0
void fields::phase_material() {
  bool changed = false;
  if (is_phasing()) {
    for (int i=0;i<num_chunks;i++)
      if (chunks[i]->is_mine()) {
	chunks[i]->phase_material(phasein_time);
	changed = changed || chunks[i]->new_s;
      }
    phasein_time--;
  }
  if (or_to_all(changed)) {
    calc_sources(time() + 0.5*dt); // for integrated H sources
    update_eh(H_stuff); // ensure H = 1/mu * B
    step_boundaries(H_stuff);
    calc_sources(time() + dt); // for integrated E sources
    update_eh(E_stuff); // ensure E = 1/eps * D
    step_boundaries(E_stuff);
  }
}
Esempio n. 2
0
File: to_all.c Progetto: caomw/SOS
int
main(int argc, char* argv[])
{
    int c, i, mype, num_pes, tests, passed;
    char *pgm;

    shmem_init();
    mype = shmem_my_pe();
    num_pes = shmem_n_pes();

    if ((pgm=strrchr(argv[0],'/')))
        pgm++;
    else
        pgm = argv[0];

	while((c=getopt(argc,argv,"ampsSoxhv")) != -1) {
		switch(c) {
		  case 'a':
            And++;  // do not run and_to_all
			break;
		  case 'm':
            Min++;  // do not run min_to_all
			break;
		  case 'o':
            Or++;  // do not run or_to_all
			break;
		  case 'p':
            Prod++;  // do not run prod_to_all
			break;
		  case 's':
            Sum++;  // do not run sum_to_all
			break;
		  case 'x':
            Xor++;  // do not run xor_to_all
			break;
		  case 'S':
            Serialize++;
			break;
		  case 'v':
			Verbose++;
			break;
		  case 'h':
		  default:
                Rfprintf(stderr,"usage: %s {-v(verbose)|h(help)}\n",pgm);
			shmem_finalize();
			return 1;
		}
	}

    for (i = 0; i < SHMEM_REDUCE_SYNC_SIZE; i++) {
        pSync[i] = SHMEM_SYNC_VALUE;
        pSync1[i] = SHMEM_SYNC_VALUE;
    }

    tests = passed = 0;

    shmem_barrier_all();

    passed += max_to_all(mype, num_pes);
    tests++;

    if (!Min) {
        passed += min_to_all(mype, num_pes);
        tests++;
    }

    if (!Sum) {
        passed += sum_to_all(mype, num_pes);
        tests++;
    }

    if (!And) {
        passed += and_to_all(mype, num_pes);
        tests++;
    }

    if (!Prod) {
        passed += prod_to_all(mype, num_pes);
        tests++;
    }

    if (!Or) {
        passed += or_to_all(mype, num_pes);
        tests++;
    }

    if (!Xor) {
        passed += xor_to_all(mype, num_pes);
        tests++;
    }

    c = 0;
    if (mype == 0) {
        if ((Verbose || tests != passed))
            fprintf(stderr,"to_all[%d] %d of %d tests passed\n",
                    mype,passed,tests);
        c = (tests == passed ? 0 : 1);
    }

    shmem_finalize();

    return c;
}