Beispiel #1
0
VOID Commence() {

    trace_enter();

    /* Init instruction counter */
    counter = 0;
    init = true;
    string _addr, _name;
    if (ifile.is_open()) {
        while (ifile) {
            char m;
            unsigned int nb_param = 0;
            vector<bool> type_param;
            string img_name = read_part(&m);

            if (img_name.empty()) {
                continue;
            }

            ADDRINT img_addr = atol(read_part(&m).c_str());
            string name = read_part(&m);

            /* Read parameters */
            while (ifile && m != '\n') {
                string part = read_part(&m);
                switch (part[0]) {
                case 'A':
                    type_param.push_back(true);
                    break;
                case 'I':
                case 'V':
                    type_param.push_back(false);
                    break;
                case 'F':
                    type_param.push_back(false);
                    break;
                default:
                    type_param.push_back(false);
                }
                nb_param += 1;
            }

            FID fid = fn_register(img_name, img_addr, name);
            if (fid != FID_UNKNOWN) {
                fn_registered(fid, nb_param - 1, type_param);
            }
        }
    }

    gettimeofday(&start, NULL);

    trace_leave();

    return;
}
Beispiel #2
0
VOID register_functions_from_arity_log() {
    ifstream ifile;
    ifile.open(KnobInputFile.Value().c_str());

    if (ifile.is_open()) {
        while (ifile) {
            char m;
            string img_name = read_part(ifile, &m);
            if (img_name.empty()) {
                continue;
            }

            ADDRINT img_addr = atol(read_part(ifile, &m).c_str());
            string name = read_part(ifile, &m);

            UINT64 int_arity = atol(read_part(ifile, &m).c_str());
            UINT64 int_stack_arity = atol(read_part(ifile, &m).c_str());
            UINT64 float_arity = atol(read_part(ifile, &m).c_str());
            UINT64 float_stack_arity = atol(read_part(ifile, &m).c_str());
            UINT64 has_return = atol(read_part(ifile, &m).c_str());

            vector<UINT32> int_param_idx;
            while (ifile && m != '\n') {
                string part = read_part(ifile, &m);
                if (part.length() == 0) {
                    break;
                }

                long idx = atol(part.c_str());
                int_param_idx.push_back(idx);
            }

            FID fid = fn_register(img_name, img_addr, name);
            if (fid != FID_UNKNOWN) {
                fn_registered(fid,
                    int_arity, int_stack_arity,
                    float_arity, float_stack_arity,
                    has_return,
                    int_param_idx);
            }
        }

        ifile.close();
    }
}
Beispiel #3
0
int
main (int argc, char *argv[])
{

  double t1, t2, t3, t4, t5, t6, t7;	/*timers */

  MPI_Init (&argc, &argv);
  MPI_Comm_rank (MPI_COMM_WORLD, &ThisTask);
  MPI_Comm_size (MPI_COMM_WORLD, &NTask);

  t1 = MPI_Wtime ();

  initvars ();

  check_params (argc, argv);

  splitdomain ();		/*select mesh size for domain decomposition based on NTask, produce spx,spy,spz */

  read_header ();		/*read file header and set file format */

  MPI_Barrier (MPI_COMM_WORLD);

  read_part ();			/*read particles, allocate each task >> locind, locbuffer, NumThis */

  selectposition ();		/*set cell position this task > ithis,jthis,kthis */

  setbordersize ();		/*set border lenght bsize */

  MPI_Barrier (MPI_COMM_WORLD);
  t2 = MPI_Wtime ();

  /*Transfer temporary boundary particles in the 6 directions */
  selectborder (0);/*-x*/
  selectborder (1);		/*+x */
  selectborder (2);/*-y*/
  selectborder (3);		/*+y */
  selectborder (4);/*-z*/
  selectborder (5);		/*+z */

  MPI_Barrier (MPI_COMM_WORLD);

  t3 = MPI_Wtime ();
  printf ("Task=%d NumThis=%d NumThis_boundary=%d\n", ThisTask, NumThis,
	  NumThisb);

  if (NumThisb > NumThis) printf ("%s",warning2);

  /*run vt */
#ifndef LOWMEMORY
  runvt ();
#else
  if ((ThisTask % 2) == 0)
    runvt ();			/*run half jobs first to save some memory, slower */
  MPI_Barrier (MPI_COMM_WORLD);
  if ((ThisTask % 2) == 1)
    runvt ();
#endif
  t4 = MPI_Wtime ();

  computeneig ();		/* Neighbors computation */
#ifdef VERBOSE
  if (ThisTask == 0)
    printf ("Neighbors complete.\n");
#endif
  computedens ();		/* Density computation */
#ifdef VERBOSE
  if (ThisTask == 0)
    printf ("Density and Volume complete.\n");
#endif

#ifdef COMPUTEGRAD
 computegrad ();   	        /*VT gradient computation*/
  if (ThisTask == 0)
    printf ("Gradient complete.\n");
#endif
  t5 = MPI_Wtime ();
  MPI_Barrier (MPI_COMM_WORLD);
  t6 = MPI_Wtime ();


#ifdef WRITEDENSITY
  writedensopen ();
  if (ThisTask == 0)
    printf ("write density...");
  savedata (0);			/*gather and save density */
  if (ThisTask == 0)
    printf ("volumes...");
  savedata (1);			/*gather and save volumes */
#endif

#ifdef COMPUTEGRAD
  if (ThisTask == 0)
    printf ("gradient...");
  savedata (3);                 /*gather and save gradient x */
  savedata (4);
  savedata (5);
#endif

#ifdef WRITEDENSITY
  writedensclose ();
#endif

#ifdef WRITENEIGHBORS
  if (ThisTask == 0)
    printf ("neighbors...\n");
  writeneigopen ();
  savedata (2);			/*gather and save neighbors */
  writeneigclose ();
#else
  printf ("\n");
#endif

#ifdef COMPUTEGRID
  if (checkgrid ())
    {
      writegridopen ();
      computegrid ();
      writegridclose ();
    }
#endif
  t7 = MPI_Wtime ();
  MPI_Barrier (MPI_COMM_WORLD);
  if (ThisTask == 0)
    printf
      ("Time Stats: Read=%.2f Bdry=%.2f Comp=%.2f Write=%.2f Tot-I/O=%.2F Tot=%.2f\n",
       t2 - t1, t3 - t2, t6 - t3, t7 - t6, t6 - t2, t7 - t1);
#ifdef VERBOSE
  MPI_Barrier (MPI_COMM_WORLD);
  printf ("Task=%d Time VT_only=%.2f\n", ThisTask, t4 - t3);
  MPI_Barrier (MPI_COMM_WORLD);
#endif
  finalize ();			/*free memory and finalize code */
  return 0;
}				/* End Main */