本文整理汇总了C++中oracle函数的典型用法代码示例。如果您正苦于以下问题:C++ oracle函数的具体用法?C++ oracle怎么用?C++ oracle使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了oracle函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: TEST_P
TEST_P(Int32Compare, UsingLoadParam) {
auto param = TRTest::to_struct(GetParam());
char inputTrees[120] = {0};
std::snprintf(inputTrees, 120,
"(method return=Int32 args=[Int32, Int32] "
"(block "
"(ireturn "
"(%s "
"(iload parm=0) "
"(iload parm=1)))))",
param.opcode.c_str());
auto trees = parseString(inputTrees);
ASSERT_NOTNULL(trees);
Tril::DefaultCompiler compiler{trees};
ASSERT_EQ(0, compiler.compile()) << "Compilation failed unexpectedly\n" << "Input trees: " << inputTrees;
auto entry_point = compiler.getEntryPoint<int32_t (*)(int32_t, int32_t)>();
volatile auto exp = param.oracle(param.lhs, param.rhs);
volatile auto act = entry_point(param.lhs, param.rhs);
ASSERT_EQ(exp, act);
}
开发者ID:jduimovich,项目名称:omr,代码行数:25,代码来源:CompareTest.cpp
示例2: TEST_P
TEST_P(DoubleToFloat, UsingConst) {
auto param = TRTest::to_struct(GetParam());
char inputTrees[512] = {0};
std::snprintf(inputTrees, 512,
"(method return=Float"
" (block"
" (freturn"
" (d2f"
" (dconst %f) ) ) ) )",
param.value);
auto trees = parseString(inputTrees);
ASSERT_NOTNULL(trees);
Tril::DefaultCompiler compiler{trees};
ASSERT_EQ(0, compiler.compile()) << "Compilation failed unexpectedly\n" << "Input trees: " << inputTrees;
auto entry_point = compiler.getEntryPoint<float (*)()>();
volatile auto exp = param.oracle(param.value);
volatile auto act = entry_point();
if (std::isnan(exp)) {
ASSERT_EQ(std::isnan(exp), std::isnan(act));
} else {
ASSERT_EQ(exp, act);
}
}
开发者ID:jduimovich,项目名称:omr,代码行数:28,代码来源:TypeConversionTest.cpp
示例3: main
int
main(int argc, char *argv[])
{
if (argc < 4)
errx(1, "not enough arguments");
init_sli();
VexPtr<Oracle> oracle(new Oracle(NULL, NULL, NULL));
VexPtr<StateMachine, &ir_heap> readMachine(readStateMachine(open(argv[1], O_RDONLY)));
VexPtr<StateMachine, &ir_heap> writeMachine(readStateMachine(open(argv[2], O_RDONLY)));
VexPtr<IRExpr, &ir_heap> assumption(readIRExpr(open(argv[3], O_RDONLY)));
bool mightCrash;
bool mightSurvive;
evalCrossProductMachine(readMachine, writeMachine, oracle, assumption,
AllowableOptimisations::defaultOptimisations,
&mightSurvive, &mightCrash, ALLOW_GC);
printf("Might survive %d, might crash %d\n",
mightSurvive, mightCrash);
return 0;
}
开发者ID:sos22,项目名称:SLI,代码行数:25,代码来源:eval_cross_product.cpp
示例4: rebuild
virtual void rebuild () { // insert must not happen at this time
if (flavor == KGRAPH_LINEAR) {
BOOST_VERIFY(indexed_size == 0);
return;
}
if (entries.size() == indexed_size) return;
if (flavor == KGRAPH_LITE) {
indexed_size = 0;
delete kg_index;
kg_index = nullptr;
return;
}
KGraph *kg = nullptr;
if (entries.size() >= min_index_size) {
kg = KGraph::create();
LOG(info) << "Rebuilding index for " << entries.size() << " features.";
IndexOracle oracle(this, index_params_l1);
kg->build(oracle, index_params, NULL);
LOG(info) << "Swapping on new index...";
}
indexed_size = entries.size();
std::swap(kg, kg_index);
if (kg) {
delete kg;
}
}
开发者ID:aaalgo,项目名称:donkey,代码行数:30,代码来源:index-kgraph.cpp
示例5: TEST_P
TEST_P(Int8ToInt32, UsingLoadParam) {
std::string arch = omrsysinfo_get_CPU_architecture();
SKIP_IF(OMRPORT_ARCH_S390 == arch || OMRPORT_ARCH_S390X == arch, KnownBug)
<< "The Z code generator incorrectly spills sub-integer types arguments (see issue #3525)";
auto param = TRTest::to_struct(GetParam());
char *inputTrees =
"(method return=Int32 args=[Int8]"
" (block"
" (ireturn"
" (b2i"
" (bload parm=0) ) ) ) )";
auto trees = parseString(inputTrees);
ASSERT_NOTNULL(trees);
Tril::DefaultCompiler compiler{trees};
ASSERT_EQ(0, compiler.compile()) << "Compilation failed unexpectedly\n" << "Input trees: " << inputTrees;
auto entry_point = compiler.getEntryPoint<int32_t (*)(int8_t)>();
volatile auto exp = param.oracle(param.value);
volatile auto act = entry_point(param.value);
ASSERT_EQ(exp, act);
}
开发者ID:hangshao0,项目名称:omr,代码行数:26,代码来源:TypeConversionTest.cpp
示例6: main
int main()
{
int k[10] = {adventurer, gardens, embargo, village, minion, mine, cutpurse,
sea_hag, tribute, smithy};
int i, n, players, player, handCount, deckCount, seed;
//struct gameState state;
struct gameState state;
player = 0;
n = 0;
srand(time(NULL));
printf("Running Random Adventurer Test\n");
/*
--- Author's Note ---
So, I had problems running out of memory when I used the same gameState variable more than 12 times, and
I honestly don't know why. I momentarily solved this problem by adding more for loops and creating more gamestates;
I was still able to get decent coverage, though not up to the amount of tests I originally had in mind.
*/
for (i = 0; i < MAX_TESTS; i++)
{
players = rand() % 3 + 2;
seed = rand(); //pick random seed
initializeGame(players, k, seed, &state); //initialize Gamestate
//Initiate valid state variables
state.deckCount[player] = rand() % 20; //Pick random deck size out of MAX DECK size
state.discardCount[player] = rand() % 20;
handCount = rand() % 10;
state.hand[0][0] = adventurer;
//Copy state variables
deckCount = state.deckCount[player];
//1 in 3 chance of making empty deck for coverage
if (seed % 3 == 0)
{
state.deckCount[player] = 0;
}
printf("Test: %d\n", i);
oracle(state, deckCount, state.discardCount[0]); //Run adventurer card
}
printf("Tests Complete\n");
return 0;
}
开发者ID:CS362-Winter-2016,项目名称:cs362w16_bowenjos,代码行数:57,代码来源:randomtestadventurer.c
示例7: ComputeLinearTreeLoss
int ComputeLinearTreeLoss(const CState & state,
const vector<CDepTree *> & nodes,
const CIDMap::ACTION_TYPE action) {
CDynamicOracleSearcher oracle(state, nodes);
oracle.InitStackCosts();
oracle.BuildStacks(action);
oracle.ComputeStackCost(action);
return oracle.LossLinearTree();
}
开发者ID:majineu,项目名称:Parser,代码行数:9,代码来源:DynamicOracleTest.cpp
示例8: BestAction
int BestAction(const CState & state, const vector<CDepTree*> & nodes) {
set<CIDMap::ACTION_TYPE> actions;
CDynamicOracleSearcher oracle(state, nodes);
oracle.InitStackCosts();
// oracle.Oracle(0, &actions);
oracle.Oracle(&actions);
vector<double> scores(CIDMap::GetOutcomeNum(), 0.);
return oracle.BestAction(actions, scores);
}
开发者ID:majineu,项目名称:Parser,代码行数:9,代码来源:DynamicOracleTest.cpp
示例9: main
int main(int argc, char **argv)
{
pool p[1] = { pool_create() };
random_init();
/* biases at 16 and 32, so we prefix our 30 byte secret with
* two bytes to start with, up to 17 */
byteblock prefix = { (uint8_t *) "AAAAAAAAAAAAAAAAAA", 2 };
assert(argc == 2);
byteblock secret = from_base64(p, argv[1]);
assert(secret.len == SECRET_LEN);
unsigned counts[SECRET_LEN][256];
memset(counts, 0, sizeof(counts));
while (prefix.len < 18)
{
uint8_t buf[64];
byteblock bb = { buf, 0 };
for (size_t i = 0; i < ROUNDS; i++)
{
oracle(&prefix, &secret, &bb);
if (prefix.len <= 15)
{
/* bias at 16 towards 240 (full) 0 (half) 16 (half) */
uint8_t b16 = buf[15];
counts[15 - prefix.len][b16 ^ 240] += FULL_WEIGHT;
counts[15 - prefix.len][b16 ^ 0] += HALF_WEIGHT;
counts[15 - prefix.len][b16 ^ 16] += HALF_WEIGHT;
}
/* bias at 32 towards 224 (full) 0 (half) 32 (half) */
uint8_t b32 = buf[31];
counts[31 - prefix.len][b32 ^ 224] += FULL_WEIGHT;
counts[31 - prefix.len][b32 ^ 0] += HALF_WEIGHT;
counts[31 - prefix.len][b32 ^ 32] += HALF_WEIGHT;
}
prefix.len++;
byteblock plaintext = recover(p, counts);
printf("guess: %s\n", to_ascii(p, &plaintext));
}
byteblock recovered = recover(p, counts);
printf("message: %s\n", to_ascii(p, &recovered));
p->finish(p);
return 0;
}
开发者ID:ctz,项目名称:cryptopals,代码行数:54,代码来源:mcp56.c
示例10: run_refactor
int run_refactor(optionst &options, messaget::mstreamt &result,
const symbol_tablet &st, const goto_functionst &gf)
{
refactor_preprocessingt preproc(options, st, gf);
refactor_symex_learnt learn_cfg(preproc.get_program());
refactor_symex_verifyt verify_cfg(preproc.get_program());
cegis_symex_learnt<refactor_preprocessingt, refactor_symex_learnt> learn(
options, preproc, learn_cfg);
cegis_symex_verifyt<refactor_symex_verifyt> oracle(options, verify_cfg);
return run_cegis_with_statistics_wrapper(
result, options, learn, oracle, preproc);
}
开发者ID:diffblue,项目名称:cbmc,代码行数:12,代码来源:refactor_runner.cpp
示例11: main
int main() {
int k[10] = {adventurer, gardens, embargo, village, minion, mine, cutpurse,
sea_hag, tribute, smithy};
int i, n, players, player, handCount, deckCount, seed;
//struct gameState state;
struct gameState state;
srand(time(NULL));
player = 0;
n = 1;
printf("Running Random Card Test for Village\n");
for (i = 0; i < MAX_TESTS; i++)
{
players = rand() % 3 + 2;
seed = rand(); //pick random seed
initializeGame(players, k, seed, &state); //initialize Gamestate
//Initiate valid state variables
state.deckCount[player] = rand() % MAX_DECK; //Pick random deck size out of MAX DECK size
state.discardCount[player] = rand() % MAX_DECK;
handCount = rand() % MAX_HAND;
state.hand[0][0] = village;
//Copy state variables
deckCount = state.deckCount[player];
printf("test: %d\n", n);
oracle(state, state.handCount[0], state.discardCount[0], state.numActions); //Run adventurer card
n++;
}
printf("Tests Complete\n");
return 0;
}
开发者ID:CS362-Winter-2016,项目名称:cs362w16_liusop,代码行数:46,代码来源:randomtestcard.c
示例12: rebuild
virtual void rebuild () { // insert must not happen at this time
if (linear) {
indexed_size = entries.size();
return;
}
if (entries.size() == indexed_size) return;
KGraph *kg = nullptr;
if (entries.size() >= min_index_size) {
kg = KGraph::create();
LOG(info) << "Rebuilding index for " << entries.size() << " features.";
IndexOracle oracle(this);
kg->build(oracle, index_params, NULL);
LOG(info) << "Swapping on new index...";
}
indexed_size = entries.size();
std::swap(kg, kg_index);
if (kg) {
delete kg;
}
}
开发者ID:donkey-fart,项目名称:donkey,代码行数:20,代码来源:index-kgraph.cpp
示例13: main
int main() {
// Generate input vectors
double *x = gen_array(ARRAY_SIZE);
double *y = gen_array(ARRAY_SIZE);
double result, answer;
answer = oracle(x, y);
// Test framework that sweeps the number of threads and times each ru
double start_time, run_time;
int num_threads = omp_get_max_threads();
for(int i=1; i<=num_threads; i++) {
omp_set_num_threads(i);
start_time = omp_get_wtime();
for(int j=0; j<REPEAT; j++) {
result = dotp(x,y);
if (result != answer) {
printf("Incorrect dotp %f %f\n", result, answer);
return 0;
}
}
run_time = omp_get_wtime() - start_time;
printf(" %d thread(s) took %f seconds\n",i,run_time);
}
}
开发者ID:cycomachead,项目名称:61c,代码行数:23,代码来源:dotp.c
示例14: main
//.........这里部分代码省略.........
project.readAndResize("edges", beEdges);
std::set<int> nodes;
for (int n : beNodes)
nodes.insert(n);
std::set<std::pair<int, int>> edges;
for (int i = 0; i < beEdges.shape(1); i++)
edges.insert(
std::make_pair(
std::min(beEdges(i, 0), beEdges(i, 1)),
std::max(beEdges(i, 0), beEdges(i, 1))));
for (Crag::NodeIt n(crag); n != lemon::INVALID; ++n)
bestEffort->node[n] = nodes.count(crag.id(n));
for (Crag::EdgeIt e(crag); e != lemon::INVALID; ++e)
bestEffort->edge[e] = edges.count(
std::make_pair(
std::min(crag.id(crag.u(e)), crag.id(crag.v(e))),
std::max(crag.id(crag.u(e)), crag.id(crag.v(e)))));
} else {
LOG_USER(logger::out) << "reading ground-truth" << std::endl;
ExplicitVolume<int> groundTruth;
volumeStore.retrieveGroundTruth(groundTruth);
LOG_USER(logger::out) << "finding best-effort solution" << std::endl;
overlapLoss = new OverlapLoss(crag, groundTruth);
bestEffort = new BestEffort(crag, *overlapLoss);
}
Loss* loss = 0;
bool destructLoss = false;
if (optionLoss.as<std::string>() == "hamming") {
LOG_USER(logger::out) << "using Hamming loss" << std::endl;
loss = new HammingLoss(crag, *bestEffort);
destructLoss = true;
} else if (optionLoss.as<std::string>() == "overlap") {
LOG_USER(logger::out) << "using overlap loss" << std::endl;
if (!overlapLoss) {
LOG_USER(logger::out) << "reading ground-truth" << std::endl;
ExplicitVolume<int> groundTruth;
volumeStore.retrieveGroundTruth(groundTruth);
LOG_USER(logger::out) << "finding best-effort solution" << std::endl;
overlapLoss = new OverlapLoss(crag, groundTruth);
}
loss = overlapLoss;
} else {
LOG_ERROR(logger::out)
<< "unknown loss: "
<< optionLoss.as<std::string>()
<< std::endl;
return 1;
}
if (optionNormalizeLoss) {
LOG_USER(logger::out) << "normalizing loss..." << std::endl;
loss->normalize(crag, MultiCut::Parameters());
}
Oracle oracle(
crag,
nodeFeatures,
edgeFeatures,
*loss,
*bestEffort);
std::vector<double> weights(nodeFeatures.dims() + edgeFeatures.dims(), 0);
optimizer.optimize(oracle, weights);
storeVector(weights, optionFeatureWeights);
if (destructLoss && loss != 0)
delete loss;
if (overlapLoss)
delete overlapLoss;
if (bestEffort)
delete bestEffort;
} catch (boost::exception& e) {
handleException(e, std::cerr);
}
}
开发者ID:jni,项目名称:candidate_mc,代码行数:101,代码来源:train.cpp
示例15: main
//.........这里部分代码省略.........
("db_search_max_missed_cleavages", boost::program_options::value<int>(&db_search_max_missed_cleavages)->default_value(0), "db_search_max_missed_cleavages")
("db_search_max_dynamic_mods", boost::program_options::value<int>(&db_search_max_dynamic_mods)->default_value(0), "db_search_max_dynamic_mods")
("db_search_min_enzymatic_termini", boost::program_options::value<int>(&db_search_min_enzymatic_termini)->default_value(2), "db_search_min_enzymatic_termini")
("db_search_mass_tolerance", boost::program_options::value<double>(&db_search_mass_tolerance)->default_value(.05), "db_search_mass_tolerance")
("db_search_PTM", boost::program_options::value<std::vector<DBPTM> >(&PTMs)->multitoken(), "PTMs")
("db_search_enzyme", boost::program_options::value<std::vector<DBEnzyme>>(&enzymes)->multitoken(), "enzymes")
("db_search_null_lambda", boost::program_options::value<double>(&null_lambda)->default_value(6), "db_search_null_lambda")
("max_ms1_injection_time", boost::program_options::value<double>(&max_ms1_injection_time)->default_value(0.2), "max_ms1_injection_time")
("max_ms2_injection_time", boost::program_options::value<double>(&max_ms2_injection_time)->default_value(0.5), "max_ms2_injection_time")
("ms1_target_total_ion_count", boost::program_options::value<double>(&ms1_target_total_ion_count)->default_value(1e6), "ms1_target_total_ion_count")
("ms2_target_total_ion_count", boost::program_options::value<double>(&ms2_target_total_ion_count)->default_value(1e5), "ms2_target_total_ion_count")
;
boost::program_options::variables_map vm_config;
std::ifstream config_file(param_file_path.c_str());
if(!config_file.is_open()) {
std::cerr << "Unable to open configuration file: " << param_file_path << std::endl;
exit(1);
}
boost::program_options::store(boost::program_options::parse_config_file(config_file, config, true), vm_config);
boost::program_options::notify(vm_config);
//endregion
ElutionShapeSimulator elution_shape_simulator(elution_tau, elution_sigma);
std::unique_ptr<GroundTruthText> db = std::unique_ptr<GroundTruthText>(new GroundTruthText(sqlite_in_path, false));
std::unique_ptr<Instrument> instrument = std::unique_ptr<Instrument>(new Instrument(resolution, dynamic_range, ms1_scan_time, ms2_scan_time,
scan_overhead_time, max_ms1_injection_time,
max_ms2_injection_time, ms1_target_total_ion_count,
ms2_target_total_ion_count));
Sequencer sequencer(fasta_in_path, PTMs, enzymes, db_search_mass_tolerance, db_search_max_missed_cleavages, db_search_min_enzymatic_termini, db_search_min_mass, db_search_max_mass, db_search_max_dynamic_mods, null_lambda);
Oracle oracle(db.get(), instrument.get(), elution_shape_simulator);
MzMLWriter mzml_writer(mzml_out_path);
FidoWriter fido_writer(fido_out_path);
AcquisitionController* controller = get_controller(acquisition_algorithm_name, acquisition_param_values);
int ms1_count = 0;
int ms2_count = 0;
int quality_ms2_count = 0;
double current_time = 0;
std::cout << "Simulating Acquisition:" << std::endl;
while (current_time <= acquisition_length) {
std::unique_ptr<ScanRequest> scan_request = controller->get_scan_request(current_time);
std::unique_ptr<Scan> scan = oracle.get_scan_data(scan_request.get(), current_time);
if (scan->scan_type == Scan::ScanType::MS2) {
ms2_count++;
MS2Scan* tmp_scan = static_cast<MS2Scan*>(scan.get());
sequencer.sequence_ms2_scan(tmp_scan);
if (tmp_scan->probability >= 0 && tmp_scan->peptide != "DECOY") {
fido_writer.write_peptide(tmp_scan->probability, tmp_scan->peptide, tmp_scan->proteins);
if (tmp_scan->probability >= .9) quality_ms2_count++;
}
/*double max_int = 0;
std::string max_pep;
for (auto itr = tmp_scan->peptide2intensity.begin(); itr != tmp_scan->peptide2intensity.end(); ++itr) {
if (itr->second > max_int) {
max_int = itr->second;
max_pep = itr->first;
开发者ID:DennisGoldfarb,项目名称:MSAcquisitionSimulator,代码行数:67,代码来源:mainAcquisitionSimulator.cpp
示例16: main
int main(int argc, char * argv[])
{
srand(time(NULL));
// Let us define a 3 layer perceptron architecture
auto input = gaml::mlp::input<X>(INPUT_DIM, fillInput);
auto l1 = gaml::mlp::layer(input, HIDDEN_LAYER_SIZE, gaml::mlp::mlp_sigmoid(), gaml::mlp::mlp_dsigmoid());
auto l2 = gaml::mlp::layer(l1, HIDDEN_LAYER_SIZE, gaml::mlp::mlp_sigmoid(), gaml::mlp::mlp_dsigmoid());
auto output = gaml::mlp::layer(l2, OUTPUT_DIM, gaml::mlp::mlp_identity(), gaml::mlp::mlp_didentity());
auto mlp = gaml::mlp::perceptron(output, output_of);
// Create a training base
// Let us try to fit a noisy sinc function
Basis basis;
basis.resize(NB_SAMPLES);
for(auto& d: basis)
{
d.first = {{ -10.0 + 20.0 * gaml::random::uniform(0.0, 1.0) }} ;
d.second = noisy_oracle(d.first);
}
// Set up the parameters for learning the MLP with a gradient descent
gaml::mlp::learner::gradient::parameter gradient_params;
gradient_params.alpha = 1e-2;
gradient_params.dalpha = 1e-3;
gradient_params.verbose = true;
// The stopping criteria
gradient_params.max_iter = 10000;
gradient_params.min_dparams = 1e-7;
// Create the learner
auto learning_algorithm = gaml::mlp::learner::gradient::algorithm(mlp, gradient_params, gaml::mlp::loss::Quadratic(), fillOutput);
// Call the learner on the basis and get the learned predictor
auto predictor = learning_algorithm(basis.begin(),
basis.end(),
input_of_data,
output_of_data);
// Print out the structure of the perceptron we learned
std::cout << predictor << std::endl;
// Dump the results
std::ofstream outfile("example-005-samples.data");
for(auto& b: basis)
outfile << b.first[0] << " "
<< b.second[0] << " "
<< std::endl;
outfile.close();
outfile.open("example-005-regression.data");
X x;
for(x[0] = -10; x[0] < 10 ; x[0] += 0.1)
{
auto output = predictor(x);
outfile << x[0] << " "
<< oracle(x)[0] << " "
<< output[0] << std::endl;
}
outfile.close();
std::cout << "You can plot the results using gnuplot :" << std::endl;
std::cout << "gnuplot " << ML_MLP_SHAREDIR << "/plot-example-005.gplot" << std::endl;
std::cout << "This will produce example-005.ps" << std::endl;
// Let us compute the empirical risk.
auto evaluator = gaml::risk::empirical(gaml::mlp::loss::Quadratic());
double risk = evaluator(predictor,
basis.begin(),
basis.end(),
input_of_data,
output_of_data);
std::cout << "Empirical risk = " << risk << std::endl;
// We will use a 6-fold cross-validation to estimate the real risk.
auto kfold_evaluator = gaml::risk::cross_validation(gaml::mlp::loss::Quadratic(),
gaml::partition::kfold(6),
true);
double kfold_risk = kfold_evaluator(learning_algorithm,
basis.begin(),basis.end(),
input_of_data,output_of_data);
std::cout << "Estimation of the real risk (6-fold): "
<< kfold_risk << std::endl;
}
开发者ID:gpichot,项目名称:gaml,代码行数:90,代码来源:example-005-train-gradient.cpp
示例17: noisy_oracle
Y noisy_oracle(X x)
{
Y y = oracle(x);
y[0] += gaml::random::uniform(-0.1, 0.1);
return y;
}
开发者ID:gpichot,项目名称:gaml,代码行数:6,代码来源:example-005-train-gradient.cpp
示例18: layerPair
Pairing * PairGeneratorSector::run(HitCollection & hits, const GeometrySupplement & geomSupplement,
uint nThreads, const TripletConfigurations & layerTriplets, const Grid & grid)
{
std::vector<uint> oracleOffset;
uint totalMaxPairs = 0;
uint nLayerTriplets = layerTriplets.size();
for(uint e = 0; e < grid.config.nEvents; ++e){
for(uint p = 0; p < nLayerTriplets; ++p){
TripletConfiguration layerPair(layerTriplets, p);
LayerGrid layer1(grid, layerPair.layer1(),e);
LayerGrid layer2(grid, layerPair.layer2(),e);
uint nMaxPairs = layer1.size()*layer2.size();
nMaxPairs = 32 * std::ceil(nMaxPairs / 32.0); //round to next multiple of 32
oracleOffset.push_back(totalMaxPairs);
totalMaxPairs += nMaxPairs;
}
}
LOG << "Initializing oracle offsets for pair gen...";
clever::vector<uint, 1> m_oracleOffset(oracleOffset, ctx);
LOG << "done[" << m_oracleOffset.get_count() << "]" << std::endl;
LOG << "Initializing oracle for pair gen...";
clever::vector<uint, 1> m_oracle(0, std::ceil(totalMaxPairs / 32.0), ctx);
LOG << "done[" << m_oracle.get_count() << "]" << std::endl;
LOG << "Initializing prefix sum for pair gen...";
clever::vector<uint, 1> m_prefixSum(0, grid.config.nEvents*nLayerTriplets*nThreads+1, ctx);
LOG << "done[" << m_prefixSum.get_count() << "]" << std::endl;
//ctx.select_profile_event(KERNEL_COMPUTE_EVT());
LOG << "Running pair gen kernel...";
cl_event evt = pairCount.run(
//configuration
layerTriplets.transfer.buffer(Layer1()), layerTriplets.transfer.buffer(Layer2()), grid.config.nLayers,
grid.transfer.buffer(Boundary()),
grid.config.MIN_Z, grid.config.sectorSizeZ(), grid.config.nSectorsZ,
grid.config.MIN_PHI, grid.config.sectorSizePhi(), grid.config.nSectorsPhi,
layerTriplets.transfer.buffer(pairSpreadZ()), layerTriplets.transfer.buffer(pairSpreadPhi()),
// hit input
hits.transfer.buffer(GlobalX()), hits.transfer.buffer(GlobalY()), hits.transfer.buffer(GlobalZ()),
// intermeditate data: oracle for hit pairs, prefix sum for found pairs
m_oracle.get_mem(), m_oracleOffset.get_mem(), m_prefixSum.get_mem(),
//local
local_param(sizeof(cl_uint), (grid.config.nSectorsZ+1)*(grid.config.nSectorsPhi+1)),
//thread config
range(nThreads, nLayerTriplets, grid.config.nEvents),
range(nThreads, 1,1));
PairGeneratorSector::events.push_back(evt);
LOG << "done" << std::endl;
if(PROLIX){
PLOG << "Fetching prefix sum for pair gen...";
std::vector<uint> vPrefixSum(m_prefixSum.get_count());
transfer::download(m_prefixSum,vPrefixSum,ctx);
PLOG << "done" << std::endl;
PLOG << "Prefix sum: ";
for(auto i : vPrefixSum){
PLOG << i << " ; ";
}
PLOG << std::endl;
}
if(PROLIX){
PLOG << "Fetching oracle for pair gen...";
std::vector<uint> oracle(m_oracle.get_count());
transfer::download(m_oracle,oracle,ctx);
PLOG << "done" << std::endl;
PLOG << "Oracle: ";
for(auto i : oracle){
PLOG << i << " ; ";
}
PLOG << std::endl;
}
//Calculate prefix sum
PrefixSum prefixSum(ctx);
evt = prefixSum.run(m_prefixSum.get_mem(), m_prefixSum.get_count(), nThreads, PairGeneratorSector::events);
uint nFoundPairs;
transfer::downloadScalar(m_prefixSum, nFoundPairs, ctx, true, m_prefixSum.get_count()-1, 1, &evt);
if(PROLIX){
PLOG << "Fetching prefix sum for pair gen...";
std::vector<uint> vPrefixSum(m_prefixSum.get_count());
transfer::download(m_prefixSum,vPrefixSum,ctx);
PLOG << "done" << std::endl;
PLOG << "Prefix sum: ";
for(auto i : vPrefixSum){
PLOG << i << " ; ";
//.........这里部分代码省略.........
开发者ID:JuantAldea,项目名称:trax,代码行数:101,代码来源:PairGeneratorSector.cpp
示例19: GetYearDayIndex
SqlVal GetYearDayIndex(const SqlVal& date)
{
SqlVal mssql("substring(convert(varchar(max), " + ~date + ", 1), 1, 5)", SqlS::FN);
SqlVal oracle(SqlFunc("to_char", date, "MM/DD"));
return SqlVal(SqlCode(MSSQL, ~mssql)(~oracle), SqlS::FN);
}
开发者ID:ultimatepp,项目名称:mirror,代码行数:6,代码来源:util.cpp
示例20: calculerRound
void calculerRound(int nRound, int pv, int pvEnnemis, int pillz, int pillzEnnemis, bool determinQuiEstTeste, int carteEnnemieEnvoyee, int dernierRoundACalculer) {
int pillzRestants, pillzEnnemisRestants;
bool jeGagne = false;
if (nRound == 5 || pvEnnemis <= 0 || pv <= 0) { // Combat terminé
if (pv <= 0 && pvEnnemis <= 0)
rajouterEgalites();
else if (pv > pvEnnemis)
rajouterVictoires();
else if (pv < pvEnnemis)
rajouterDefaites();
else
rajouterEgalites();
}
else {
if (nRound == dernierRoundACalculer+1) {
if (furyUtilisee) {
carteAlliee[persoTest].guessedScoreFury[pillzTest] += oracle(pv, pillz, pvEnnemis, pillzEnnemis);
} else {
carteAlliee[persoTest].guessedScore[pillzTest] += oracle(pv, pillz, pvEnnemis, pillzEnnemis);
}
return;
}
for (int i = 0 ; i < 4 ; i++) { // Pour chaque carte alliée
if (!carteAlliee[i].supposeeUtilisee && !carteAlliee[i].utiliseeACoupSur) { // ne continuer que si elle n'est pas supposée utilisée, ni pour de bon
if (determinQuiEstTeste)
persoTest = i;
carteAlliee[i].supposeeUtilisee = true; // la supposer utilisée
for (int j = 0 ; j < 4 ; j++) { // Pour chaque carte ennemie
if (!carteEnnemie[j].supposeeUtilisee && !carteEnnemie[j].utiliseeACoupSur) { // ne continuer que si elle n'est pas supposée utilisée, ni pour de bon
if (!(determinQuiEstTeste && carteEnnemieEnvoyee >= 0 && carteEnnemieEnvoyee <= 3) || j == carteEnnemieEnvoyee) { // En simplifiant par la logique, on obtient ça
//TODO vérifier la condition, elle est bizarre, et mettre un commentaire qui résume mieux celle-ci. De plus, "compris entre 0 et 3", ça veut dire "différent de -1", non ?
// on ne continue que si j = la carte ennemie envoyée à coup sûr, ou qu'on s'en fout (= on teste toutes celles qui restent)
carteEnnemie[j].supposeeUtilisee = true;
for (int k = 0 ; k <= pillz ; k++) {// Pour chaque pillz
pillzRestants = pillz - k;
if (determinQuiEstTeste)
pillzTest = k;
for (int l = 0 ; l <= pillzEnnemis ; l++) { // Pour chaque pillz ennemi
pillzEnnemisRestants = pillzEnnemis - l;
jeGagne = jeRemporteLeRound(carteAlliee[i].combatAvecXPillzContreYAvecZpillz[k][j][l], nRound);
modifPillzPvEtRoundSuivant(pv, pvEnnemis, pillzRestants, pillzEnnemisRestants, i, j, nRound, jeGagne, false, false, dernierRoundACalculer);
if (pillzRestants >= 3) {
if (determinQuiEstTeste)
furyUtilisee = true;
modifPillzPvEtRoundSuivant(pv, pvEnnemis, pillzRestants - 3, pillzEnnemisRestants , i, j, nRound, jeGagne, true, false, dernierRoundACalculer);
if (pillzEnnemisRestants >= 3)
modifPillzPvEtRoundSuivant(pv, pvEnnemis, pillzRestants - 3, pillzEnnemisRestants - 3, i, j, nRound, jeGagne, true, true, dernierRoundACalculer);
if (determinQuiEstTeste)
furyUtilisee = false;
}
if (pillzEnnemisRestants >= 3)
modifPillzPvEtRoundSuivant(pv, pvEnnemis, pillzRestants, pillzEnnemisRestants - 3, i, j, nRound, jeGagne, false, true, dernierRoundACalculer);
}
}
carteEnnemie[j].supposeeUtilisee = false; //desupposer
}
}
}
carteAlliee[i].supposeeUtilisee = false; // desupposer
}
}
}
}
开发者ID:LogicalKip,项目名称:CUR,代码行数:72,代码来源:fonctionsBoucles.cpp
注:本文中的oracle函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论