示例#1
0
文件: tests.c 项目: 1ynx/gimp
static Gimp *
gimp_init_for_gui_testing_internal (gboolean     show_gui,
                                    const gchar *gimprc)
{
  GimpSessionInfoClass *klass;
  Gimp                 *gimp;

  /* from main() */
  g_thread_init(NULL);
  g_type_init();
  gimp_log_init ();

  /* Introduce an error margin for positions written to sessionrc */
  klass = g_type_class_ref (GIMP_TYPE_SESSION_INFO);
  gimp_session_info_class_set_position_accuracy (klass, 5);

  /* from app_run() */
  gimp = gimp_new ("Unit Tested GIMP", NULL, FALSE, TRUE, TRUE, !show_gui,
                   FALSE, TRUE, TRUE, FALSE);
  gimp_set_show_gui (gimp, show_gui);
  units_init (gimp);
  gimp_load_config (gimp, gimprc, NULL);
  base_init (GIMP_BASE_CONFIG (gimp->config),
             FALSE /*be_verbose*/,
             FALSE /*use_cpu_accel*/);
  gui_init (gimp, TRUE);
  gimp_initialize (gimp, gimp_status_func_dummy);
  gimp_restore (gimp, gimp_status_func_dummy);

  g_type_class_unref (klass);

  return gimp;
}
示例#2
0
文件: collector.c 项目: BeQ/webserver
ret_t
cherokee_collector_init_base (cherokee_collector_t  *collector,
			      cherokee_plugin_info_t *info,
			      cherokee_config_node_t *config)
{
	/* Init the base class
	 */
	base_init (COLLECTOR_BASE(collector), info, config);

	/* Pure virtual methods
	 */
	collector->new_vsrv = NULL;

	/* Properties
	 */
	collector->accepts          = 0;
	collector->accepts_partial  = 0;

	collector->requests         = 0;
	collector->requests_partial = 0;

	collector->timeouts         = 0;
	collector->timeouts_partial = 0;

	return ret_ok;
}
示例#3
0
void TestQGeoPositionInfoSource::init()
{
#ifdef TST_GEOCLUEMOCK_ENABLED
    initGeoclueMock();
#endif
    base_init();
}
示例#4
0
void TIMERONE::begin(uint32_t frq)
{
	NVIC_InitTypeDef NVIC_InitStructure;
	uint32_t _period  =0;
	uint32_t _prescaler = 1;
	
	if(frq>=1000000)frq = 1000000;
	
	for(;_prescaler <= 0xffff;_prescaler++)
	{
		_period = 72000000/_prescaler/frq;
		if((0xffff>=_period))break;
	}

	base_init(_period,_prescaler);
	
	NVIC_InitStructure.NVIC_IRQChannel = TIM1_UP_IRQn;//
	NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;// 
	NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;// 
	NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
	NVIC_Init(&NVIC_InitStructure);

	
	interrupt(DISABLE);
	stop();
}
示例#5
0
int main(int argc, char **argv) {
  uint32_t cfi;
  float cfi_corr; 
  int n;

  if (argc < 3) {
    usage(argv[0]);
    exit(-1);
  }

  parse_args(argc,argv);

  if (base_init()) {
    fprintf(stderr, "Error initializing receiver\n");
    exit(-1);
  }

  n = filesource_read(&fsrc, input_buffer, flen);

  lte_fft_run_sf(&fft, input_buffer, fft_buffer);

  if (fmatlab) {
    fprintf(fmatlab, "infft=");
    vec_fprint_c(fmatlab, input_buffer, flen);
    fprintf(fmatlab, ";\n");

    fprintf(fmatlab, "outfft=");
    vec_sc_prod_cfc(fft_buffer, 1000.0, fft_buffer, CP_NSYMB(cell.cp) * cell.nof_prb * RE_X_RB);
    vec_fprint_c(fmatlab, fft_buffer, CP_NSYMB(cell.cp) * cell.nof_prb * RE_X_RB);
    fprintf(fmatlab, ";\n");
    vec_sc_prod_cfc(fft_buffer, 0.001, fft_buffer,   CP_NSYMB(cell.cp) * cell.nof_prb * RE_X_RB);
  }

  /* Get channel estimates for each port */
  chest_dl_estimate(&chest, fft_buffer, ce, 0);

  INFO("Decoding PCFICH\n", 0);

  
  n = pcfich_decode(&pcfich, fft_buffer, ce, chest_dl_get_noise_estimate(&chest),  0, &cfi, &cfi_corr);
  printf("cfi: %d, distance: %f\n", cfi, cfi_corr);

  base_free();

  if (n < 0) {
    fprintf(stderr, "Error decoding PCFICH\n");
    exit(-1);
  } else if (n == 0) {
    printf("Could not decode PCFICH\n");
    exit(-1);
  } else {
    if (cfi_corr > 2.8 && cfi == 1) {
      exit(0);
    } else {
      exit(-1);
    }
  }
}
示例#6
0
_WPRTLINK WCSkipNonTempBase::WCSkipNonTempBase( unsigned prob, unsigned max_ptrs,
        void * (*user_alloc)( size_t ),
        void (*user_dealloc)( void *, size_t ),
        WCbool duplicates )
    : alloc_fn( user_alloc ), dealloc_fn( user_dealloc ),
      level( 0 ), allowDuplicates( duplicates ),
      num_entries( 0 ) {
    base_init( prob, max_ptrs );
}
示例#7
0
void middle_init(middle_t *middle, void *base_mem, uint8 quant_bits, uint32 entries, uint32 max_vocab, uint32 max_next, void *next_source)
{
    middle->quant_bits = quant_bits;
    bitarr_mask_from_max(&middle->next_mask, max_next);
    middle->next_source = next_source;
    if (entries + 1 >= (1U << 25) || (max_next >= (1U << 25)))
        E_ERROR("Sorry, this does not support more than %d n-grams of a particular order.  Edit util/bit_packing.hh and fix the bit packing functions\n", (1U << 25));
    base_init(&middle->base, base_mem, max_vocab, quant_bits + middle->next_mask.bits);
}
示例#8
0
int main(int argc, char **argv) {
  pbch_mib_t mib;
  int n;

  if (argc < 3) {
    usage(argv[0]);
    exit(-1);
  }

  parse_args(argc,argv);

  if (base_init()) {
    fprintf(stderr, "Error initializing receiver\n");
    exit(-1);
  }

  n = filesource_read(&fsrc, input_buffer, FLEN);

  lte_fft_run_sf(&fft, input_buffer, fft_buffer);

  if (fmatlab) {
    fprintf(fmatlab, "outfft=");
    vec_sc_prod_cfc(fft_buffer, 1000.0, fft_buffer, CP_NSYMB(cell.cp) * cell.nof_prb * RE_X_RB);
    vec_fprint_c(fmatlab, fft_buffer, CP_NSYMB(cell.cp) * cell.nof_prb * RE_X_RB);
    fprintf(fmatlab, ";\n");
    vec_sc_prod_cfc(fft_buffer, 0.001, fft_buffer,   CP_NSYMB(cell.cp) * cell.nof_prb * RE_X_RB);
  }

  /* Get channel estimates for each port */
  chest_ce_sf(&chest, fft_buffer, ce, 0);

  INFO("Decoding PBCH\n", 0);

  n = pbch_decode(&pbch, fft_buffer, ce, &mib);

  base_free();

  if (n < 0) {
    fprintf(stderr, "Error decoding PBCH\n");
    exit(-1);
  } else if (n == 0) {
    printf("Could not decode PBCH\n");
    exit(-1);
  } else {
    if (mib.nof_ports == 2 && mib.nof_prb == 50 && mib.phich_length == PHICH_NORM
        && mib.phich_resources == R_1 && mib.sfn == 28) {
      pbch_mib_fprint(stdout, &mib, cell.id);
      printf("This is the signal.1.92M.dat file\n");
      exit(0);
    } else {
      pbch_mib_fprint(stdout, &mib, cell.id);
      printf("This is an unknown file\n");
      exit(-1);
    }
  }
}
示例#9
0
文件: post.c 项目: xinzou/cweb
void post_init(void) {
	if (post_klass->init) {
		base_init();
		memcpy(post_klass, base_klass, sizeof(klass_info));
		post_klass->super = base_klass;
		post_klass->class_name = "post_klass";
		user_klass->field_numbers = 3;
		post_klass->size = sizeof(post);
		post_klass->ctor = post_ctor;
		post_klass->dtor = post_dtor;
	}
}
示例#10
0
文件: main.c 项目: Protovision/io-lua
void	init(int argc, char *argv[])
{
	common_init(argc, argv);

	if (unz_exists("config.lua")) {
		script_load("config.lua");
	}

	audio_init();
	video_init();
	base_init();
	script_load("game.lua");
	script_call("init", NULL);
}
示例#11
0
文件: collector.c 项目: BeQ/webserver
ret_t
cherokee_collector_vsrv_init_base (cherokee_collector_vsrv_t  *collector_vsrv,
				   cherokee_config_node_t     *config)
{
	/* Init the base class
	 */
	base_init (COLLECTOR_BASE(collector_vsrv), NULL, config);

	/* Properties
	 */
	collector_vsrv->srv_next_update = 0;
	collector_vsrv->srv_rx_partial  = 0;
	collector_vsrv->srv_tx_partial  = 0;

	return ret_ok;
}
示例#12
0
bool ia_check_expect_file_line(const char *file, const char *function, int line, Array a, int *e, int ne) {
	base_init();
	base_count_check();
	if (a->n != ne) {
		printf("%s, line %d: Actual length %d "
			"differs from expected length %d\n", file, line, a->n, ne);
		return false;
	}
	if (a->s != sizeof(int)) {
		printf("%s, line %d: Actual element size %d "
			"differs from expected element size %lu\n", file, line, a->s, (unsigned long)sizeof(int));
		return false;
	}
	if (a->n < 0) {
		printf("%s, line %d: Invalid actual length %d\n", file, line, a->n);
		return false;		
	}
	if (ne < 0) {
		printf("%s, line %d: Invalid expected length %d\n", file, line, ne);
		return false;		
	}
	if (a->n > 0 && a->a == NULL) {
		printf("%s, line %d: Actual value array is NULL\n", file, line);
		return false;		
	}
	if (ne > 0 && e == NULL) {
		printf("%s, line %d: Expected value array is NULL\n", file, line);
		return false;		
	}
	int *ia = a->a;
	for (int i = 0; i < a->n; i++) {
		if (ia[i] != e[i]) {
			printf("%s, line %d: Actual value ", file, line);
			printia(ia, a->n);
			prints(" differs from expected value ");
			printia(e, ne);
			printf(" at index %d.\n", i);
			return false;
		}
	}
	printf("%s, line %d: check passed\n", file, line);
	base_count_success();
	return true;
}
示例#13
0
bool da_check_within_file_line(const char *file, const char *function, int line, Array a, double *e, int ne, double epsilon) {
    base_init();
    base_count_check();
    if (a->n != ne) {
        printf("%s, line %d: Actual length %d "
               "differs from expected length %d\n", file, line, a->n, ne);
        return false;
    }
    if (a->s != sizeof(double)) {
        printf("%s, line %d: Actual element size %d "
               "differs from expected element size %lu\n", file, line, a->s, (unsigned long)sizeof(double));
        return false;
    }
    if (a->n < 0) {
        printf("%s, line %d: Invalid lengths %d\n", file, line, a->n);
        return false;
    }
    if (ne < 0) {
        printf("%s, line %d: Invalid lengths %d\n", file, line, ne);
        return false;
    }
    if (a->n > 0 && a->a == NULL) {
        printf("%s, line %d: Actual value array is NULL\n", file, line);
        return false;
    }
    if (ne > 0 && e == NULL) {
        printf("%s, line %d: Expected value array is NULL\n", file, line);
        return false;
    }
    double *da = a->a;
    for (int i = 0; i < a->n; i++) {
        if (fabs(da[i] - e[i]) > epsilon) {
            printf("%s, line %d: Actual value ", file, line);
            printda(da, a->n);
            prints(" differs from expected value ");
            printda(e, ne);
            printf(" at index %d.\n", i);
            return false;
        }
    }
    printf("%s, line %d: check passed\n", file, line);
    base_count_success();
    return true;
}
示例#14
0
int main(int argc, char **argv) {
  int nof_frames;
  int ret;

  if (argc < 3) {
    usage(argv[0]);
    exit(-1);
  }
  parse_args(argc,argv);

  if (base_init()) {
    fprintf(stderr, "Error initializing memory\n");
    exit(-1);
  }

  uint8_t *data = malloc(100000);

  ret = -1;
  nof_frames = 0;
  do {
    srslte_filesource_read(&fsrc, input_buffer, flen);
    INFO("Reading %d samples sub-frame %d\n", flen, sf_idx);

    ret = srslte_ue_dl_decode(&ue_dl, input_buffer, data, sf_idx); 
    if(ret > 0) {
      printf("PDSCH Decoded OK!\n");       
    } else if (ret == 0) {
      printf("No DCI grant found\n");
    } else if (ret < 0) {
      printf("Error decoding PDSCH\n");
    }
    sf_idx = (sf_idx+1)%10;
    nof_frames++;
  } while (nof_frames <= max_frames && ret == 0);

  base_free();
  if (ret > 0) {        
    exit(0);
  } else {
    exit(-1); 
  }
}
示例#15
0
bool a_check_expect_file_line(const char *file, const char *function, int line, Array a, Array e) {
	base_init();
	base_count_check();
	if (a->n != e->n) {
		printf("%s, line %d: Actual length %d "
			"differs from expected length %d\n", file, line, a->n, e->n);
		return false;
	}
	if (a->s != e->s) {
		printf("%s, line %d: Actual element size %d "
			"differs from expected element size %d\n", file, line, a->s, e->s);
		return false;
	}
	if (a->n < 0) {
		printf("%s, line %d: Invalid actual length %d\n", file, line, a->n);
		return false;		
	}
	if (e->n < 0) {
		printf("%s, line %d: Invalid expected length %d\n", file, line, e->n);
		return false;		
	}
	if (a->n > 0 && a->a == NULL) {
		printf("%s, line %d: Actual value array is NULL\n", file, line);
		return false;		
	}
	if (e->n > 0 && e->a == NULL) {
		printf("%s, line %d: Expected value array is NULL\n", file, line);
		return false;		
	}
	char *ap = a->a;
	char *ep = e->a;
	for (int i = 0; i < a->n; i++) {
		if (memcmp(ap + i * e->s, ep + i * e->s, e->s) != 0) {
			printf("%s, line %d: Actual value differs from expected value at index %d.\n", file, line, i);
			return false;
		}
	}
	printf("%s, line %d: check passed\n", file, line);
	base_count_success();
	return true;
}
示例#16
0
extern "C" am_status_t am_log_init(const am_properties_t properties)
{
    am_status_t status = AM_SUCCESS;
    if (properties == NULL) {
        status = AM_INVALID_ARGUMENT;
    }
    else {
	const Properties *prop =
		reinterpret_cast<const Properties *>(properties);
	try {
	    base_init(*prop, B_TRUE);
	}
	catch (InternalException& ex) {
	    status = ex.getStatusCode();
	}
	catch (...) {
	    status = AM_FAILURE;
	}
    }
    return status;
}
示例#17
0
文件: tests.c 项目: 1ynx/gimp
/**
 * gimp_init_for_testing:
 *
 * Initialize the GIMP object system for unit testing. This is a
 * selected subset of the initialization happning in app_run().
 **/
Gimp *
gimp_init_for_testing (void)
{
  Gimp *gimp;
  
  gimp_log_init ();

  gimp = gimp_new ("Unit Tested GIMP", NULL, FALSE, TRUE, TRUE, TRUE,
                   FALSE, TRUE, TRUE, FALSE);

  units_init (gimp);

  gimp_load_config (gimp, NULL, NULL);

  base_init (GIMP_BASE_CONFIG (gimp->config),
             FALSE /*be_verbose*/,
             FALSE /*use_cpu_accel*/);
  gimp_initialize (gimp, gimp_status_func_dummy);
  gimp_restore (gimp, gimp_status_func_dummy);

  return gimp;
}
void TestQGeoSatelliteInfoSource::init()
{
    base_init();
}
示例#19
0
int main(void) {
	base_init();
	a_test_all();
	return 0;
}
示例#20
0
int main(int argc, char **argv) {
  ra_pdsch_t ra_dl;
  int i;
  int nof_frames;
  int ret;
  char *data;
  dci_location_t locations[10];
  uint32_t nof_locations;
  dci_msg_t dci_msg; 
  
  data = malloc(10000);

  if (argc < 3) {
    usage(argv[0]);
    exit(-1);
  }

  parse_args(argc,argv);

  if (base_init()) {
    fprintf(stderr, "Error initializing memory\n");
    exit(-1);
  }

  if (rnti == SIRNTI) {
    INFO("Initializing common search space for SI-RNTI\n",0);
    nof_locations = pdcch_common_locations(&pdcch, locations, 10, cfi);
  } else {
    // For ue-specific, generate locations for subframe 5
    INFO("Initializing user-specific search space for RNTI: 0x%x\n", rnti);
    nof_locations = pdcch_ue_locations(&pdcch, locations, 10, 5, cfi, rnti); 
  }
  
  ret = -1;
  nof_frames = 0;
  do {
    filesource_read(&fsrc, input_buffer, flen);
    if (nof_frames == 5) {
      INFO("Reading %d samples sub-frame %d\n", flen, nof_frames);

      lte_fft_run_sf(&fft, input_buffer, fft_buffer);

      if (fmatlab) {
        fprintf(fmatlab, "infft%d=", nof_frames);
        vec_fprint_c(fmatlab, input_buffer, flen);
        fprintf(fmatlab, ";\n");

        fprintf(fmatlab, "outfft%d=", nof_frames);
        vec_sc_prod_cfc(fft_buffer, 1000.0, fft_buffer, CP_NSYMB(cell.cp) * cell.nof_prb * RE_X_RB);
        vec_fprint_c(fmatlab, fft_buffer, CP_NSYMB(cell.cp) * cell.nof_prb * RE_X_RB);
        fprintf(fmatlab, ";\n");
        vec_sc_prod_cfc(fft_buffer, 0.001, fft_buffer,  CP_NSYMB(cell.cp) * cell.nof_prb * RE_X_RB);
      }

      /* Get channel estimates for each port */
      for (i=0;i<cell.nof_ports;i++) {
        chest_ce_slot_port(&chest, fft_buffer, ce[i], 2*nof_frames, i);
        chest_ce_slot_port(&chest, &fft_buffer[CP_NSYMB(cell.cp) * cell.nof_prb * RE_X_RB],
            &ce[i][CP_NSYMB(cell.cp) * cell.nof_prb * RE_X_RB], 2*nof_frames+1, i);
        if (fmatlab) {
          chest_fprint(&chest, fmatlab, 2*nof_frames+1, i);
        }
      }
      
      
      uint16_t crc_rem = 0;
      for (i=0;i<nof_locations && crc_rem != rnti;i++) {
        if (pdcch_extract_llr(&pdcch, fft_buffer, ce, locations[i], nof_frames, cfi)) {
          fprintf(stderr, "Error extracting LLRs\n");
          return -1;
        }
        if (pdcch_decode_msg(&pdcch, &dci_msg, Format1A, &crc_rem)) {
          fprintf(stderr, "Error decoding DCI msg\n");
          return -1;
        }
      }
      
      if (crc_rem == rnti) {
        if (dci_msg_to_ra_dl(&dci_msg, rnti, 1234, cell, cfi, &ra_dl)) {
          fprintf(stderr, "Error unpacking PDSCH scheduling DCI message\n");
          goto goout;
        }
        if (pdsch_harq_setup(&harq_process, ra_dl.mcs, &ra_dl.prb_alloc)) {
          fprintf(stderr, "Error configuring HARQ process\n");
          goto goout;
        }
        if (pdsch_decode(&pdsch, fft_buffer, ce, data, nof_frames%10, &harq_process, ra_dl.rv_idx)) {
          fprintf(stderr, "Error decoding PDSCH\n");
          goto goout;
        } else {
          printf("PDSCH Decoded OK!\n");
        }
      }
    }

    nof_frames++;
  } while (nof_frames <= max_frames);

  ret = 0;

goout:
  base_free();
  exit(ret);
}
示例#21
0
int main(int argc, char **argv) {
  int nf, sf_idx, N_id_2;
  cf_t pss_signal[PSS_LEN];
  float sss_signal0[SSS_LEN]; // for subframe 0
  float sss_signal5[SSS_LEN]; // for subframe 5
  pbch_mib_t mib;
  ra_pdsch_t ra_dl;
  ra_prb_t prb_alloc;
  refsignal_t refs[NSLOTS_X_FRAME];
  int i, n;
  char *data;
  cf_t *sf_symbols[MAX_PORTS];
  dci_msg_t dci_msg;
  dci_location_t locations[NSUBFRAMES_X_FRAME][10];

#ifdef DISABLE_UHD
  if (argc < 3) {
    usage(argv[0]);
    exit(-1);
  }
#endif

  parse_args(argc, argv);

  N_id_2 = cell.id % 3;
  sf_n_re = 2 * CPNORM_NSYMB * cell.nof_prb * RE_X_RB;
  sf_n_samples = 2 * SLOT_LEN(lte_symbol_sz(cell.nof_prb));

  /* this *must* be called after setting slot_len_* */
  base_init();

  /* Generate PSS/SSS signals */
  pss_generate(pss_signal, N_id_2);
  sss_generate(sss_signal0, sss_signal5, cell.id);
  
  /* Generate CRS signals */
  for (i = 0; i < NSLOTS_X_FRAME; i++) {
    if (refsignal_init_LTEDL(&refs[i], 0, i, cell)) {
      fprintf(stderr, "Error initiating CRS slot=%d\n", i);
      return -1;
    }
  }

  mib.nof_ports = cell.nof_ports;
  mib.nof_prb = cell.nof_prb;
  mib.phich_length = PHICH_NORM;
  mib.phich_resources = R_1;
  mib.sfn = 0;

  for (i = 0; i < MAX_PORTS; i++) { // now there's only 1 port
    sf_symbols[i] = sf_buffer;
  }

#ifndef DISABLE_UHD
  if (!output_file_name) {
    printf("Set TX rate: %.2f MHz\n",
        cuhd_set_tx_srate(uhd, lte_sampling_freq_hz(cell.nof_prb)) / 1000000);
    printf("Set TX gain: %.1f dB\n", cuhd_set_tx_gain(uhd, uhd_gain));
    printf("Set TX freq: %.2f MHz\n",
        cuhd_set_tx_freq(uhd, uhd_freq) / 1000000);
  }
#endif

  bzero(&ra_dl, sizeof(ra_pdsch_t));
  ra_dl.harq_process = 0;
  ra_dl.mcs_idx = mcs_idx;
  ra_dl.ndi = 0;
  ra_dl.rv_idx = 0;
  ra_dl.alloc_type = alloc_type0;
  ra_dl.type0_alloc.rbg_bitmask = 0xffffffff;
  
  dci_msg_pack_pdsch(&ra_dl, &dci_msg, Format1, cell.nof_prb, false);
  
  ra_prb_get_dl(&prb_alloc, &ra_dl, cell.nof_prb);
  ra_prb_get_re_dl(&prb_alloc, cell.nof_prb, 1, cell.nof_prb<10?(cfi+1):cfi, CPNORM);
  ra_mcs_from_idx_dl(mcs_idx, cell.nof_prb, &ra_dl.mcs);

  ra_pdsch_fprint(stdout, &ra_dl, cell.nof_prb);
  
  /* Initiate valid DCI locations */
  for (i=0;i<NSUBFRAMES_X_FRAME;i++) {
    pdcch_ue_locations(&pdcch, locations[i], 10, i, cfi, 1234);
  }

  data = malloc(sizeof(char) * ra_dl.mcs.tbs);
  if (!data) {
    perror("malloc");
    exit(-1);
  }  
    
  nf = 0;
  
  if (pdsch_harq_setup(&harq_process, ra_dl.mcs, &prb_alloc)) {
    fprintf(stderr, "Error configuring HARQ process\n");
    exit(-1);
  }

  while (nf < nof_frames || nof_frames == -1) {
    for (sf_idx = 0; sf_idx < NSUBFRAMES_X_FRAME && (nf < nof_frames || nof_frames == -1); sf_idx++) {
      bzero(sf_buffer, sizeof(cf_t) * sf_n_re);

      if (sf_idx == 0 || sf_idx == 5) {
        pss_put_slot(pss_signal, sf_buffer, cell.nof_prb, CPNORM);
        sss_put_slot(sf_idx ? sss_signal5 : sss_signal0, sf_buffer, cell.nof_prb,
            CPNORM);
      }
      
      if (sf_idx == 0) {
        pbch_encode(&pbch, &mib, sf_symbols);
      }
    
      for (n=0;n<2;n++) {
        refsignal_put(&refs[2*sf_idx+n], &sf_buffer[n*sf_n_re/2]);
      }

      pcfich_encode(&pcfich, cfi, sf_symbols, sf_idx);       

      INFO("SF: %d, Generating %d random bits\n", sf_idx, ra_dl.mcs.tbs);
      for (i=0;i<ra_dl.mcs.tbs;i++) {
        data[i] = rand()%2;
      }
      
      INFO("Puttting DCI to location: n=%d, L=%d\n", locations[sf_idx][0].ncce, locations[sf_idx][0].L);
      if (pdcch_encode(&pdcch, &dci_msg, locations[sf_idx][0], 1234, sf_symbols, sf_idx, cfi)) {
        fprintf(stderr, "Error encoding DCI message\n");
        exit(-1);
      }
      
      if (pdsch_encode(&pdsch, data, sf_symbols, sf_idx, &harq_process, ra_dl.rv_idx)) {
        fprintf(stderr, "Error encoding PDSCH\n");
        exit(-1);
      }

      /* Transform to OFDM symbols */
      lte_ifft_run_sf(&ifft, sf_buffer, output_buffer);
      
      /* send to file or usrp */
      if (output_file_name) {
        filesink_write(&fsink, output_buffer, sf_n_samples);
        usleep(5000);
      } else {
#ifndef DISABLE_UHD
        vec_sc_prod_cfc(output_buffer, uhd_amp, output_buffer, sf_n_samples);
        cuhd_send(uhd, output_buffer, sf_n_samples, true);
#endif
      }
      nf++;
    }
    mib.sfn = (mib.sfn + 1) % 1024;
    printf("SFN: %4d\r", mib.sfn);
    fflush(stdout);
  }

  base_free();

  printf("Done\n");
  exit(0);
}
示例#22
0
文件: app.c 项目: DevMaggio/gimp
void
app_run (const gchar         *full_prog_name,
         const gchar        **filenames,
         const gchar         *alternate_system_gimprc,
         const gchar         *alternate_gimprc,
         const gchar         *session_name,
         const gchar         *batch_interpreter,
         const gchar        **batch_commands,
         gboolean             as_new,
         gboolean             no_interface,
         gboolean             no_data,
         gboolean             no_fonts,
         gboolean             no_splash,
         gboolean             be_verbose,
         gboolean             use_shm,
         gboolean             use_cpu_accel,
         gboolean             console_messages,
         gboolean             use_debug_handler,
         GimpStackTraceMode   stack_trace_mode,
         GimpPDBCompatMode    pdb_compat_mode)
{
  GimpInitStatusFunc  update_status_func = NULL;
  Gimp               *gimp;
  GimpGeglConfig     *config;
  GMainLoop          *loop;
  gboolean            swap_is_ok;

  /*  Create an instance of the "Gimp" object which is the root of the
   *  core object system
   */
  gimp = gimp_new (full_prog_name,
                   session_name,
                   be_verbose,
                   no_data,
                   no_fonts,
                   no_interface,
                   use_shm,
                   console_messages,
                   stack_trace_mode,
                   pdb_compat_mode);

  errors_init (gimp, full_prog_name, use_debug_handler, stack_trace_mode);

  units_init (gimp);

  /*  Check if the user's gimp_directory exists
   */
  if (! g_file_test (gimp_directory (), G_FILE_TEST_IS_DIR))
    {
      GimpUserInstall *install = gimp_user_install_new (be_verbose);

#ifdef GIMP_CONSOLE_COMPILATION
      gimp_user_install_run (install);
#else
      if (! (no_interface ?
	     gimp_user_install_run (install) :
	     user_install_dialog_run (install)))
	exit (EXIT_FAILURE);
#endif

      gimp_user_install_free (install);
    }

  gimp_load_config (gimp, alternate_system_gimprc, alternate_gimprc);

  config = GIMP_GEGL_CONFIG (gimp->config);

  /*  change the locale if a language if specified  */
  language_init (gimp->config->language);

  /*  initialize lowlevel stuff  */
  swap_is_ok = base_init (config, be_verbose, use_cpu_accel);

  gimp_gegl_init (gimp);

#ifndef GIMP_CONSOLE_COMPILATION
  if (! no_interface)
    update_status_func = gui_init (gimp, no_splash);
#endif

  if (! update_status_func)
    update_status_func = app_init_update_noop;

  /*  Create all members of the global Gimp instance which need an already
   *  parsed gimprc, e.g. the data factories
   */
  gimp_initialize (gimp, update_status_func);

  /*  Load all data files
   */
  gimp_restore (gimp, update_status_func);

  /* display a warning when no test swap file could be generated */
  if (! swap_is_ok)
    {
      gchar *path = gimp_config_path_expand (config->swap_path, FALSE, NULL);

      g_message (_("Unable to open a test swap file.\n\n"
		   "To avoid data loss, please check the location "
		   "and permissions of the swap directory defined in "
		   "your Preferences (currently \"%s\")."), path);

      g_free (path);
    }

  /*  enable autosave late so we don't autosave when the
   *  monitor resolution is set in gui_init()
   */
  gimp_rc_set_autosave (GIMP_RC (gimp->edit_config), TRUE);

  /*  Load the images given on the command-line.
   */
  if (filenames)
    {
      gint i;

      for (i = 0; filenames[i] != NULL; i++)
        file_open_from_command_line (gimp, filenames[i], as_new);
    }

  batch_run (gimp, batch_interpreter, batch_commands);

  loop = g_main_loop_new (NULL, FALSE);

  g_signal_connect_after (gimp, "exit",
                          G_CALLBACK (app_exit_after_callback),
                          loop);

  gimp_threads_leave (gimp);
  g_main_loop_run (loop);
  gimp_threads_enter (gimp);

  g_main_loop_unref (loop);

  g_object_unref (gimp);

  gimp_debug_instances ();

  errors_exit ();
  gegl_exit ();
  base_exit ();
}
示例#23
0
文件: simple_tx.c 项目: sdnnfv/srsLTE
int main(int argc, char **argv) {
  int sf_idx=0, N_id_2=0;
  cf_t pss_signal[SRSLTE_PSS_LEN];
  float sss_signal0[SRSLTE_SSS_LEN]; // for subframe 0
  float sss_signal5[SRSLTE_SSS_LEN]; // for subframe 5
  int i;
  
#ifdef DISABLE_UHD
  if (argc < 3) {
    usage(argv[0]);
    exit(-1);
  }
#endif

  parse_args(argc, argv);

  N_id_2 = cell.id % 3;
  sf_n_re = 2 * SRSLTE_CP_NORM_NSYMB * cell.nof_prb * SRSLTE_NRE;
  sf_n_samples = 2 * SRSLTE_SLOT_LEN(srslte_symbol_sz(cell.nof_prb));

  cell.phich_length = SRSLTE_PHICH_NORM;
  cell.phich_resources = SRSLTE_PHICH_R_1;

  /* this *must* be called after setting slot_len_* */
  base_init();

  /* Generate PSS/SSS signals */
  srslte_pss_generate(pss_signal, N_id_2);
  srslte_sss_generate(sss_signal0, sss_signal5, cell.id);
  
  printf("Set TX rate: %.2f MHz\n",
      cuhd_set_tx_srate(uhd, srslte_sampling_freq_hz(cell.nof_prb)) / 1000000);
  printf("Set TX gain: %.1f dB\n", cuhd_set_tx_gain(uhd, uhd_gain));
  printf("Set TX freq: %.2f MHz\n",
      cuhd_set_tx_freq(uhd, uhd_freq) / 1000000);

  uint32_t nbits; 
  
  srslte_modem_table_t modulator; 
  srslte_modem_table_init(&modulator);
  srslte_modem_table_lte(&modulator, modulation);

  srslte_tcod_t turbocoder; 
  srslte_tcod_init(&turbocoder, SRSLTE_TCOD_MAX_LEN_CB);

  srslte_dft_precoding_t dft_precod;
  srslte_dft_precoding_init(&dft_precod, 12);
  
  nbits = srslte_cbsegm_cbindex(sf_n_samples/8/srslte_mod_bits_x_symbol(modulation)/3 - 12);
  uint32_t ncoded_bits = sf_n_samples/8/srslte_mod_bits_x_symbol(modulation); 
  
  uint8_t *data     = malloc(sizeof(uint8_t)*nbits);
  uint8_t *data_enc = malloc(sizeof(uint8_t)*ncoded_bits);
  cf_t    *symbols  = malloc(sizeof(cf_t)*sf_n_samples);
  
  bzero(data_enc, sizeof(uint8_t)*ncoded_bits);
  while (1) {
    for (sf_idx = 0; sf_idx < SRSLTE_NSUBFRAMES_X_FRAME; sf_idx++) {
      bzero(sf_buffer, sizeof(cf_t) * sf_n_re);

#ifdef kk
      if (sf_idx == 0 || sf_idx == 5) {
        srslte_pss_put_slot(pss_signal, sf_buffer, cell.nof_prb, SRSLTE_CP_NORM);
        srslte_sss_put_slot(sf_idx ? sss_signal5 : sss_signal0, sf_buffer, cell.nof_prb,
            SRSLTE_CP_NORM);
        /* Transform to OFDM symbols */
        srslte_ofdm_tx_sf(&ifft, sf_buffer, output_buffer);
        
        float norm_factor = (float) sqrtf(cell.nof_prb)/15;
        srslte_vec_sc_prod_cfc(output_buffer, uhd_amp*norm_factor, output_buffer, SRSLTE_SF_LEN_PRB(cell.nof_prb));
      
      } else {
#endif
        /* Generate random data */
        for (i=0;i<nbits;i++) {
          data[i] = rand()%2;
        }
        srslte_tcod_encode(&turbocoder, data, data_enc, nbits);
        srslte_mod_modulate(&modulator, data_enc, symbols, ncoded_bits);        
        srslte_interp_linear_offset_cabs(symbols, output_buffer, 8, sf_n_samples/8, 0, 0);
//    }
      
      /* send to usrp */
      srslte_vec_sc_prod_cfc(output_buffer, uhd_amp, output_buffer, sf_n_samples);
      cuhd_send(uhd, output_buffer, sf_n_samples, true);
    }
  }

  base_free();

  printf("Done\n");
  exit(0);
}
示例#24
0
_WPRTLINK WCSkipNonTempBase::WCSkipNonTempBase( unsigned prob, unsigned max_ptrs,
        WCbool duplicates )
    : alloc_fn( 0 ), dealloc_fn( 0 ), level( 0 ),
      allowDuplicates( duplicates ), num_entries( 0 ) {
    base_init( prob, max_ptrs );
}
示例#25
0
int main(int argc, char **argv) {
	int nf, ns, N_id_2;
	cf_t pss_signal[PSS_LEN];
	float sss_signal0[SSS_LEN]; // for subframe 0
	float sss_signal5[SSS_LEN]; // for subframe 5
	pbch_mib_t mib;
	refsignal_t refs[NSLOTS_X_FRAME];
	int i;
	cf_t *slot1_symbols[MAX_PORTS_CTRL];


#ifdef DISABLE_UHD
	if (argc < 3) {
		usage(argv[0]);
		exit(-1);
	}
#endif

	parse_args(argc,argv);

	N_id_2 = cell_id%3;
	slot_n_re = CPNORM_NSYMB * nof_prb * RE_X_RB;
	slot_n_samples = SLOT_LEN_CPNORM(lte_symbol_sz(nof_prb));

	/* this *must* be called after setting slot_len_* */
	base_init();

	/* Generate PSS/SSS signals */
	pss_generate(pss_signal, N_id_2);
	sss_generate(sss_signal0, sss_signal5, cell_id);

	/* Generate CRS signals */
	for (i=0;i<NSLOTS_X_FRAME;i++) {
		if (refsignal_init_LTEDL(&refs[i], 0, i, cell_id, CPNORM, nof_prb)) {
			fprintf(stderr, "Error initiating CRS slot=%d\n", i);
			return -1;
		}
	}

	mib.nof_ports = 1;
	mib.nof_prb = 6;
	mib.phich_length = PHICH_NORM;
	mib.phich_resources = R_1;
	mib.sfn = 0;

	for (i=0;i<MAX_PORTS_CTRL;i++) { // now there's only 1 port
		slot1_symbols[i] = slot_buffer;
	}

#ifndef DISABLE_UHD
	if (!output_file_name) {
		printf("Set TX rate: %.2f MHz\n", cuhd_set_tx_srate(uhd, UHD_SAMP_FREQ)/1000000);
		printf("Set TX gain: %.1f dB\n", cuhd_set_tx_gain(uhd, uhd_gain));
		printf("Set TX freq: %.2f MHz\n", cuhd_set_tx_freq(uhd, uhd_freq)/1000000);
	}
#endif

	nf = 0;

	while(nf<nof_frames || nof_frames == -1) {
		for (ns=0;ns<NSLOTS_X_FRAME;ns++) {
			bzero(slot_buffer, sizeof(cf_t) * slot_n_re);

			switch(ns) {
			case 0: // tx pss/sss
			case 10: // tx pss/sss
				pss_put_slot(pss_signal, slot_buffer, nof_prb, CPNORM);
				sss_put_slot(ns?sss_signal5:sss_signal0, slot_buffer, nof_prb, CPNORM);
				break;
			case 1: // tx pbch
				pbch_encode(&pbch, &mib, slot1_symbols, 1);
				break;
			default: // transmit zeros
				break;
			}

			refsignal_put(&refs[ns], slot_buffer);

			/* Transform to OFDM symbols */
			lte_ifft_run(&ifft, slot_buffer, output_buffer);

			/* send to file or usrp */
			if (output_file_name) {
				filesink_write(&fsink, output_buffer, slot_n_samples);
				usleep(5000);
			} else {
#ifndef DISABLE_UHD
				vec_sc_prod_cfc(output_buffer, uhd_amp, output_buffer, slot_n_samples);
				cuhd_send(uhd, output_buffer, slot_n_samples, 1);
#endif
			}
		}
		mib.sfn=(mib.sfn+1)%1024;
		printf("SFN: %4d\r", mib.sfn);fflush(stdout);
		nf++;
	}

	base_free();

	printf("Done\n");
	exit(0);
}
示例#26
0
文件: edax.c 项目: markkings/reversi
/**
 * @brief Loop event.
 * @param ui user interface.
 */
void ui_loop_edax(UI *ui)
{
	char *cmd = NULL, *param = NULL;
	Play *play = ui->play;
	char book_file[FILENAME_MAX];
	unsigned long long histogram[129][65];
	int repeat = options.repeat;

	histogram_init(histogram);

	// loop forever
	for (;;) {
		errno = 0;

		if (options.verbosity) {
			putchar('\n');
			play_print(play, stdout);
			if (play_is_game_over(play)) printf("\n*** Game Over ***\n");
			putchar('\n');
		}

		if (log_is_open(edax_log)) {
			putc('\n', edax_log->f);
			play_print(play, edax_log->f);
			if (play_is_game_over(play)) fputs("\n*** Game Over ***\n", edax_log->f);
			putc('\n', edax_log->f);
		}

		// edax turn ? (automatic play mode)
		if (!ui_event_exist(ui) && !play_is_game_over(play) && (ui->mode == !play->player || ui->mode == 2)) {
			putchar('\n');
			play_go(play, true);
			printf("\nEdax plays "); move_print(play_get_last_move(play)->x, 0, stdout); putchar('\n');
			if (ui->mode != 2) play_ponder(play);

		// proceed by reading a command
		} else {

			/* automatic rules after a game over*/
			if (play_is_game_over(play)) {
				if (options.auto_store) play_store(play);
				if (options.auto_swap && ui->mode < 2) ui->mode = !ui->mode;
				if (options.repeat && repeat > 1) {
					--repeat;
					play_new(play);
					continue;
				}
				if (options.auto_quit) {
					return;
				}
				if (options.auto_start) {
					play_new(play);
					continue;
				}
			}

			putchar('>'); fflush(stdout);
			ui_event_wait(ui, &cmd, &param);
			log_print(edax_log, "cmd=\"%s\" ; param=\"%s\"\n", cmd, param);
			putchar('\n');

			if (cmd == NULL) {
				warn("unexpected null command?\n");
				continue;
			}

			// skip empty lines or commented lines
			if (*cmd == '\0' || *cmd == '#') {
			
			// help
			} else if (strcmp(cmd, "help") == 0 || strcmp(cmd, "?") == 0) {
				if (*param == '\0' || strcmp(param, "options") == 0) help_options();
				if (*param == '\0' || strcmp(param, "commands") == 0) help_commands();
				if (*param == '\0' || strcmp(param, "book") == 0) help_book();
				if (*param == '\0' || strcmp(param, "base") == 0) help_base();
				if (*param == '\0' || strcmp(param, "test") == 0) help_test(); 

			// new game from standard position
			} else if (strcmp(cmd, "i") == 0 || strcmp(cmd, "init") == 0) {
				board_init(play->initial_board);
				play_new(play);

			// new game from personnalized position
			} else if ((strcmp(cmd, "n") == 0 || strcmp(cmd, "new") == 0) && *param == '\0') {
				play_new(play);

			// open a saved game
			} else if (strcmp(cmd, "o") == 0 || strcmp(cmd, "open") == 0 || strcmp(cmd, "load") == 0) {
				play_load(play, param);

			// save a game
			} else if (strcmp(cmd, "s") == 0 || strcmp(cmd, "save") == 0) {
				play_save(play, param);

			// quit
			} else if (strcmp(cmd, "quit") == 0 || strcmp(cmd, "q") == 0 || strcmp(cmd, "exit") == 0) {
				free(cmd); free(param);
				return;

			} else if (!options.auto_quit && (strcmp(cmd, "eof") == 0 && (ui->mode != 2 || play_is_game_over(play)))){
				free(cmd); free(param);
				return;

			// undo last move
			} else if (strcmp(cmd, "u") == 0 || strcmp(cmd, "undo") == 0) {
				play_undo(play);
				if (ui->mode == 0 || ui->mode == 1) play_undo(play);

			// redo last move
			} else if (strcmp(cmd, "r") == 0 || strcmp(cmd, "redo") == 0) {
				play_redo(play);
				if (ui->mode == 0 || ui->mode == 1) play_undo(play);

			// mode
			} else if (strcmp(cmd, "m") == 0 || strcmp(cmd, "mode") == 0) {
				ui->mode = string_to_int(param, 3);

			// analyze a game
			} else if (strcmp(cmd, "a") == 0 || strcmp(cmd, "analyze") == 0 || strcmp(cmd, "analyse") == 0) {
				play_analyze(play, string_to_int(param, play->n_game));

			// set a new initial position
			} else if (strcmp(cmd, "setboard") == 0) {
				play_set_board(play, param);

			// vertical mirror
			} else if (strcmp(cmd, "vmirror") == 0) {
				play_symetry(play, 2);

			// horizontal mirror
			} else if (strcmp(cmd, "hmirror") == 0) {
				play_symetry(play, 1);

			// rotate
			} else if (strcmp(cmd, "rotate") == 0) {
				int angle = string_to_int(param, 90) % 360;
				if (angle < 0) angle += 360;
				switch (angle) {
				case 90: 
					play_symetry(play, 5);
					break; 
				case 180:
					play_symetry(play, 3);
					break; 
				case 270:
					play_symetry(play, 6);
					break; 
				default:
					warn("Rotate angle should be 90°, 180° or 270°");
					break;
				}

			// direct symetry...
			} else if (strcmp(cmd, "symetry") == 0) {
				int sym = string_to_int(param, 1);
				if (sym < 0 || sym >= 16) warn("symetry parameter should be a number between 0 and 15\n");
				else {
					if (sym & 8) play->player ^= 1;
					play_symetry(play, sym & 7);
				}

			// play a serie of moves
			} else if (strcmp(cmd, "play") == 0) {
				string_to_lowercase(param);
				play_game(play, param);

			// force edax to play an opening
			} else if (strcmp(cmd, "force") == 0) {
				string_to_lowercase(param);
				play_force_init(play, param);

			// solve a set of problems
			} else if (strcmp(cmd, "solve") == 0) {
				char problem_file[FILENAME_MAX + 1], *hard_file;
				hard_file = parse_word(param, problem_file, FILENAME_MAX);
				parse_word(hard_file, hard_file, FILENAME_MAX);
				obf_test(play->search, problem_file, hard_file);
				search_set_observer(play->search, edax_observer);

			// convert a set of problems in a .script file to a .obf file
			} else if (strcmp(cmd, "script-to-obf") == 0) {
				char script_file[FILENAME_MAX + 1], *obf_file;
				obf_file = parse_word(param, script_file, FILENAME_MAX);
				parse_word(obf_file, obf_file, FILENAME_MAX);
				script_to_obf(play->search, script_file, obf_file);
				search_set_observer(play->search, edax_observer);

			} else if (strcmp(cmd, "select-hard") == 0) {
				char full_file[FILENAME_MAX + 1], *hard_file;
				hard_file = parse_word(param, full_file, FILENAME_MAX);
				parse_word(hard_file, hard_file, FILENAME_MAX);
				obf_filter(full_file, hard_file);

			// game/position enumeration
			} else if (strcmp(cmd, "count") == 0) {
				char count_cmd[16], *count_param;
				int depth = 10, size = 8;

				count_param = parse_word(param, count_cmd, 15);
				count_param = parse_int(count_param, &depth); BOUND(depth, 1, 90, "max-ply");
				if (count_param) parse_int(count_param, &size); BOUND(size, 6, 8, "board-size");

				if (strcmp(count_cmd, "games") == 0) { // game enumeration
					quick_count_games(play->board, depth, size);
				} else if (strcmp(count_cmd, "positions") == 0) { // position enumeration
					count_positions(play->board, depth, size);
				} else if (strcmp(count_cmd, "shapes") == 0) { // shape enumeration
					count_shapes(play->board, depth, size);
				} else {
					warn("Unknown count command: \"%s %s\"\n", cmd, param);
				}

			} else if (strcmp(cmd, "perft") == 0) {
				int depth = 14;
				depth = string_to_int(param, 10); BOUND(depth, 1, 90, "max-ply");
				count_games(play->board, depth);
			
			// game/position enumeration
			} else if (strcmp(cmd, "estimate") == 0) {
				int n = 1000;
				n = string_to_int(param, 10); BOUND(n, 1, 2000000000, "max-trials");

				estimate_games(play->board, n);
	
			// seek highest mobility
			} else if (strcmp(cmd, "mobility") == 0) {
				int t = 3600; // 1 hour
				t = string_to_int(param, 10); BOUND(t, 1, 3600*24*365*10, "max time");

				seek_highest_mobility(play->board, t);

			// seek a position
			} else if (strcmp(cmd, "seek") == 0) {
				Board target;
				Line solution;
				
				board_set(&target, param);
				line_init(&solution, play->player);
				
				if (seek_position(&target, play->board, &solution)) {
					printf("Solution found:\n");
					line_print(&solution, 200, " ", stdout);
					putchar('\n');
				}
			
			// bench (a serie of low level tests).
			} else if (strcmp(cmd, "bench") == 0) {
				bench();

			// wtest test the engine against wthor theoretical scores
			} else if (strcmp(cmd, "wtest") == 0) {
				wthor_test(param, play->search);

			// make wthor games played by "Edax (Delorme)" as "Etudes" tournament.
			} else if (strcmp(cmd, "edaxify") == 0) {
				wthor_edaxify(param);

			// wtest test the engine against wthor theoretical scores
			} else if (strcmp(cmd, "weval") == 0) {
				wthor_eval(param, play->search, histogram);
				histogram_print(histogram);
				histogram_stats(histogram);
				histogram_to_ppm("weval.ppm", histogram);

			// go think!
			} else if (strcmp(cmd, "go") == 0) {
				if (play_is_game_over(play)) printf("\n*** Game Over ***\n");
				else {
					play_go(play, true);
					printf("\nEdax plays "); move_print(play_get_last_move(play)->x, 0, stdout); putchar('\n');
				}

			// hint for [n] moves
			} else if (strcmp(cmd, "hint") == 0) {
				int n = string_to_int(param, 1); BOUND(n, 1, 60, "n_moves");
				play_hint(play, n);

			// stop thinking
			} else if (strcmp(cmd, "stop") == 0) {
				ui->mode = 3;

			// user move
			} else if (play_user_move(play, cmd)) {
				printf("\nYou play "); move_print(play_get_last_move(play)->x, 0, stdout); putchar('\n');

			// debug pv
			} else if (strcmp(cmd, "debug-pv") == 0) {
				Move move[1];
				if (parse_move(param, play->board, move) != param) {
					search_set_board(play->search, play->board, play->player);
					pv_debug(play->search, move, stdout);
				}
			} else if (strcmp(cmd, "options") == 0) {
					options_dump(stdout);
#ifdef __unix__
			} else if (strcmp(cmd, "resources") == 0) {
				struct rusage u;
				long long t;
	 			getrusage(RUSAGE_SELF, &u);
				t = 1000 * u.ru_utime.tv_sec + u.ru_utime.tv_usec / 1000;
				printf("user cpu time: "); time_print(t, false, stdout); printf("\n");	
				t = 1000 * u.ru_stime.tv_sec + u.ru_stime.tv_usec / 1000;
				printf("system cpu time: "); time_print(t, false, stdout); printf("\n");	
				printf("max resident memory: %ld\n", u.ru_maxrss); 
				printf("page fault without I/O: %ld\n", u.ru_minflt); 
				printf("page fault with I/O: %ld\n", u.ru_majflt); 
				printf("number of input: %ld\n", u.ru_inblock); 
				printf("number of output: %ld\n", u.ru_oublock); 
				printf("number of voluntary context switch: %ld\n", u.ru_nvcsw); 
				printf("number of unvoluntary context switch: %ld\n\n", u.ru_nivcsw); 
#endif		
			// opening name
			} else if (strcmp(cmd, "opening") == 0) {
				const char *name;
				name = play_show_opening_name(play, opening_get_english_name);
				if (name == NULL) name = "?";
				puts(name);  

			// opening name in french
			} else if (strcmp(cmd, "ouverture") == 0) {
				const char *name;
				name = play_show_opening_name(play, opening_get_french_name);
				if (name == NULL) name = "?";
				puts(name); 

			// opening book commands
			} else if (strcmp(cmd, "book") == 0 || strcmp(cmd, "b") == 0) {
				char book_cmd[FILENAME_MAX + 1], *book_param;
				int val_1, val_2;
				Book *book = play->book;

				book->search = play->search;
				book->search->options.verbosity = book->options.verbosity;
				book_param = parse_word(param, book_cmd, FILENAME_MAX);
				// store the last played game
				if (strcmp(book_cmd, "store") == 0) {
					play_store(play);

				// turn book usage on
				} else if (strcmp(book_cmd, "on") == 0) { // learn
					options.book_allowed = true;

				// turn book usage off
				} else if (strcmp(book_cmd, "off") == 0) { // learn
					options.book_allowed = false;

				// set book randomness
				} else if (strcmp(book_cmd, "randomness") == 0) { // learn
					val_1 = 0; book_param = parse_int(book_param, &val_1);
					options.book_randomness = val_1;

				// set book depth (until which to learn)
				} else if (strcmp(book_cmd, "depth") == 0) { // learn
					val_1 = 36; book_param = parse_int(book_param, &val_1);
					book->options.n_empties = 61 - val_1;

				// create a new empty book
				} else if (strcmp(book_cmd, "new") == 0) {
					val_1 = 21; book_param = parse_int(book_param, &val_1);
					val_2 = 36;	book_param = parse_int(book_param, &val_2);
					book_free(book) ;
					book_new(book, val_1, 61 - val_2);

				// load an opening book (binary format) from the disc
				} else if (strcmp(book_cmd, "load") == 0 || strcmp(book_cmd, "open") == 0) {
					book_free(book) ;
					parse_word(book_param, book_file, FILENAME_MAX);
					book_load(book, book_file);

				// save an opening book (binary format) to the disc
				} else if (strcmp(book_cmd, "save") == 0) {
					parse_word(book_param, book_file, FILENAME_MAX);
					book_save(book, book_file);

				// import an opening book (text format)
				} else if (strcmp(book_cmd, "import") == 0) {
					book_free(book);
					parse_word(book_param, book_file, FILENAME_MAX);
					book_import(book, book_file);
					book_link(book);
					book_fix(book);
					book_negamax(book);
					book_sort(book);

				// export an opening book (text format)
				} else if (strcmp(book_cmd, "export") == 0) {
					parse_word(book_param, book_file, FILENAME_MAX);
					book_export(book, book_file);

				// merge an opening book to the current one
				} else if (strcmp(book_cmd, "merge") == 0) {
					Book src[1];
					parse_word(book_param, book_file, FILENAME_MAX);
					src->search = play->search;
					book_load(src, book_file);
					book_merge(book, src);
					book_free(src);
					warn("Book needs to be fixed before usage\n");

				// fix an opening book
				} else if (strcmp(book_cmd, "fix") == 0) {
					book_fix(book); // do nothing (or edax is buggy)
					book_link(book); // links nodes
					book_negamax(book); // negamax nodes
					book_sort(book); // sort moves

				// negamax an opening book
				} else if (strcmp(book_cmd, "negamax") == 0) {
					book_negamax(book); // negamax nodes
					book_sort(book); // sort moves

				// check and correct solved positions of the book
				} else if (strcmp(book_cmd, "correct") == 0) {
					book_correct_solved(book); // do nothing (or edax is buggy)
					book_fix(book); // do nothing (or edax is buggy)
					book_link(book); // links nodes
					book_negamax(book); // negamax nodes
					book_sort(book); // sort moves

				// prune an opening book
				} else if (strcmp(book_cmd, "prune") == 0) {
					book_prune(book); // remove unreachable lines.
					book_fix(book); // do nothing (or edax is buggy)
					book_link(book); // links nodes
					book_negamax(book); // negamax nodes
					book_sort(book); // sort moves

				// show the current position as stored in the book
				} else if (strcmp(book_cmd, "show") == 0) {
					book_show(book, play->board);

				// show book general information
				} else if (strcmp(book_cmd, "info") == 0) {
					book_info(book);

				// show book general information
				} else if (strcmp(book_cmd, "stats") == 0) {
					book_stats(book);


				// set book verbosity
				} else if (strcmp(book_cmd, "verbose") == 0) {
					parse_int(book_param, &book->options.verbosity);
					book->search->options.verbosity = book->options.verbosity;

				// analyze a game from the opening book point of view
				} else if (strcmp(book_cmd, "a") == 0 || strcmp(book_cmd, "analyze") == 0 || strcmp(book_cmd, "analyse") == 0) {
					val_1 = string_to_int(book_param, play->n_game); BOUND(val_1, 1, play->n_game, "depth");
					play_book_analyze(play, val_1);

				// add positions from a game database
				} else if (strcmp(book_cmd, "add") == 0) {
					Base base[1];
					parse_word(book_param, book_file, FILENAME_MAX);
					base_init(base);
					base_load(base, book_file);
					book_add_base(book, base);
					base_free(base);

				// check positions from a game database
				} else if (strcmp(book_cmd, "check") == 0) {
					Base base[1];
					parse_word(book_param, book_file, FILENAME_MAX);
					base_init(base);
					base_load(base, book_file);
					book_check_base(book, base);
					base_free(base);

				// extract positions
				} else if (strcmp(book_cmd, "problem") == 0) {
					val_1 = 24; book_param = parse_int(book_param, &val_1); BOUND(val_1, 0, 60, "number of empties");
					val_2 = 10; book_param = parse_int(book_param, &val_2); BOUND(val_2, 1, 1000000, "number of positions");
					book_extract_positions(book, val_1, val_2);
					
				// extract pv to a game database
				} else if (strcmp(book_cmd, "extract") == 0) {
					Base base[1];
					parse_word(book_param, book_file, FILENAME_MAX);
					base_init(base);
					book_extract_skeleton(book, base);
					base_save(base, book_file);
					base_free(base);

				// add position using the "deviate algorithm"
				} else if (strcmp(book_cmd, "deviate") == 0) {
					val_1 = 2; book_param = parse_int(book_param, &val_1); BOUND(val_1, -129, 129, "relative error");
					val_2 = 4; book_param = parse_int(book_param, &val_2); BOUND(val_2, 0, 65, "absolute error");
					book_deviate(book, play->board, val_1, val_2);

				// add position using the "enhance algorithm"
				} else if (strcmp(book_cmd, "enhance") == 0) {
					val_1 = 2; book_param = parse_int(book_param, &val_1); BOUND(val_1, 0, 129, "midgame error");
					val_2 = 4; book_param = parse_int(book_param, &val_2); BOUND(val_2, 0, 129, "endcut error");
					book_enhance(book, play->board, val_1, val_2);

				// add position by filling hole in the book
				} else if (strcmp(book_cmd, "fill") == 0) {
					val_1 = 1; book_param = parse_int(book_param, &val_1); BOUND(val_1, 1, 61, "fill depth");
					book_fill(book, val_1);

				// add positions by expanding positions with no-link
				} else if (strcmp(book_cmd, "play") == 0) {
					book_play(book);

				// add positions by expanding positions with no-link
				} else if (strcmp(book_cmd, "deepen") == 0) {
					book_deepen(book);

				// add book positions to the hash table
				} else if (strcmp(book_cmd, "feed-hash") == 0) {
					book_feed_hash(book, play->board, play->search);

				// wrong command ?
				} else {
					warn("Unknown book command: \"%s %s\"\n", cmd, param);
				}
				book->options.verbosity = book->search->options.verbosity;
				book->search->options.verbosity = options.verbosity;

			/* base TODO: add more actions... */
			} else if (strcmp(cmd, "base") == 0) {
				char base_file[FILENAME_MAX + 1];
				char base_cmd[512], *base_param;
				Base base[1];

				base_init(base);
				base_param = parse_word(param, base_cmd, 511);
				base_param = parse_word(base_param, base_file, FILENAME_MAX);

				// extract problem from a game base
				if (strcmp(base_cmd, "problem") == 0) {
					char problem_file[FILENAME_MAX + 1];
					int n_empties = 24;
					base_param = parse_int(base_param, &n_empties);
					base_param = parse_word(base_param, problem_file, FILENAME_MAX);

					base_load(base, base_file);
					base_to_problem(base, n_empties, problem_file);

				// extract FEN 
				} else if (strcmp(base_cmd, "tofen") == 0) {
					char problem_file[FILENAME_MAX + 1];
					int n_empties = 24;
					base_param = parse_int(base_param, &n_empties);
					base_param = parse_word(base_param, problem_file, FILENAME_MAX);

					base_load(base, base_file);
					base_to_FEN(base, n_empties, problem_file);
	
				// correct erroneous games
				} else if (strcmp(base_cmd, "correct") == 0) {
					int n_empties = 24;
					base_param = parse_int(base_param, &n_empties);

					base_load(base, base_file);
					base_analyze(base, play->search, n_empties, true);
					remove(base_file);
					base_save(base, base_file);

				// check erroneous games
				} else if (strcmp(base_cmd, "check") == 0) {
					int n_empties = 24;
					base_param = parse_int(base_param, &n_empties);

					base_load(base, base_file);
					base_analyze(base, play->search, n_empties, false);

				// terminate unfinished base
				} else if (strcmp(base_cmd, "complete") == 0) {
					base_load(base, base_file);
					base_complete(base, play->search);
					remove(base_file);
					base_save(base, base_file);

				// convert a base to another format
				} else if (strcmp(base_cmd, "convert") == 0) {
					base_load(base, base_file);
					base_param = parse_word(base_param, base_file, FILENAME_MAX);
					base_save(base, base_file);

				// make a base unique by removing identical games
				} else if (strcmp(base_cmd, "unique") == 0) {
					base_load(base, base_file);
					base_param = parse_word(base_param, base_file, FILENAME_MAX);
					base_unique(base);
					base_save(base, base_file);

				// compare two game bases
				} else if (strcmp(base_cmd, "compare") == 0) {
					char base_file_2[FILENAME_MAX + 1];
					base_param = parse_word(base_param, base_file_2, FILENAME_MAX);
					base_compare(base_file, base_file_2);

				} else {
					warn("Unknown base command: \"%s %s\"\n", cmd, param);
				}

				base_free(base);

			/* edax options */
			} else if (options_read(cmd, param)) {
				options_bound();
				// parallel search changes:
				if (search_count_tasks(play->search) != options.n_task) {
					play_stop_pondering(play);
					search_set_task_number(play->search, options.n_task);
				}

			/* switch to another protocol */
			} else if (strcmp(cmd, "nboard") == 0 && strcmp(param, "1") == 0) {
				free(cmd); free(param);
				play_stop_pondering(play);
				ui->free(ui);
				ui_switch(ui, "nboard");
				ui->init(ui);
				ui->loop(ui);
				return;

			} else if (strcmp(cmd, "xboard") == 0) {
				free(cmd); free(param);
				play_stop_pondering(play);
				ui->free(ui);
				ui_switch(ui, "xboard");
				ui->init(ui);
				ui->loop(ui);
				return;

			} else if (strcmp(cmd, "engine-protocol") == 0 && strcmp(param, "init") == 0) {
				free(cmd); free(param);
				play_stop_pondering(play);
				ui->free(ui);
				ui_switch(ui, "cassio");
				engine_loop();
				return;

			} else if (strcmp(cmd, "protocol_version") == 0) {
				free(cmd); free(param);
				play_stop_pondering(play);
				ui->free(ui);
				ui_switch(ui, "gtp");
				ui->init(ui);
				puts("= 2\n"); fflush(stdout);
				ui->loop(ui);
				return;

#ifdef TUNE_EDAX
			/* edax tuning */
			} else if (strcmp(cmd, "tune") == 0) {
				char problem[FILENAME_MAX];
				char *w_name;
				play_stop_pondering(play);
				w_name = parse_word(param, problem, FILENAME_MAX);
				tune_move_evaluate(play->search, problem, parse_skip_spaces(w_name));
				search_set_observer(play->search, edax_observer);
#endif
			/* illegal cmd/move */
			} else {
				warn("Unknown command/Illegal move: \"%s %s\"\n", cmd, param);
			}
		}
	}
}
示例#27
0
int main(int argc, char **argv) {
  int frame_cnt, valid_frames;
  int freq;
  int cell_id;
  sync_t sfind, strack;
  float max_peak_to_avg;
  float sfo;
  int find_idx, track_idx, last_found;
  enum sync_state state;
  int n;
  filesink_t fs;

  if (argc < 3) {
    usage(argv[0]);
    exit(-1);
  }

  parse_args(argc,argv);

  if (base_init(FLEN)) {
    fprintf(stderr, "Error initializing memory\n");
    exit(-1);
  }

  if (sync_init(&sfind, FLEN)) {
    fprintf(stderr, "Error initiating PSS/SSS\n");
    exit(-1);
  }
  sync_pss_det_peak_to_avg(&sfind);

  if (sync_init(&strack, track_len)) {
    fprintf(stderr, "Error initiating PSS/SSS\n");
    exit(-1);
  }
  sync_pss_det_peak_to_avg(&strack);

  nof_bands = lte_band_get_fd_band(band, channels, earfcn_start, earfcn_end, MAX_EARFCN);
  printf("RSSI scan: %d freqs in band %d, RSSI threshold %.2f dBm\n", nof_bands, band, rssi_threshold);

  n = rssi_scan();
  if (n == -1) {
    exit(-1);
  }

  printf("\nDone. Starting PSS search on %d channels\n", n);
  usleep(500000);
  INFO("Setting sampling frequency %.2f MHz\n", (float) SAMP_FREQ/MHZ);
  cuhd_set_rx_srate(uhd, SAMP_FREQ);

  cuhd_set_rx_gain(uhd, uhd_gain);

  print_to_matlab();

  filesink_init(&fs, "test.dat", COMPLEX_FLOAT_BIN);

  freq=0;
  state = INIT;
  find_idx = 0;
  max_peak_to_avg = 0;
  last_found = 0;
  frame_cnt = 0;
  while(freq<nof_bands) {
    /* scan only bands above rssi_threshold */
    if (!IS_SIGNAL(freq)) {
      INFO("[%3d/%d]: Skipping EARFCN %d %.2f MHz RSSI %.2f dB\n", freq, nof_bands,
                channels[freq].id, channels[freq].fd,10*log10f(rssi[freq]) + 30);
      freq++;
    } else {
      if (state == TRACK || state == FIND) {
        cuhd_recv(uhd, &input_buffer[FLEN], FLEN, 1);
      }
      switch(state) {
      case INIT:
        DEBUG("Stopping receiver...\n",0);
        cuhd_stop_rx_stream(uhd);

        /* set freq */
        cuhd_set_rx_freq(uhd, (double) channels[freq].fd * MHZ);
        cuhd_rx_wait_lo_locked(uhd);
        DEBUG("Set freq to %.3f MHz\n", (double) channels[freq].fd);

        DEBUG("Starting receiver...\n",0);
        cuhd_start_rx_stream(uhd);

        /* init variables */
        frame_cnt = 0;
        max_peak_to_avg = -99;
        cell_id = -1;

        /* receive first frame */
        cuhd_recv(uhd, input_buffer, FLEN, 1);

        /* set find_threshold and go to FIND state */
        sync_set_threshold(&sfind, find_threshold);
        sync_force_N_id_2(&sfind, -1);
        state = FIND;
        break;
      case FIND:
        /* find peak in all frame */
        find_idx = sync_run(&sfind, &input_buffer[FLEN]);
        DEBUG("[%3d/%d]: PAR=%.2f\n", freq, nof_bands, sync_get_peak_to_avg(&sfind));
        if (find_idx != -1) {
          /* if found peak, go to track and set lower threshold */
          frame_cnt = -1;
          last_found = 0;
          sync_set_threshold(&strack, track_threshold);
          sync_force_N_id_2(&strack, sync_get_N_id_2(&sfind));
          state = TRACK;
          INFO("[%3d/%d]: EARFCN %d Freq. %.2f MHz PSS found PAR %.2f dB\n", freq, nof_bands,
                        channels[freq].id, channels[freq].fd,
                        10*log10f(sync_get_peak_to_avg(&sfind)));
        } else {
          if (frame_cnt >= nof_frames_find) {
            state = INIT;
            printf("[%3d/%d]: EARFCN %d Freq. %.2f MHz No PSS found\r", freq, nof_bands,
                          channels[freq].id, channels[freq].fd, frame_cnt - last_found);
            if (VERBOSE_ISINFO()) {
              printf("\n");
            }
            freq++;
          }
        }
        break;
      case TRACK:
        INFO("Tracking PSS find_idx %d offset %d\n", find_idx, find_idx + track_len);

        filesink_write(&fs, &input_buffer[FLEN+find_idx+track_len], track_len);

        track_idx = sync_run(&strack, &input_buffer[FLEN + find_idx - track_len]);
        p2a_v[frame_cnt] = sync_get_peak_to_avg(&strack);

        /* save cell id for the best peak-to-avg */
        if (p2a_v[frame_cnt] > max_peak_to_avg) {
          max_peak_to_avg = p2a_v[frame_cnt];
          cell_id = sync_get_cell_id(&strack);
        }
        if (track_idx != -1) {
          cfo_v[frame_cnt] = sync_get_cfo(&strack);
          last_found = frame_cnt;
          find_idx += track_idx - track_len;
          idx_v[frame_cnt] = find_idx;
        } else {
          idx_v[frame_cnt] = -1;
          cfo_v[frame_cnt] = 0.0;
        }
        /* if we missed to many PSS it is not a cell, next freq */
        if (frame_cnt - last_found > max_track_lost) {
          INFO("\n[%3d/%d]: EARFCN %d Freq. %.2f MHz %d frames lost\n", freq, nof_bands,
              channels[freq].id, channels[freq].fd, frame_cnt - last_found);

          state = INIT;
          freq++;
        } else if (frame_cnt >= nof_frames_track) {
          state = DONE;
        }
        break;
      case DONE:

        cfo[freq] = mean_valid(idx_v, cfo_v, frame_cnt);
        p2a[freq] = mean_valid(idx_v, p2a_v, frame_cnt);
        valid_frames = preprocess_idx(idx_v, idx_valid, t, frame_cnt);
        sfo = sfo_estimate_period(idx_valid, t, valid_frames, FLEN_PERIOD);

        printf("\n[%3d/%d]: FOUND EARFCN %d Freq. %.2f MHz. "
            "PAR %2.2f dB, CFO=%+.2f KHz, SFO=%+2.3f KHz, CELL_ID=%3d\n", freq, nof_bands,
                channels[freq].id, channels[freq].fd,
                10*log10f(p2a[freq]), cfo[freq] * 15, sfo / 1000, cell_id);
        state = INIT;
        freq++;
        break;
      }
      if (state == TRACK || (state == FIND && frame_cnt)) {
        memcpy(input_buffer, &input_buffer[FLEN], FLEN * sizeof(cf_t));
      }
      frame_cnt++;
    }
  }

  print_to_matlab();

  sync_free(&sfind);
  base_free();

  printf("\n\nDone\n");
  exit(0);
}
示例#28
0
int main(int argc, char **argv) {
  srslte_ra_dl_dci_t ra_dl;
  int i;
  int frame_cnt;
  int ret;
  srslte_dci_location_t locations[MAX_CANDIDATES];
  uint32_t nof_locations;
  srslte_dci_msg_t dci_msg; 

  if (argc < 3) {
    usage(argv[0]);
    exit(-1);
  }

  parse_args(argc,argv);

  if (base_init()) {
    fprintf(stderr, "Error initializing memory\n");
    exit(-1);
  }

  ret = -1;
  frame_cnt = 0;
  do {
    srslte_filesource_read(&fsrc, input_buffer, flen);

    INFO("Reading %d samples sub-frame %d\n", flen, frame_cnt);

    srslte_ofdm_rx_sf(&fft, input_buffer, fft_buffer);

    /* Get channel estimates for each port */
    srslte_chest_dl_estimate(&chest, fft_buffer, ce, frame_cnt %10);
    
    uint16_t crc_rem = 0;
    if (srslte_pdcch_extract_llr(&pdcch, fft_buffer, 
                          ce, srslte_chest_dl_get_noise_estimate(&chest), 
                          frame_cnt %10, cfi)) {
      fprintf(stderr, "Error extracting LLRs\n");
      return -1;
    }
    if (rnti == SRSLTE_SIRNTI) {
      INFO("Initializing common search space for SI-RNTI\n",0);
      nof_locations = srslte_pdcch_common_locations(&pdcch, locations, MAX_CANDIDATES, cfi);
    } else {
      INFO("Initializing user-specific search space for RNTI: 0x%x\n", rnti);
      nof_locations = srslte_pdcch_ue_locations(&pdcch, locations, MAX_CANDIDATES, frame_cnt %10, cfi, rnti); 
    }

    for (i=0;i<nof_locations && crc_rem != rnti;i++) {
      if (srslte_pdcch_decode_msg(&pdcch, &dci_msg, &locations[i], dci_format, &crc_rem)) {
        fprintf(stderr, "Error decoding DCI msg\n");
        return -1;
      }
    }
    
    if (crc_rem == rnti) {
      srslte_dci_msg_type_t type;
      if (srslte_dci_msg_get_type(&dci_msg, &type, cell.nof_prb, rnti)) {
        fprintf(stderr, "Can't get DCI message type\n");
        exit(-1);
      }
      printf("MSG %d: ",i);
      srslte_dci_msg_type_fprint(stdout, type);
      switch(type.type) {
      case SRSLTE_DCI_MSG_TYPE_PDSCH_SCHED:
        bzero(&ra_dl, sizeof(srslte_ra_dl_dci_t));
        if (srslte_dci_msg_unpack_pdsch(&dci_msg, &ra_dl, cell.nof_prb, rnti != SRSLTE_SIRNTI)) {
          fprintf(stderr, "Can't unpack DCI message\n");
        } else {
          srslte_ra_pdsch_fprint(stdout, &ra_dl, cell.nof_prb);
          if (ra_dl.alloc_type == SRSLTE_RA_ALLOC_TYPE2 && ra_dl.type2_alloc.mode == SRSLTE_RA_TYPE2_LOC
              && ra_dl.type2_alloc.riv == 11 && ra_dl.rv_idx == 0
              && ra_dl.harq_process == 0 && ra_dl.mcs_idx == 2) {
            printf("This is the file signal.1.92M.amar.dat\n");
            ret = 0;
          }
        }
        break;
      default:
        fprintf(stderr, "Unsupported message type\n");
        break;
      }

    }

    frame_cnt++;
  } while (frame_cnt <= max_frames);

  base_free();
  exit(ret);
}
void TestQGeoPositionInfoSource::init()
{
    base_init();
}
示例#30
0
fapi2::ReturnCode operation<DEFAULT_MC_TYPE>::multi_port_init_internal()
{
    FAPI_INF("multi-port init internal for %s", mss::c_str(iv_target));


    // Let's assume we are going to send out all subtest unless we are in broadcast mode,
    // where we only send up to 2 subtests under an MCA ( 1 for each DIMM) which is why no const
    auto l_dimms = mss::find_targets<fapi2::TARGET_TYPE_DIMM>(iv_target);

    // Get the port/DIMM information for the addresses. This is an integral value which allows us to index
    // all the DIMM across a controller.
    const uint64_t l_portdimm_start_address = iv_const.iv_start_address.get_port_dimm();
    const uint64_t l_portdimm_end_address = iv_const.iv_end_address.get_port_dimm();

    FAPI_INF("%s start port/dimm: %d end port/dimm: %d", mss::c_str(iv_target), l_portdimm_start_address,
             l_portdimm_end_address);

    // If start address == end address we can handle the single port case simply
    if (l_portdimm_start_address == l_portdimm_end_address)
    {
        // Single port case; simple.
        return single_port_init();
    }

    FAPI_ASSERT( l_portdimm_start_address < l_portdimm_end_address,
                 fapi2::MSS_START_ADDR_BIGGER_THAN_END_ADDR()
                 .set_TARGET(iv_target)
                 .set_START_ADDRESS(l_portdimm_start_address)
                 .set_END_ADDRESS(l_portdimm_end_address),
                 "Start address %d larger than end address %d for %s",
                 l_portdimm_start_address, l_portdimm_end_address, mss::c_str(iv_target));

    // Determine which ports are functional and whether we can broadcast to them
    // If we're in broadcast mode, PRD sends DIMM 0/1 of the first functional and configured port,
    // and we then run all ports in parallel (ports set in subtest config)
    if( mss::mcbist::is_broadcast_capable(iv_target) == mss::YES )
    {
        const auto l_prev_size = l_dimms.size();
        FAPI_TRY( broadcast_mode_start_address_check(iv_target, l_portdimm_start_address, l_dimms) );

        FAPI_INF("Updated %d DIMMs on the MCBIST to %d on the first configured MCA due to broadcast mode for %s",
                 l_prev_size, l_dimms.size(), mss::c_str(iv_target));
    }

    // Configures all subtests under an MCBIST
    // If we're here we know start port < end port. We want to run one subtest (for each DIMM) from start_address
    // to the max range of the start address port, then one subtest (for each DIMM) for each port between the
    // start/end ports and one test (for each DIMM) from the start of the end port to the end address.

    // Setup the address configurations
    FAPI_TRY( multi_port_addr() );

    // We need to do three things here. One is to create a subtest which starts at start address and runs to
    // the end of the port. Next, create subtests to go from the start of the next port to the end of the
    // next port. Last we need a subtest which goes from the start of the last port to the end address specified
    // in the end address. Notice this may mean one subtest (start and end are on the same port) or it might
    // mean two subtests (start is one one port, end is on the next.) Or it might mean three or more subtests.

    // Configure multiport subtests, can be all subtests for the DIMMs under an MCBIST,
    // or just the DIMMs under the first configured MCA if in broadcast mode.
    configure_multiport_subtests(l_dimms);

    // Here's an interesting problem. PRD (and others maybe) expect the operation to proceed in address-order.
    // That is, when PRD finds an address it stops on, it wants to continue from there "to the end." That means
    // we need to keep the subtests sorted, otherwise PRD could pass one subtest come upon a fail in a subsequent
    // subtest and re-test something it already passed. So we sort the resulting iv_subtest vector by port/DIMM
    // in the subtest.
    std::sort(iv_program.iv_subtests.begin(), iv_program.iv_subtests.end(),
              [](const decltype(iv_subtest)& a, const decltype(iv_subtest)& b) -> bool
    {
        const uint64_t l_a_portdimm = (a.get_port() << 1) | a.get_dimm();
        const uint64_t l_b_portdimm = (b.get_port() << 1) | b.get_dimm();

        return l_a_portdimm < l_b_portdimm;
    });

    // Initialize the common sections
    FAPI_TRY( base_init() );

    // And configure broadcast mode if required
    FAPI_TRY(mss::mcbist::configure_broadcast_mode(iv_target, iv_program));

fapi_try_exit:
    return fapi2::current_err;
}