int main() { boost::signal2<void, int, int> sig; sig.connect(print_sum()); sig.connect(print_product()); sig(3, 5); boost::signals::connection print_diff_con = sig.connect(print_difference()); // sig is still connected to print_diff_con assert(print_diff_con.connected()); sig(5, 3); // prints 8, 15, and 2 print_diff_con.disconnect(); // disconnect the print_difference slot sig(5, 3); // now prints 8 and 15, but not the difference assert(!print_diff_con.connected()); // not connected any more { boost::signals::scoped_connection c = sig.connect(print_quotient()); sig(5, 3); // prints 8, 15, and 1 } // c falls out of scope, so sig and print_quotient are disconnected sig(5, 3); // prints 8 and 15 return 0; }
static void Test_alpha_epsilon(void) { printf("\n** Test_alpha_epsilon: **\n"); const REAL8 f = 0.01; const REAL8 q = 4; const REAL8 chil = 0.5625; const REAL8 chip = 0.18; NNLOanglecoeffs angcoeffs; ComputeNNLOanglecoeffs(&angcoeffs,q,chil,chip); const REAL8 omega = LAL_PI * f; const REAL8 logomega = log(omega); const REAL8 omega_cbrt = cbrt(omega); const REAL8 omega_cbrt2 = omega_cbrt*omega_cbrt; const REAL8 alpha = (angcoeffs.alphacoeff1/omega + angcoeffs.alphacoeff2/omega_cbrt2 + angcoeffs.alphacoeff3/omega_cbrt + angcoeffs.alphacoeff4*logomega + angcoeffs.alphacoeff5*omega_cbrt); const REAL8 epsilon = (angcoeffs.epsiloncoeff1/omega + angcoeffs.epsiloncoeff2/omega_cbrt2 + angcoeffs.epsiloncoeff3/omega_cbrt + angcoeffs.epsiloncoeff4*logomega + angcoeffs.epsiloncoeff5*omega_cbrt); const REAL8 alpha_expected = -11.8196; const REAL8 epsilon_expected = -11.936; print_difference("alpha", alpha, alpha_expected); print_difference("epsilon", epsilon, epsilon_expected); const REAL8 eps = 1e-5; assert( approximatelyEqual(alpha, alpha_expected, eps) && approximatelyEqual(epsilon, epsilon_expected, eps) && "Test_alpha_epsilon()" ); }
void find_ptimer_b12(int cnum) { uint8_t signals_ref_timer[0x100 * 8]; uint8_t signals_tmp[0x100 * 8]; struct signals_comparaison diffs; int i; uint32_t r_9210, r_9400; printf("<PTIMER_B12>\n"); r_9210 = nva_rd32(cnum, 0x9210); r_9400 = nva_rd32(cnum, 0x9400); /* stop the time */ nva_wr32(cnum, 0x9210, 0); nva_wr32(cnum, 0x9400, 0); poll_signals(cnum, signals_ref_timer); nva_wr32(cnum, 0x9400, 0x20000); poll_signals(cnum, signals_tmp); /* restore ptimer */ nva_wr32(cnum, 0x9400, r_9400); nva_wr32(cnum, 0x9210, r_9210); diffs = signals_compare(signals_ref_timer, signals_tmp); if (diffs.diff_count >= 1) { for (i = 0; i < diffs.diff_count; i++) { uint8_t set, signal; set = diffs.differences[i].set; signal = diffs.differences[i].signal; if (diffs.differences[i].set == 0) { if (diffs.differences[i].change == ZERO_TO_ONE) printf("PTIMER_B12: Set %u, signal 0x%.2x\n", set, signal); } else { printf("Unexpected difference: "); print_difference(diffs.differences[i]); } } } else printf("Not found.\n"); signals_comparaison_free(diffs); printf("</PTIMER_B12>\n\n"); }
void find_ctxCtlFlags(int cnum) { uint8_t signals_ref_ctx[0x100 * 8]; uint8_t signals_tmp[0x100 * 8]; struct signals_comparaison diffs; int bit, i; uint32_t r_400824 = nva_rd32(cnum, 0x400824); printf("<CTXCTL FLAGS>\n"); nva_mask(cnum, 0x400824, 0xf0000000, 0); poll_signals(cnum, signals_ref_ctx); for (bit = 28; bit < 32; bit++) { nva_mask(cnum, 0x400824, 0xf0000000, 1 << bit); poll_signals(cnum, signals_tmp); diffs = signals_compare(signals_ref_ctx, signals_tmp); if (diffs.diff_count >= 1) { for (i = 0; i < diffs.diff_count; i++) { uint8_t set, signal; set = diffs.differences[i].set; signal = diffs.differences[i].signal; if (diffs.differences[i].set == 1) { if (diffs.differences[i].change == ZERO_TO_ONE) printf("CTXCTL flag 0x%.2x: Set %u, signal 0x%.2x\n", bit, set, signal); } else { printf("Unexpected difference: "); print_difference(diffs.differences[i]); } } } else printf("Not found. Please re-run when the GPU is idle.\n"); signals_comparaison_free(diffs); } nva_wr32(cnum, 0x400824, r_400824); printf("</CTXCTL FLAGS>\n\n"); }
int main() { boost::signal2<void, int, int> sig; sig.connect(print_sum()); sig.connect(print_product()); sig(3, 5); boost::signals::connection print_diff_con = sig.connect(print_difference()); // sig is still connected to print_diff_con assert(print_diff_con.connected()); sig(5, 3); // prints 8, 15, and 2 print_diff_con.disconnect(); // disconnect the print_difference slot sig(5, 3); // now prints 8 and 15, but not the difference assert(!print_diff_con.connected()); // not connected any more return 0; }
static void Test_XLALSimIMRPhenomPCalculateModelParameters(void) { printf("\n** Test_XLALSimIMRPhenomPCalculateModelParameters: **\n"); REAL8 eta, chi_eff, chip, thetaJ, phiJ, alpha0; REAL8 m1_SI = 10 * LAL_MSUN_SI; REAL8 m2_SI = 40 * LAL_MSUN_SI; REAL8 s1x = 0.3; REAL8 s1y = 0; REAL8 s1z = 0.45; REAL8 s2x = 0; REAL8 s2y = 0; REAL8 s2z = 0.45; REAL8 lnhatx = sin(0.4); REAL8 lnhaty = 0; REAL8 lnhatz = cos(0.4); REAL8 f_min = 20; XLALSimIMRPhenomPCalculateModelParameters( &chi_eff, /**< Output: Effective aligned spin */ &chip, /**< Output: Effective spin in the orbital plane */ &eta, /**< Output: Symmetric mass-ratio */ &thetaJ, /**< Output: Angle between J0 and line of sight (z-direction) */ &phiJ, /**< Output: Angle of J0 in the plane of the sky */ &alpha0, /**< Output: Initial value of alpha angle */ m1_SI, /**< Mass of companion 1 (kg) */ m2_SI, /**< Mass of companion 2 (kg) */ f_min, /**< Starting GW frequency (Hz) */ lnhatx, /**< Initial value of LNhatx: orbital angular momentum unit vector */ lnhaty, /**< Initial value of LNhaty */ lnhatz, /**< Initial value of LNhatz */ s1x, /**< Initial value of s1x: dimensionless spin of larger BH */ s1y, /**< Initial value of s1y: dimensionless spin of larger BH */ s1z, /**< Initial value of s1z: dimensionless spin of larger BH */ s2x, /**< Initial value of s2x: dimensionless spin of larger BH */ s2y, /**< Initial value of s2y: dimensionless spin of larger BH */ s2z); /**< Initial value of s2z: dimensionless spin of larger BH */ REAL8 eta_expected = 0.16; REAL8 chi_eff_expected = 0.437843; REAL8 chip_expected = 0.175238; REAL8 thetaJ_expected = 0.298553; REAL8 phiJ_expected = 0; REAL8 alpha0_expected = 0; print_difference("eta", eta, eta_expected); print_difference("chi_eff", chi_eff, chi_eff_expected); print_difference("chip", chip, chip_expected); print_difference("thetaJ", thetaJ, thetaJ_expected); print_difference("phiJ", phiJ, phiJ_expected); print_difference("alpha0", alpha0, alpha0_expected); //const REAL8 eps = DBL_EPSILON; const REAL8 eps = 1e-5; assert( approximatelyEqual(eta, eta_expected, eps) && approximatelyEqual(chi_eff, chi_eff_expected, eps) && approximatelyEqual(chip, chip_expected, eps) && approximatelyEqual(thetaJ, thetaJ_expected, eps) && approximatelyEqual(phiJ, phiJ_expected, eps) && approximatelyEqual(alpha0, alpha0_expected, eps) && "Test_XLALSimIMRPhenomPCalculateModelParameters()" ); }
void find_pgraphIdle_and_interrupt(int cnum) { unsigned char signals_idle[0x100 * 8]; struct signals_comparaison diffs; int i; uint32_t r_400500, r_400808, r_40013c; printf("<PGRAPH_IDLE/INTERRUPT> /!\\ no drivers should be loaded!\n"); /* safety check: */ if (nva_rd32(cnum, 0x140) == 1) { printf("You shouldn't run this tool while a driver is running\n"); goto error; } /* reboot PGRAPH */ nva_mask(cnum, 0x200, 0x00201000, 0x00000000); nva_mask(cnum, 0x200, 0x00201000, 0x00201000); r_400500 = nva_rd32(cnum, 0x400500); r_400808 = nva_rd32(cnum, 0x400808); r_40013c = nva_rd32(cnum, 0x40013c); /* generate an illegal method IRQ * that will pull the PGRAP_IDLE signal down and the PGRAPH_INTERRUPT up * * neither nouveau or nvidia should be loaded as they would ack the interrupt * straight away. */ nva_wr32(cnum, 0x400500, 0x10001); nva_wr32(cnum, 0x400808, 0xa00000fc); nva_wr32(cnum, 0x40013c, 0xffffffff); poll_signals(cnum, signals_idle); diffs = signals_compare(signals_ref, signals_idle); if (diffs.diff_count >= 1) { for (i = 0; i < diffs.diff_count; i++) { uint8_t set, signal; set = diffs.differences[i].set; signal = diffs.differences[i].signal; if (diffs.differences[i].set == 1) { if (diffs.differences[i].change == ONE_TO_ZERO) printf("PGRAPH_IDLE: Set %u, signal 0x%.2x\n", set, signal); else if (diffs.differences[i].change == ZERO_TO_ONE) printf("PGRAPH_INTERRUPT: Set %u, signal 0x%.2x\n", set, signal); } else { printf("Unexpected difference: "); print_difference(diffs.differences[i]); } } signals_comparaison_free(diffs); } else printf("Not found. Please re-run when the GPU is idle.\n"); /* restore our mess */ nva_wr32(cnum, 0x400500, r_400500); nva_wr32(cnum, 0x400808, r_400808); nva_wr32(cnum, 0x40013c, r_40013c); /* ACK all PGRAPH's interrupts */ nva_wr32(cnum, 0x400100, 0xffffffff); error: printf("</PGRAPH_IDLE/INTERRUPT>\n\n"); }
int master(workorder_t *w) { int rc; int i; int thr_count; int nthr, nproc; int id; int goodbye_timeout = UPERF_GOODBYE_TIMEOUT; hrtime_t start, stop; uperf_shm_t *shm; goodbye_stat_t gtotal; int error; if ((shm = master_init(w)) == NULL) exit(1); /* * We need to get the total number of threads to arm the * start, and end barriers. */ nproc = workorder_num_strands_bytype(w, STRAND_TYPE_PROCESS); nthr = workorder_num_strands_bytype(w, STRAND_TYPE_THREAD); thr_count = nproc + nthr; if (handshake(shm, w) != UPERF_SUCCESS) { uperf_info("Error in handshake\n"); shm_fini(shm); exit(1); } if (nthr == 0 && nproc != 0) { (void) printf("Starting %d processes running profile:%s ... ", thr_count, w->name); } else if (nproc == 0 && nthr != 0) { (void) printf("Starting %d threads running profile:%s ... ", thr_count, w->name); } else { (void) printf( "Starting %d threads, %d processes running profile:%s ... ", nthr, nproc, w->name); } (void) fflush(stdout); start = GETHRTIME(); /* Traverse through the worklist and create threads */ id = 0; for (i = 0; i < w->ngrp; i++) { w->grp[i].groupid = i; if (shm->global_error > 0) break; if (spawn_strands_group(shm, &w->grp[i], id) != 0) shm->global_error++; id += w->grp[i].nthreads; } if (shm->global_error > 0) { master_prepare_to_exit(shm); shm_fini(shm); return (UPERF_FAILURE); } stop = GETHRTIME(); (void) printf(" %5.2f seconds\n", (stop-start)/1.0e+9); (void) fflush(stdout); /* Handshake end */ if (handshake_end_master(shm, w) != UPERF_SUCCESS) { return (UPERF_FAILURE); } #ifdef ENABLE_NETSTAT if (ENABLED_PACKET_STATS(options)) netstat_snap(SNAP_BEGIN); #endif /* ENABLE_NETSTAT */ /* * The main Loop. * if either global_error is not 0 or master_poll returns 1 * let wait_for_strands know that. */ newstat_begin(0, AGG_STAT(shm), 0, 0); error = master_poll(shm); if (error == 0 && shm->global_error != 0) error = shm->global_error; (void) wait_for_strands(shm, error); newstat_end(0, AGG_STAT(shm), 0, 0); shm->current_time = GETHRTIME(); #ifdef ENABLE_NETSTAT if (ENABLED_PACKET_STATS(options)) netstat_snap(SNAP_END); #endif /* ENABLE_NETSTAT */ if (ENABLED_STATS(options)) { print_summary(AGG_STAT(shm), 0); } if (shm->global_error > 0) { /* decrease timeout coz no point in waiting */ goodbye_timeout = 1000; } if (ENABLED_GROUP_STATS(options)) print_group_details(shm); if (ENABLED_THREAD_STATS(options)) print_strand_details(shm); if (ENABLED_TXN_STATS(options)) print_txn_averages(shm); if (ENABLED_FLOWOP_STATS(options)) print_flowop_averages(shm); #ifdef ENABLE_NETSTAT if (ENABLED_PACKET_STATS(options)) print_netstat(); #endif /* ENABLE_NETSTAT */ if (ENABLED_ERROR_STATS(options)) { goodbye_stat_t local; (void) memset(>otal, 0, sizeof (goodbye_stat_t)); if ((rc = say_goodbyes_and_close(>otal, goodbye_timeout)) == 0) { update_aggr_stat(shm); local.elapsed_time = (AGG_STAT(shm))->end_time - (AGG_STAT(shm))->start_time; local.error = 0; local.bytes_xfer = (AGG_STAT(shm))->size; local.count = (AGG_STAT(shm))->count; print_goodbye_stat("master", &local); print_difference(local, gtotal); } } uperf_log_flush(); if (ENABLED_HISTORY_STATS(options)) { (void) fclose(options.history_fd); } /* Cleanup */ if (shm->global_error != 0) { (void) printf("\nWARNING: Errors detected during run\n"); shm_fini(shm); exit(1); } shm_fini(shm); return (rc); }