Example #1
0
extern C int kernel_main(void)
{
    // Initialize heap
    Memory::initialize(0x00300000);

    RaspiSerial console;

    // TODO: put this in the boot.S, or maybe hide it in the support library? maybe a _run_main() or something.
    constructors();

    // TODO: this should be done from the support library too.
    // Later, a user-process should monitor the kernel console buffer and write
    // it to the selected console for the kernel.
#define BANNER \
    "FreeNOS " RELEASE " [" ARCH "/" SYSTEM "] (" BUILDUSER "@" BUILDHOST ") (" COMPILER_VERSION ") " DATETIME "\r\n"

    console.setMinimumLogLevel(Log::Debug);
    console.write(BANNER);
    console.write(COPYRIGHT "\r\n");
    NOTICE("Initializing subsystems");

    ARMMemory mem(128 * 1024 * 1024);
    ARMFactory fac;
    ProcessScheduler sched;
    ProcessManager procs(&fac, &sched);
    ARMKernel kernel(&mem, &procs);

    while (true)
	console.put(console.get());

    return 0;
}
bool SystemInformation::setTopProcesses( std::vector< std::string > const& _list )
{
    bool success = true;

    if( !_list.empty() )
    {
        for( auto list_it( _list.begin() )
                , end( _list.end() );
             list_it != end;
             ++list_it )
        {
            float cpu;
            float mem;
            std::string cmd;
            std::string excess;

            std::istringstream procs( *list_it );
            procs >> cpu >> mem >> cmd >> excess;

            if( cmd == "" || excess != "" )
            {
                success = false;
                break;
            }
            else
            {
                std::vector< variant > single_proc;
                single_proc.push_back( cmd );
                single_proc.push_back( cpu );
                single_proc.push_back( mem );
                processes__.push_back( single_proc );
            }
        }
    }
    else
Example #3
0
void do_geo(DisjointBoxLayout&              a_dbl,
            EBISLayout       &              a_ebisl,
            Box              &              a_domain,
            Real             &              a_dx )
{

  //define grids
  int len = 32;
  int mid = len/2;
  Real xdom = 1.0;
  a_dx = xdom/len;
  const IntVect hi = (len-1)*IntVect::Unit;
  a_domain=  Box(IntVect::Zero, hi);
  Vector<Box> boxes(4);
  Vector<int> procs(4);
  boxes[0] = Box(IntVect(D_DECL(0  ,  0,   0)), IntVect(D_DECL(mid-1, mid-1, len-1)));
  boxes[1] = Box(IntVect(D_DECL(0  ,mid,   0)), IntVect(D_DECL(mid-1, len-1, len-1)));
  boxes[2] = Box(IntVect(D_DECL(mid,  0,   0)), IntVect(D_DECL(len-1, mid-1, len-1)));
  boxes[3] = Box(IntVect(D_DECL(mid,mid,   0)), IntVect(D_DECL(len-1, len-1, len-1)));

  LoadBalance(procs, boxes);
  /**
  int loProc = 0;
  int hiProc = numProc() -1;
  procs[0] = loProc;
  procs[1] = hiProc;
  procs[2] = loProc;
  procs[3] = hiProc;
  **/

  a_dbl = DisjointBoxLayout(boxes, procs);

  //define geometry
  RealVect rampNormal = RealVect::Zero;
  rampNormal[0] = -0.5;
  rampNormal[1] = 0.866025404;

  Real rampAlpha = -0.0625;

  RealVect rampPoint = RealVect::Zero;
  rampPoint[0] = rampAlpha / rampNormal[0];

  bool inside = true;

  PlaneIF ramp(rampNormal,rampPoint,inside);

  RealVect vectDx = RealVect::Unit;
  vectDx *= a_dx;

  GeometryShop mygeom( ramp, 0, vectDx );
  RealVect origin = RealVect::Zero;

  EBIndexSpace *ebisPtr = Chombo_EBIS::instance();
  ebisPtr->define(a_domain, origin, a_dx, mygeom);

  //fill layout
  ebisPtr->fillEBISLayout(a_ebisl, a_dbl, a_domain, 4 );
}
Example #4
0
int main()
{
	int num, base;
	
	scanf("%d%d", &num, &base);
	
	procs(num, base);
	return 0;
}
Example #5
0
int main()
{
	int num;
	char str[90];
	
	scanf("%s", str);
	procs(str);
	
	return 0;
}
Example #6
0
File: status.c Project: awaw/status
static void
redraw(void)
{
	desktops(5);
	memory(90);
	loadaverage(400);
	procs(550);
	cpubar(650);
	showfile(750);
	datetime();
}
Example #7
0
int
_Tt_s_file::procs_joined()
{
	_Tt_s_procid_table_cursor	procs(_tt_s_mp->active_procs);
	int			nprocs = 0;
	
	while (procs.next()) {
		if (procs->joined_to_file(networkPath)) {
			nprocs++;
		}
	}
	return(nprocs);
}
Example #8
0
int main()
{
    char *str = (char *)malloc(sizeof(char) * MAX);
    int i = 0, len = 0;
    
    scanf("%c", str+i);
    while( str[i] != '\n' )
    {
        i++;
        len++;
        scanf("%c", str+i);
        
    }
    
    procs(str, len);
    
    return 0;
    
}
int recursive_bisection_contoller::best_partition_processor(int cut,
                                                            MPI_Comm comm) const {
  int rank;
  int nProcs;
  int bestCut;
  int bestProc;

  int i;

  MPI_Comm_size(comm, &nProcs);
  MPI_Comm_rank(comm, &rank);

  dynamic_array<int> allCuts(nProcs);
  dynamic_array<int> procs(nProcs);

  MPI_Allgather(&cut, 1, MPI_INT, allCuts.data(), 1, MPI_INT, comm);

  bestCut = allCuts[0];
  procs[0] = 0;

  for (i = 1; i < nProcs; ++i) {
    procs[i] = i;

    if (allCuts[i] < bestCut)
      bestCut = allCuts[i];
  }

  procs.random_permutation();

  if (rank == 0) {
    for (i = 0; i < nProcs; ++i) {
      if (allCuts[procs[i]] == bestCut) {
        bestProc = procs[i];
        break;
      }
    }
  }

  MPI_Bcast(&bestProc, 1, MPI_INT, 0, comm);

  return bestProc;
}
Example #10
0
 cuint32_t localCBlocksSize (cuint32_t proc) const {
     return localCBlockOffset (proc, procs ());
 }
Example #11
0
 cuint32_t localCBlockOffset (cuint32_t proc, cuint32_t block) const {
     ASSERT (proc < procs ());
     ASSERT (block <= procs ());
     return localBlockOffset_[(block * procs () + proc) ()];
 }
Example #12
0
 cuint32_t localCVec0 (cuint32_t i) const {
     ASSERT (i < procs ());
     return localVec0_[i ()];
 }
Example #13
0
 cuint32_t localCNvCount (cuint32_t i) const {
     ASSERT (i < procs ());
     return localNvCount_[i ()];
 }
Example #14
0
int
main(int argc, char** argv)
{
  //This test is an attempt to test linearization
  //of eb data holders directly

  int eekflag=0;
#ifdef CH_MPI
  MPI_Init(&argc, &argv);
#endif
  //begin forever present scoping trick
  {
    //registerDebugger();

    // Set up some geometry.
    Box domain;
    Real dx;

    do_geo( domain, dx );

    Vector<Box> boxes(1, domain);
    Vector<int> procs(1, 0);
    // Make a layout for the space.
    DisjointBoxLayout dbl(boxes, procs);

    // Fill in the layout with the geometrical info.
    EBISLayout ebisl;
    EBIndexSpace *ebisPtr = Chombo_EBIS::instance();
    ebisPtr->fillEBISLayout(ebisl, dbl, domain, 1 );

    // Define the leveldata for my one and only level.
    DataIterator dit = dbl.dataIterator();
    for ( dit.begin(); dit.ok(); ++dit )
      {
        eekflag = testIVFAB(ebisl[dit()], dbl.get(dit()));
        if (eekflag != 0)
          {
            pout() << "IVFAB linearization test failed " << endl;
            return eekflag;
          }
        eekflag = testIFFAB(ebisl[dit()], dbl.get(dit()));
        if (eekflag != 0)
          {
            pout() << "IFFAB  linearization test failed " << endl;
            return eekflag;
          }
        eekflag = testEBCellFAB(ebisl[dit()], dbl.get(dit()));
        if (eekflag != 0)
          {
            pout() << "EBCellFAB  linearization test failed " << endl;
            return eekflag;
          }
        eekflag = testEBFaceFAB(ebisl[dit()], dbl.get(dit()));
        if (eekflag != 0)
          {
            pout() << "EBFaceFAB  linearization test failed " << endl;
            return eekflag;
          }

        eekflag = testEBFluxFAB(ebisl[dit()], dbl.get(dit()));
        if (eekflag != 0)
          {
            pout() << "EBFluxFAB  linearization test failed " << endl;
            return eekflag;
          }
      }

    ebisPtr->clear();

  }//end scoping trick
  pout() << "linearization tests passed "<< endl;
#ifdef CH_MPI
  MPI_Finalize();
#endif
  return eekflag;
}
Example #15
0
void mrbig(void)
{
	char *p;
	time_t t, lastrun;
	int sleeptime, i;
	char hostname[256];
	DWORD hostsize;

	/*
	 * install exception logging/stacktrace handler.
	 * We need to resolve the symbol at run time because windows 2000
	 * does not have it.
	 */
	do {
		HMODULE dll;
		PVOID (*ptr) (ULONG First,PVECTORED_EXCEPTION_HANDLER Handler) = NULL;
		dll = LoadLibraryEx("kernel32.dll", NULL, 0);
		if (dll == NULL)
			break;
		ptr = (typeof(ptr))GetProcAddress(dll, "AddVectoredExceptionHandler");
		if (ptr == NULL)
			break;
		ptr(1, VectoredExceptionHandler);
		mrlog("VectoredExceptionHandler handler has been installed");
	} while(0);

	if (debug) {
		mrlog("mrbig()");
	}
	for (i = 0; _environ[i]; i++) {
		startup_log("%s", _environ[i]);
	}
	for (;;) {
		if (debug) mrlog("main loop");
		read_cfg("mrbig", cfgfile);
		readcfg();
		t = time(NULL);
		strlcpy(now, ctime(&t), sizeof now);
		p = strchr(now, '\n');
		if (p) *p = '\0';
		hostsize = sizeof hostname;
		if (GetComputerName(hostname, &hostsize)) {
			for (i = 0; hostname[i]; i++)
				hostname[i] = tolower(hostname[i]);
			snprcat(now, sizeof now, " [%s]", hostname);
		}

		cpu();
		check_chunks("after cpu test");

		disk();
		check_chunks("after disk test");

		memory();
		check_chunks("after memory test");

		msgs();
		check_chunks("after msgs test");

		procs();
		check_chunks("after procs test");

		svcs();
		check_chunks("after svcs test");

		wmi();
		check_chunks("after wmi test");

		if (pickupdir[0]) ext_tests();

		lastrun = t;
		t = time(NULL);
		if (t < lastrun) {
			mrlog("mainloop: timewarp detected, sleep for %d",
				mrloop);
			sleeptime = mrloop;
		} else {
			sleeptime = mrloop-(t-lastrun);
		}
		if (sleeptime < SLEEP_MIN) sleeptime = SLEEP_MIN;
		if (debug) mrlog("started at %d, finished at %d, sleep for %d",
			(int)lastrun, (int)t, sleeptime);
		clear_cfg();
		if (debug) {
			dump_chunks();
			check_chunks("after main loop");
		}
		Sleep(sleeptime*1000);
	}
}
Example #16
0
int main(int argc, char *argv[]) {
    pm_kernel_t *ker;
    pm_process_t *proc;
    pid_t *pids;
    size_t num_procs;
    uint64_t total_pss;
    uint64_t total_uss;
    uint64_t total_swap;
    uint64_t total_pswap;
    uint64_t total_uswap;
    uint64_t total_zswap;
    int error;
    bool has_swap = false, has_zram = false;
    uint64_t required_flags = 0;
    uint64_t flags_mask = 0;

    int arg;
    size_t i;

    enum {
        WS_OFF,
        WS_ONLY,
        WS_RESET,
    } ws;

    uint64_t mem[MEMINFO_COUNT] = { };
    pm_proportional_swap_t *p_swap;
    float zram_cr = 0.0;

    signal(SIGPIPE, SIG_IGN);
    compfn = &sort_by_pss;
    order = -1;
    ws = WS_OFF;
    bool oomadj = false;

    for (arg = 1; arg < argc; arg++) {
        if (!strcmp(argv[arg], "-v")) { compfn = &sort_by_vss; continue; }
        if (!strcmp(argv[arg], "-r")) { compfn = &sort_by_rss; continue; }
        if (!strcmp(argv[arg], "-p")) { compfn = &sort_by_pss; continue; }
        if (!strcmp(argv[arg], "-u")) { compfn = &sort_by_uss; continue; }
        if (!strcmp(argv[arg], "-s")) { compfn = &sort_by_swap; continue; }
        if (!strcmp(argv[arg], "-o")) { compfn = &sort_by_oomadj; oomadj = true; continue; }
        if (!strcmp(argv[arg], "-c")) { required_flags = 0; flags_mask = (1 << KPF_SWAPBACKED); continue; }
        if (!strcmp(argv[arg], "-C")) { required_flags = flags_mask = (1 << KPF_SWAPBACKED); continue; }
        if (!strcmp(argv[arg], "-k")) { required_flags = flags_mask = (1 << KPF_KSM); continue; }
        if (!strcmp(argv[arg], "-w")) { ws = WS_ONLY; continue; }
        if (!strcmp(argv[arg], "-W")) { ws = WS_RESET; continue; }
        if (!strcmp(argv[arg], "-R")) { order *= -1; continue; }
        if (!strcmp(argv[arg], "-h")) { usage(argv[0]); exit(0); }
        fprintf(stderr, "Invalid argument \"%s\".\n", argv[arg]);
        usage(argv[0]);
        exit(EXIT_FAILURE);
    }

    get_mem_info(mem);
    p_swap = pm_memusage_pswap_create(mem[MEMINFO_SWAP_TOTAL] * 1024);

    error = pm_kernel_create(&ker);
    if (error) {
        fprintf(stderr, "Error creating kernel interface -- "
                        "does this kernel have pagemap?\n");
        exit(EXIT_FAILURE);
    }

    error = pm_kernel_pids(ker, &pids, &num_procs);
    if (error) {
        fprintf(stderr, "Error listing processes.\n");
        exit(EXIT_FAILURE);
    }

    std::vector<proc_info> procs(num_procs);
    for (i = 0; i < num_procs; i++) {
        procs[i].pid = pids[i];
        procs[i].oomadj = getoomadj(pids[i]);
        pm_memusage_zero(&procs[i].usage);
        pm_memusage_pswap_init_handle(&procs[i].usage, p_swap);
        error = pm_process_create(ker, pids[i], &proc);
        if (error) {
            fprintf(stderr, "warning: could not create process interface for %d\n", pids[i]);
            continue;
        }

        switch (ws) {
        case WS_OFF:
            error = pm_process_usage_flags(proc, &procs[i].usage, flags_mask,
                                           required_flags);
            break;
        case WS_ONLY:
            error = pm_process_workingset(proc, &procs[i].usage, 0);
            break;
        case WS_RESET:
            error = pm_process_workingset(proc, NULL, 1);
            break;
        }

        if (error) {
            fprintf(stderr, "warning: could not read usage for %d\n", pids[i]);
        }

        if (ws != WS_RESET && procs[i].usage.swap) {
            has_swap = true;
        }

        pm_process_destroy(proc);
    }

    free(pids);

    if (ws == WS_RESET) exit(0);

    procs.erase(std::remove_if(procs.begin(),
                               procs.end(),
                               [](auto proc){
                                   return proc.usage.vss == 0;
                               }),
                procs.end());

    qsort(procs.data(), procs.size(), sizeof(procs[0]), compfn);

    if (has_swap) {
        uint64_t zram_mem_used = get_zram_mem_used();
        if (zram_mem_used) {
            mem[MEMINFO_ZRAM_TOTAL] = zram_mem_used/1024;
            zram_cr = (float) mem[MEMINFO_ZRAM_TOTAL] /
                    (mem[MEMINFO_SWAP_TOTAL] - mem[MEMINFO_SWAP_FREE]);
            has_zram = true;
        }
    }

    printf("%5s  ", "PID");
    if (oomadj) {
        printf("%5s  ", "oom");
    }
    if (ws) {
        printf("%7s  %7s  %7s  ", "WRss", "WPss", "WUss");
        if (has_swap) {
            printf("%7s  %7s  %7s  ", "WSwap", "WPSwap", "WUSwap");
            if (has_zram) {
                printf("%7s  ", "WZSwap");
            }
        }
    } else {
        printf("%8s  %7s  %7s  %7s  ", "Vss", "Rss", "Pss", "Uss");
        if (has_swap) {
            printf("%7s  %7s  %7s  ", "Swap", "PSwap", "USwap");
            if (has_zram) {
                printf("%7s  ", "ZSwap");
            }
        }
    }

    printf("%s\n", "cmdline");

    total_pss = 0;
    total_uss = 0;
    total_swap = 0;
    total_pswap = 0;
    total_uswap = 0;
    total_zswap = 0;

    std::vector<uint64_t> lmk_minfree;
    std::vector<int> lmk_adj;
    if (oomadj) {
        getminfree(&lmk_minfree, &lmk_adj);
    }
    auto lmk_minfree_it = lmk_minfree.cbegin();
    auto lmk_adj_it = lmk_adj.cbegin();

    auto print_oomadj_totals = [&](int adj){
        for (; lmk_adj_it != lmk_adj.cend() && lmk_minfree_it != lmk_minfree.cend() &&
                 adj > *lmk_adj_it; lmk_adj_it++, lmk_minfree_it++) {
            // Print the cumulative total line
            printf("%5s  ", ""); // pid

            printf("%5s  ", ""); // oomadj

            if (ws) {
                printf("%7s  %6" PRIu64 "K  %6" PRIu64 "K  ",
                       "", total_pss / 1024, total_uss / 1024);
            } else {
                printf("%8s  %7s  %6" PRIu64 "K  %6" PRIu64 "K  ",
                       "", "", total_pss / 1024, total_uss / 1024);
            }

            if (has_swap) {
                printf("%6" PRIu64 "K  ", total_swap / 1024);
                printf("%6" PRIu64 "K  ", total_pswap / 1024);
                printf("%6" PRIu64 "K  ", total_uswap / 1024);
                if (has_zram) {
                    printf("%6" PRIu64 "K  ", total_zswap / 1024);
                }
            }

            printf("TOTAL for oomadj < %d (%6" PRIu64 "K)\n", *lmk_adj_it, *lmk_minfree_it / 1024);
        }
    };

    for (auto& proc: procs) {
        if (oomadj) {
            print_oomadj_totals(proc.oomadj);
        }

        std::string cmdline = getprocname(proc.pid);

        total_pss += proc.usage.pss;
        total_uss += proc.usage.uss;
        total_swap += proc.usage.swap;

        printf("%5d  ", proc.pid);

        if (oomadj) {
            printf("%5d  ", proc.oomadj);
        }

        if (ws) {
            printf("%6zuK  %6zuK  %6zuK  ",
                proc.usage.rss / 1024,
                proc.usage.pss / 1024,
                proc.usage.uss / 1024
            );
        } else {
            printf("%7zuK  %6zuK  %6zuK  %6zuK  ",
                proc.usage.vss / 1024,
                proc.usage.rss / 1024,
                proc.usage.pss / 1024,
                proc.usage.uss / 1024
            );
        }

        if (has_swap) {
            pm_swapusage_t su;

            pm_memusage_pswap_get_usage(&proc.usage, &su);
            printf("%6zuK  ", proc.usage.swap / 1024);
            printf("%6zuK  ", su.proportional / 1024);
            printf("%6zuK  ", su.unique / 1024);
            total_pswap += su.proportional;
            total_uswap += su.unique;
            pm_memusage_pswap_free(&proc.usage);
            if (has_zram) {
                size_t zpswap = su.proportional * zram_cr;
                printf("%6zuK  ", zpswap / 1024);
                total_zswap += zpswap;
            }
        }

        printf("%s\n", cmdline.c_str());
    }

    pm_memusage_pswap_destroy(p_swap);

    if (oomadj) {
        print_oomadj_totals(INT_MAX);
    }

    // Print the separator line
    printf("%5s  ", "");

    if (oomadj) {
        printf("%5s  ", "");
    }

    if (ws) {
        printf("%7s  %7s  %7s  ", "", "------", "------");
    } else {
        printf("%8s  %7s  %7s  %7s  ", "", "", "------", "------");
    }

    if (has_swap) {
        printf("%7s  %7s  %7s  ", "------", "------", "------");
        if (has_zram) {
            printf("%7s  ", "------");
        }
    }

    printf("%s\n", "------");

    // Print the total line
    printf("%5s  ", "");

    if (oomadj) {
        printf("%5s  ", "");
    }

    if (ws) {
        printf("%7s  %6" PRIu64 "K  %6" PRIu64 "K  ",
            "", total_pss / 1024, total_uss / 1024);
    } else {
        printf("%8s  %7s  %6" PRIu64 "K  %6" PRIu64 "K  ",
            "", "", total_pss / 1024, total_uss / 1024);
    }

    if (has_swap) {
        printf("%6" PRIu64 "K  ", total_swap / 1024);
        printf("%6" PRIu64 "K  ", total_pswap / 1024);
        printf("%6" PRIu64 "K  ", total_uswap / 1024);
        if (has_zram) {
            printf("%6" PRIu64 "K  ", total_zswap / 1024);
        }
    }

    printf("TOTAL\n");

    printf("\n");

    if (has_swap) {
        printf("ZRAM: %" PRIu64 "K physical used for %" PRIu64 "K in swap "
                "(%" PRIu64 "K total swap)\n",
                mem[MEMINFO_ZRAM_TOTAL], (mem[MEMINFO_SWAP_TOTAL] - mem[MEMINFO_SWAP_FREE]),
                mem[MEMINFO_SWAP_TOTAL]);
    }
    printf(" RAM: %" PRIu64 "K total, %" PRIu64 "K free, %" PRIu64 "K buffers, "
            "%" PRIu64 "K cached, %" PRIu64 "K shmem, %" PRIu64 "K slab\n",
            mem[MEMINFO_TOTAL], mem[MEMINFO_FREE], mem[MEMINFO_BUFFERS],
            mem[MEMINFO_CACHED], mem[MEMINFO_SHMEM], mem[MEMINFO_SLAB]);

    return 0;
}
Example #17
0
 cuint32_t localCVecStride (cuint32_t i) const {
     ASSERT (i < procs ());
     return localVecStride_[i ()];
 }
Example #18
0
int startsim(void){

message m;
int i,j=0,piReady = -1;
u64_t cpuTimeDiff;
FILE *fp;

fp = fopen("/home/out","w");

for(i=0;i<HISTORY;i++){
	pInfoPtrs[i] = (struct pi *) &pInfo[i][0]; 
}
for(i=0;i<HISTORY;i++){
	pQhPtrs[i] = (struct qh*) &pQh[i][0];
}

/* Copy the pointer arrays so that you can go backward and forward through the history */
struct pi *pInfoPtrsCopy[HISTORY];
struct qh *pQhPtrsCopy[HISTORY];
for(i=0;i<HISTORY;i++){
	pInfoPtrsCopy[i] = pInfoPtrs[i];
	pQhPtrsCopy[i] = pQhPtrs[i];
}
m.m1_p1 = (char *) &pInfoPtrs;
m.m1_p2 = (char *) &piReady;
m.m1_i2 = SELF;
m.m1_i3 = HISTORY;
m.m2_p1 = (char *) &pQhPtrs;
m.m3_p1 = (char *) &cpuFreq;

int error = _syscall(PM_PROC_NR,STARTRECORD,&m);
procs();
for(j;j<HISTORY;j++){
		while(piReady < j){
		}
		if(j==0){
			fprintf(fp,"CPU frequency is: %lu Mhz\n",div64u(cpuFreq, 1000000));
		}
		printf("Simulation is %d%% complete.\n",(j*2)+2);
		fprintf(fp,"Proc Table %d\n\n",j);
		fprintf(fp,"Queue heads: ");
		for(i=0;i<NR_SCHED_QUEUES;i++){
				if(pQhPtrsCopy[j]->p_endpoint!=-1){
					fprintf(fp,"Queue: %d %d ",i,pQhPtrsCopy[j]->p_endpoint);
				}
				pQhPtrsCopy[j]++;
		}
		fprintf(fp,"\n\n");
		pQhPtrsCopy[j] = pQhPtrs[j];
	
	/*Write out the runable queues in order */
	for(i=0; i<NR_SCHED_QUEUES; i++){
			fprintf(fp,"Priority Queue %d: ",i);
			if(pQhPtrsCopy[j]->p_endpoint != -1){
				printQ(pInfoPtrsCopy[j],pQhPtrsCopy[j]->p_endpoint,fp);
			}
			else{
				fprintf(fp,"\n");
			}
			pQhPtrsCopy[j]++;
	}
	pQhPtrsCopy[j] = pQhPtrs[j]; /* Reset the Qh Pointers */

	for (i=0;i<ALL_PROCS;i++){ 
		if (!(pInfoPtrsCopy[j]->p_rts_flags == RTS_SLOT_FREE)){ 
			if(j>0){
				cpuTimeDiff = sub64(pInfoPtrsCopy[j]->p_cycles,pInfoPtrsCopy[j-1]->p_cycles);
				}
		fprintf(fp,"Process: %s, Endpoint: %d, Enter queue: %lu%lu, Time in Queue: %lu%lu, Dequeues: %lu, IPC Sync: %lu, IPC Async: %lu,Preempted: %lu,RTS: %x\n\t\t, Priority: %d, Next: %s Endpoint: %d, User time: %d, Sys Time: %d, CPU Cycles Elaps: %lu%lu\n",
				pInfoPtrsCopy[j]->p_name,pInfoPtrsCopy[j]->p_endpoint,ex64hi(pInfoPtrsCopy[j]->p_times.enter_queue),ex64lo(pInfoPtrsCopy[j]->p_times.enter_queue),
				ex64hi(pInfoPtrsCopy[j]->p_times.time_in_queue),ex64lo(pInfoPtrsCopy[j]->p_times.time_in_queue),
				pInfoPtrsCopy[j]->p_times.dequeues,pInfoPtrsCopy[j]->p_times.ipc_sync,pInfoPtrsCopy[j]->p_times.ipc_async,
				pInfoPtrsCopy[j]->p_times.preempted,pInfoPtrsCopy[j]->p_rts_flags,pInfoPtrsCopy[j]->p_priority, pInfoPtrsCopy[j]->p_nextready,
				pInfoPtrsCopy[j]->p_nextready_endpoint,pInfoPtrsCopy[j]->p_user_time,pInfoPtrsCopy[j]->p_sys_time,ex64hi(cpuTimeDiff),
				ex64lo(cpuTimeDiff));
		}
		pInfoPtrsCopy[j]++;
		if(j>0){
			pInfoPtrsCopy[j-1]++;
		}
	}
	pInfoPtrsCopy[j] = pInfoPtrs[j];	
}

m.m1_i3 = -1;
_syscall(PM_PROC_NR,STARTRECORD,&m);
return(0);
}
Example #19
0
 cuint32_t localCGridX (cuint32_t i) const {
     ASSERT (i < procs ());
     return localGridX_[i ()];
 }
Example #20
0
LBMigrateMsg* WSLB::Strategy(WSLB::LDStats* stats, int count)
{
#if CMK_LBDB_ON
  //  CkPrintf("[%d] Strategy starting\n",CkMyPe());
  // Compute the average load to see if we are overloaded relative
  // to our neighbors
  const double load_factor = 1.05;
  double objload;

  double myload = myStats.total_walltime - myStats.idletime;
  double avgload = myload;
  int unvacated_neighbors = 0;
  int i;
  for(i=0; i < count; i++) {
    // If the neighbor is vacating, skip him
    if (stats[i].vacate_me)
      continue;

    // Scale times we need appropriately for relative proc speeds
    double hisload = stats[i].total_walltime - stats[i].idletime;
    const double hisusage = stats[i].usage;

    const double scale =  (myStats.proc_speed * usage) 
      / (stats[i].proc_speed * hisusage);

    hisload *= scale;
    stats[i].total_walltime *= scale;
    stats[i].idletime *= scale;

    //    CkPrintf("PE %d %d hisload = %f hisusage = %f\n",
    //	     CkMyPe(),i,hisload,hisusage);
    avgload += hisload;
    unvacated_neighbors++;
  }
  if (vacate && unvacated_neighbors == 0)
    CkPrintf("[%d] ALL NEIGHBORS WANT TO VACATE!!!\n",CkMyPe());

  avgload /= (unvacated_neighbors+1);

  CkVec<MigrateInfo*> migrateInfo;

  // If we want to vacate, we always dump our load, otherwise
  // only if we are overloaded

  if (vacate || myload > avgload) {
    //    CkPrintf("[%d] OVERLOAD My load is %f, average load is %f\n",
    //	     CkMyPe(),myload,avgload);

    // First, build heaps of other processors and my objects
    // Then assign objects to other processors until either
    //   - The smallest remaining object would put me below average, or
    //   - I only have 1 object left, or
    //   - The smallest remaining object would put someone else 
    //     above average

    // Build heaps
    minHeap procs(count);
    for(i=0; i < count; i++) {
      // If all my neighbors vacate, I won't have anyone to give work 
      // to
      if (!stats[i].vacate_me) {
	InfoRecord* item = new InfoRecord;
	item->load = stats[i].total_walltime - stats[i].idletime;
	item->Id =  stats[i].from_pe;
	procs.insert(item);
      }
    }
      
    maxHeap objs(myStats.obj_data_sz);
    for(i=0; i < myStats.obj_data_sz; i++) {
      InfoRecord* item = new InfoRecord;
      item->load = myStats.objData[i].wallTime;
      item->Id = i;
      objs.insert(item);
    }

    int objs_here = myStats.obj_data_sz;
    do {
      //      if (objs_here <= 1) break;  // For now, always leave 1 object

      InfoRecord* p;
      InfoRecord* obj;

      // Get the lightest-loaded processor
      p = procs.deleteMin();
      if (p == 0) {
	//	CkPrintf("[%d] No destination PE found!\n",CkMyPe());
	break;
      }

      // Get the biggest object
      bool objfound = false;
      do {
	obj = objs.deleteMax();
	if (obj == 0) break;

	objload = load_factor * obj->load;

	double new_p_load = p->load + objload;
	double my_new_load = myload - objload;

	// If we're vacating, the biggest object is always good.
	// Otherwise, only take it if it doesn't produce overload
	if (vacate || new_p_load < my_new_load) {
	  objfound = true;
	} else {
	  // This object is too big, so throw it away
//	  CkPrintf("[%d] Can't move object w/ load %f to proc %d load %f %f\n",
//		   CkMyPe(),obj->load,p->Id,p->load,avgload);
	  delete obj;
	}
      } while (!objfound);

      if (!objfound) {
	//	CkPrintf("[%d] No suitable object found!\n",CkMyPe());
	break;
      }

      const int me = CkMyPe();
      // Apparently we can give this object to this processor
      if (_lb_args.debug())
      CkPrintf("[%d] Obj %d of %d migrating from %d to %d\n",
	       CkMyPe(),obj->Id,myStats.obj_data_sz,me,p->Id);

      MigrateInfo* migrateMe = new MigrateInfo;
      migrateMe->obj = myStats.objData[obj->Id].handle;
      migrateMe->from_pe = me;
      migrateMe->to_pe = p->Id;
      migrateInfo.insertAtEnd(migrateMe);

      objs_here--;
      
      // We may want to assign more to this processor, so lets
      // update it and put it back in the heap
      p->load += objload;
      myload -= objload;
      procs.insert(p);
      
      // This object is assigned, so we delete it from the heap
      delete obj;

    } while(vacate || myload > avgload);

    // Now empty out the heaps
    InfoRecord* p;
    while (NULL!=(p=procs.deleteMin()))
      delete p;
    InfoRecord* obj;
    while (NULL!=(obj=objs.deleteMax()))
      delete obj;
  }  

  // Now build the message to actually perform the migrations
  int migrate_count=migrateInfo.length();
  //  if (migrate_count) {
  //    CkPrintf("PE %d: Sent away %d of %d objects\n",
  //	     CkMyPe(),migrate_count,myStats.obj_data_sz);
  //  }
  LBMigrateMsg* msg = new(migrate_count,CkNumPes(),CkNumPes(),0) LBMigrateMsg;
  msg->n_moves = migrate_count;
  for(i=0; i < migrate_count; i++) {
    MigrateInfo* item = (MigrateInfo*) migrateInfo[i];
    msg->moves[i] = *item;
    delete item;
    migrateInfo[i] = 0;
  }

  return msg;
#else
  return NULL;
#endif
}
Example #21
0
 cuint32_t localCBoxZ (cuint32_t i) const {
     ASSERT (i < procs ());
     return localBoxZ_[i ()];
 }