コード例 #1
0
def ConfigureRunningEnv(num_process, size_tile_cache):
    """Configures the running environment.

  Optimal performance is obtained by increasing the number of process
  and a geo cache big enough to avoid swapping. Each tile covers about
  100kmx100km. Swapping statistics can be obtaines using the routine:
    `CheckTerrainTileCacheOk()`.

  Args:
    num_process: Number of process. Special values: -1: #cpu/2 ; -2: #cpu-1
    size_tile_cache: Geo cache size in number of tiles. The memory usage is
      about: `num_process * size_tile_cache * 60 MB`
  """
    # Configure the global pool of processes
    mpool.Configure(num_process)

    # Configure the geo drivers to avoid swap
    # - for main process
    drive.ConfigureTerrainDriver(cache_size=size_tile_cache)
    drive.ConfigureNlcdDriver(cache_size=size_tile_cache)
    # - for worker processes
    mpool.RunOnEachWorkerProcess(drive.ConfigureTerrainDriver,
                                 terrain_dir=None,
                                 cache_size=size_tile_cache)
    mpool.RunOnEachWorkerProcess(drive.ConfigureNlcdDriver,
                                 nlcd_dir=None,
                                 cache_size=size_tile_cache)
    return mpool.GetNumWorkerProcesses()
コード例 #2
0
def CheckTerrainTileCacheOk():
    """Check tiles cache well behaved."""
    print('Check of tile cache swap:')
    num_workers = mpool.GetNumWorkerProcesses()
    if num_workers:
        tile_stats = mpool.RunOnEachWorkerProcess(_getTileStats)
    else:
        tile_stats = [_getTileStats()]
    num_active_tiles, cnt_per_tile = tile_stats[np.argmax(
        [tile_stat[0] for tile_stat in tile_stats])]
    if not num_active_tiles:
        print('-- Cache ERROR: No active tiles read')
    elif max(cnt_per_tile) > 1:
        print(
            '-- Cache WARNING: cache tile too small - tiles are swapping from cache.'
        )
        if num_workers:
            pool = mpool.Pool()
            pool.apply_async(_printTileStats)
        else:
            _printTileStats()
    else:
        print('-- Cache tile: OK (no swapping)')
コード例 #3
0
    if num_tiles_master_ned < 16:
        logging.warning('Required geo cache size %d (for master) is low'
                        '- too few memory or too many workers' %
                        num_tiles_master_ned)
    logging.info(' ... NED: cache size: %d per master, %d for workers' %
                 (num_tiles_master_ned, num_tiles_worker_ned))
    logging.info(' ... NLCD: cache size: %d per master, %d for workers' %
                 (num_tiles_master_ned, num_tiles_worker_ned))

    # - for main process
    drive.ConfigureTerrainDriver(cache_size=num_tiles_master_ned)
    drive.ConfigureNlcdDriver(cache_size=num_tiles_master_nlcd)

    # - for worker processes
    mpool.RunOnEachWorkerProcess(drive.ConfigureTerrainDriver,
                                 terrain_dir=None,
                                 cache_size=num_tiles_worker_ned)
    mpool.RunOnEachWorkerProcess(drive.ConfigureNlcdDriver,
                                 nlcd_dir=None,
                                 cache_size=num_tiles_worker_nlcd)

    #run
    client = cbsd_sas.client()

    #Authenticate
    client.server._sas_admin.Reset()

    #Registration
    ret = client.registration()

    if (ret == True):
コード例 #4
0
    print 'Move List mask:'
    print dpa.GetMoveListMask((fmin, fmax))
    len_move_list = len(dpa.move_lists[0])
    print ''
    print 'Num Cores (Parallelization): %d' % num_workers
    print 'Num Protection Points: %d' % len(dpa.protected_points)
    print 'Num CBSD: %d (A: %d %d - B %d)' % (len(grants), n_a_indoor,
                                              n_a_outdoor, n_b)
    print 'Distribution: %s' % ('uniform' if not do_inside_urban_area else
                                'urban areas only')
    print 'Move list size: %d' % len_move_list
    print 'Computation time: %.1fs' % (end_time - start_time)

    # Check tiles cache well behaved
    print ''
    tile_stats = mpool.RunOnEachWorkerProcess(getTileStats)
    num_active_tiles, cnt_per_tile = tile_stats[0]
    if not num_active_tiles:
        print '-- Cache ERROR: No active tiles read'
    elif max(cnt_per_tile) > 1:
        print '-- Cache WARNING: cache tile too small - tiles are swapping from cache.'
        pool = mpool.Pool()
        pool.apply_async(printTileStats)
    else:
        print '-- Cache tile: OK (no swapping)'

    # Plot the move list
    if len_move_list:
        result = dpa.GetMoveListMask((fmin, fmax))
        ax.scatter(
            [cbsd.longitude for k, cbsd in enumerate(all_cbsds) if result[k]],