本文整理汇总了C++中compute函数的典型用法代码示例。如果您正苦于以下问题:C++ compute函数的具体用法?C++ compute怎么用?C++ compute使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了compute函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TEST
TEST(ComputeRandomPermutation, ComputeSingle)
{
std::vector<int> expectedData{ 0 };
EXPECT_EQ(expectedData, compute(1));
}
示例2: compute
void HelloWorld::set(double r1_, double r2_)
{
r1 = r1_;
r2 = r2_;
compute(); // compute s
}
示例3: compute
void XListBox::mouseWheelUp(X_Event *event)
{
compute(6);
onPaint(X_UPDATE);
showWidget();
}
示例4: main
//main program
int main(int argc, char *argv[])
{
MPI_Init(&argc, &argv);
int size, rank;
long t1, t2;
static int ranks[1] = { 0 };
MPI_Request request1, request2, request3, request4;
MPI_Status status, status1, status2, status3, status4;
MPI_Group MPI_GROUP_WORLD, grprem;
MPI_Comm commslave, newcomm;
MPI_Comm commsp;
MPI_Comm_group(MPI_COMM_WORLD, &MPI_GROUP_WORLD);
MPI_Group_excl(MPI_GROUP_WORLD, 1, ranks, &grprem);
MPI_Comm_create(MPI_COMM_WORLD, grprem, &commslave);
MPI_Comm_size(MPI_COMM_WORLD, &size);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
printf("Node %d in %d is ready\n", rank, size);
//Initialize
double *grid0 = creat_grid(x_size, y_size, z_size, size, rank, GRID0);
double *grid1 = creat_grid(x_size, y_size, z_size, size, rank, GRID1);
MPI_Barrier(MPI_COMM_WORLD);
if (size != 1)
{
if (rank == 0)
{
for (int i = 1; i < size; i++)
{
int len = (i == size - 1) ? (x_size / (size - 1)) : (x_size / (size - 1) + x_size % (size - 1));
MPI_Isend(grid0 + (i - 1)*x_size / (size - 1), len*y_size*z_size, MPI_DOUBLE, i, i, MPI_COMM_WORLD, &request1);
MPI_Wait(&request1, &status1);
}
}
else
{
for (int i = 1; i < size; i++)
{
if (rank == i)
{
int len = (i == size - 1) ? (x_size / (size - 1)) : (x_size / (size - 1) + x_size % (size - 1));
MPI_Irecv(grid0 + y_size*z_size, len*y_size*z_size, MPI_DOUBLE, 0, i, MPI_COMM_WORLD, &request2);
MPI_Wait(&request2, &status2);
}
}
}
}
//Compute
if (rank == 0) printf("Start computing...\n");
if (rank != 0 && size > 1)
{
for (int t = 0; t < stepnum; t++)
{
compute(grid0, grid1, rank, size);
//send right slice of data to next node, then receieve right slice of data form next node
if (rank < size - 1)
{
MPI_Isend(grid1 + (1 + x_size / (size - 1))*y_size*z_size,
y_size*z_size, MPI_DOUBLE, rank + 1, rank, MPI_COMM_WORLD, &request1);
MPI_Irecv(grid1 + (1 + x_size / (size - 1))*y_size*z_size,
y_size*z_size, MPI_DOUBLE, rank + 1, rank + 1, MPI_COMM_WORLD, &request2);
MPI_Wait(&request1, &status1);
MPI_Wait(&request2, &status2);
}
//receieve left slice of data from perior node, then send left slice of data to perior node
if (rank > 1)
{
MPI_Irecv(grid1, y_size*z_size, MPI_DOUBLE, rank - 1, rank - 1, MPI_COMM_WORLD, &request3);
MPI_Isend(grid1, y_size*z_size, MPI_DOUBLE, rank - 1, rank, MPI_COMM_WORLD, &request4);
MPI_Wait(&request3, &status3);
MPI_Wait(&request4, &status4);
}
double *temp;
temp = grid0;
grid0 = grid1;
grid1 = temp;
MPI_Barrier(commslave);
}
}
else if (size == 1)
{
for (int t = 0; t < stepnum; t++)
{
compute(grid0, grid1, rank, size);
double *temp;
temp = grid0;
grid0 = grid1;
grid1 = temp;
}
}
else { ; }
MPI_Barrier(MPI_COMM_WORLD);
printf("Rank %d finished computing!\n", rank);
//Gather data form nodes to host
if (size != 1)
{
if (stepnum % 2)
{
double *temp;
temp = grid0;
//.........这里部分代码省略.........
示例5: passThrough
void passThrough(int *p) {
use2(p, compute());
// [email protected] {{Passing null pointer value via 1st parameter 'ptr'}}
// [email protected] {{Calling 'use2'}}
}
示例6: __declspec
__declspec(dllexport) long Multiplicate(long arg1, long arg2)
{
return compute(arg1, arg2);
}
示例7: compute
MatrixXf Permutohedral::compute ( const MatrixXf & in, bool reverse ) const
{
MatrixXf r;
compute( r, in, reverse );
return r;
}
示例8: compute
const_shared_ptr<Result> BinaryExpression::compute(const std::uint8_t& left,
const double& right, yy::location left_position,
yy::location right_position) const {
double converted_left = left;
return compute(converted_left, right, left_position, right_position);
}
示例9: compute
SUMOReal
HelpersHBEFA::computeFuel(SUMOEmissionClass c, double v, double a) {
return compute(c, FUEL_OFFSET, v, a) / 790.;
}
示例10: mexFunction
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
int atria_preprocessing_given = 0; // flag wheter preprocessing is already given on command line
long opt_flag = 0; // 0 => eucl.norm, upper triangle matrix, 1 => max.norm, utm, 2 => eucl,full matrix, 3 => max.,full matrix
be_verbose = 0; // Don't spit out feedback to user by default
// try to see if the first parameter given is an atria structure
// If this is true, the order of input parameters is shifted by one
if ((nrhs > 0) && mxIsStruct(prhs[0])) {
atria_preprocessing_given = 1;
prhs++; // these two lines enable us to use the old argument parsing block without changing it
nrhs--;
}
/* check input args */
if (nrhs < 3)
{
mexErrMsgTxt("Correlation sum : Data set of points (row vectors), reference points and relative range (relative to attractor diameter) must be given, number of bins is optional");
return;
}
if (nrhs > 4) opt_flag = (long) *((double *)mxGetPr(prhs[4]));
if (opt_flag & (long) 2)
be_verbose = 0;
if (atria_preprocessing_given) {
#ifdef MATLAB_MEX_FILE
char* metric = 0;
if (mxIsChar(mxGetField(prhs[-1], 0, "optional"))) {
long buflen = (mxGetM(mxGetField(prhs[-1], 0, "optional")) * mxGetN(mxGetField(prhs[-1], 0, "optional"))) + 1;
metric = (char*) mxMalloc(buflen);
mxGetString(mxGetField(prhs[-1], 0, "optional"), metric, buflen);
}
if ((metric == 0) || (!strncmp("euclidian", metric, strlen(metric)))) {
euclidian_distance dummy;
if (be_verbose)
mexPrintf("Using euclidian metric to calculated distances\n");
compute(nlhs, plhs, nrhs, prhs, 1, dummy);
}
else if ((!strncmp("maximum", metric, strlen(metric)))) {
maximum_distance dummy;
if (be_verbose)
mexPrintf("Using maximum metric to calculated distances\n");
compute(nlhs, plhs, nrhs, prhs, 1, dummy);
}
else
printf("ATRIA preprocessing structure was not created using a supported metric; doing preprocessing again\n");
mxFree(metric);
#endif
} else {
if (opt_flag & (long)1) {
maximum_distance dummy;
if (be_verbose)
mexPrintf("Using maximum metric to calculated distances\n");
compute(nlhs, plhs, nrhs, prhs, 0, dummy);
} else {
euclidian_distance dummy;
if (be_verbose)
mexPrintf("Using euclidian metric to calculated distances\n");
compute(nlhs, plhs, nrhs, prhs, 0, dummy);
}
}
}
示例11: compute
/**
* \ingroup Stimulus
* Set the angular aperture of the cylinder in radians
* \param _startAngle Starting angle in radians
* \param _endAngle End angle in radians
**/
void CylinderPointsStimulus::setAperture(double _startAngle, double _endAngle )
{ startAngle = _startAngle;
endAngle = _endAngle;
compute();
}
示例12: compute
void LMMNormalDriftCalculator::compute(const LMMCurveState& cs,
std::vector<Real>& drifts) const {
compute(cs.forwardRates(), drifts);
}
示例13: GetLeft
const_shared_ptr<Result> BinaryExpression::Evaluate(
const shared_ptr<ExecutionContext> context,
const shared_ptr<ExecutionContext> closure) const {
ErrorListRef errors = ErrorList::GetTerminator();
const_shared_ptr<Expression> left = GetLeft();
const_shared_ptr<Expression> right = GetRight();
const_shared_ptr<Result> left_result = left->Evaluate(context, closure);
if (!ErrorList::IsTerminator(left_result->GetErrors())) {
return left_result;
}
const_shared_ptr<Result> right_result = right->Evaluate(context, closure);
if (!ErrorList::IsTerminator(right_result->GetErrors())) {
return right_result;
}
auto left_type_specifier_result = left->GetTypeSpecifier(context);
auto right_type_specifier_result = right->GetTypeSpecifier(context);
errors = left_type_specifier_result.GetErrors();
if (ErrorList::IsTerminator(errors)) {
errors = right_type_specifier_result.GetErrors();
if (ErrorList::IsTerminator(errors)) {
yy::location left_position = left->GetLocation();
yy::location right_position = right->GetLocation();
auto type_table = context->GetTypeTable();
auto left_type = left_type_specifier_result.GetData();
auto right_type = right_type_specifier_result.GetData();
// This logic is essentially a big muxer.
// It works in tandem with C++ type widening to convert operands to the same data type
if (left_type->AnalyzeAssignmentTo(
PrimitiveTypeSpecifier::GetBoolean(), type_table)
== EQUIVALENT) {
bool left_value = *(left_result->GetData<bool>());
if (right_type->AnalyzeAssignmentTo(
PrimitiveTypeSpecifier::GetBoolean(), type_table)
== EQUIVALENT) {
bool right_value = *(right_result->GetData<bool>());
return compute(left_value, right_value, left_position,
right_position);
} else if (right_type->AnalyzeAssignmentTo(
PrimitiveTypeSpecifier::GetByte(), type_table)
== EQUIVALENT) {
auto right_value = *(right_result->GetData<std::uint8_t>());
return compute(left_value, right_value, left_position,
right_position);
} else if (right_type->AnalyzeAssignmentTo(
PrimitiveTypeSpecifier::GetInt(), type_table)
== EQUIVALENT) {
int right_value = *(right_result->GetData<int>());
return compute(left_value, right_value, left_position,
right_position);
} else if (right_type->AnalyzeAssignmentTo(
PrimitiveTypeSpecifier::GetDouble(), type_table)
== EQUIVALENT) {
double right_value = *(right_result->GetData<double>());
return compute(left_value, right_value, left_position,
right_position);
} else if (right_type->AnalyzeAssignmentTo(
PrimitiveTypeSpecifier::GetString(), type_table)
== EQUIVALENT) {
string right_value = *(right_result->GetData<string>());
return compute(left_value, right_value, left_position,
right_position);
} else {
assert(false);
}
} else if (left_type->AnalyzeAssignmentTo(
PrimitiveTypeSpecifier::GetByte(), type_table)
== EQUIVALENT) {
auto left_value = *(left_result->GetData<std::uint8_t>());
if (right_type->AnalyzeAssignmentTo(
PrimitiveTypeSpecifier::GetBoolean(), type_table)
== EQUIVALENT) {
bool right_value = *(right_result->GetData<bool>());
return compute(left_value, right_value, left_position,
right_position);
} else if (right_type->AnalyzeAssignmentTo(
PrimitiveTypeSpecifier::GetByte(), type_table)
== EQUIVALENT) {
auto right_value = *(right_result->GetData<std::uint8_t>());
return compute(left_value, right_value, left_position,
right_position);
} else if (right_type->AnalyzeAssignmentTo(
PrimitiveTypeSpecifier::GetInt(), type_table)
== EQUIVALENT) {
int right_value = *(right_result->GetData<int>());
return compute(left_value, right_value, left_position,
right_position);
} else if (right_type->AnalyzeAssignmentTo(
PrimitiveTypeSpecifier::GetDouble(), type_table)
== EQUIVALENT) {
double right_value = *(right_result->GetData<double>());
return compute(left_value, right_value, left_position,
//.........这里部分代码省略.........
示例14: main
long main()
{
printf("compute=%d\n", compute(1, 2, 3));
}
示例15: log_notice
//.........这里部分代码省略.........
"\tBudget\tUsed Budget\n");
if (data->ind == 0) {
clock_gettime(CLOCK_MONOTONIC, &t_zero);
#ifdef TRACE_SETS_ZERO_TIME
if (opts.ftrace)
log_ftrace(ft_data.marker_fd,
"[%d] sets zero time",
data->ind);
#endif
}
pthread_barrier_wait(&threads_barrier);
/*
* Set the task to SCHED_DEADLINE as far as possible touching its
* budget as little as possible for the first iteration.
*/
if (data->sched_policy == SCHED_DEADLINE) {
ret = sched_setattr(tid, &attr, flags);
if (ret != 0) {
log_critical("[%d] sched_setattr "
"returned %d", data->ind, ret);
errno = ret;
perror("sched_setattr");
exit(EXIT_FAILURE);
}
}
t = t_zero;
t_next = msec_to_timespec(1000LL);
t_next = timespec_add(&t, &t_next);
clock_nanosleep(CLOCK_MONOTONIC,
TIMER_ABSTIME,
&t_next,
NULL);
data->deadline = timespec_add(&t_next, &data->deadline);
while (continue_running) {
int pn;
struct timespec t_start, t_end, t_diff, t_slack, t_resp;
/* Thread numeration reported starts with 1 */
#ifdef TRACE_BEGINS_LOOP
if (opts.ftrace)
log_ftrace(ft_data.marker_fd, "[%d] begins job %d", data->ind+1, i);
#endif
clock_gettime(CLOCK_MONOTONIC, &t_start);
if (data->nphases == 0) {
compute(data->ind, &data->min_et, NULL, 0);
} else {
for (pn = 0; pn < data->nphases; pn++) {
log_notice("[%d] phase %d start", data->ind+1, pn);
exec_phase(data, pn);
log_notice("[%d] phase %d end", data->ind+1, pn);
}
}
clock_gettime(CLOCK_MONOTONIC, &t_end);
t_diff = timespec_sub(&t_end, &t_start);
t_slack = timespec_sub(&data->deadline, &t_end);
t_resp = timespec_sub(&t_end, &t_next);
t_start_usec = timespec_to_usec(&t_start);
if (i < nperiods) {
if (timings)
curr_timing = &timings[i];
else
curr_timing = &tmp_timing;
curr_timing->ind = data->ind;
curr_timing->period = timespec_to_usec(&data->period);
curr_timing->min_et = timespec_to_usec(&data->min_et);
curr_timing->max_et = timespec_to_usec(&data->max_et);
curr_timing->rel_start_time =
t_start_usec - timespec_to_usec(&data->main_app_start);
curr_timing->abs_start_time = t_start_usec;
curr_timing->end_time = timespec_to_usec(&t_end);
curr_timing->deadline = timespec_to_usec(&data->deadline);
curr_timing->duration = timespec_to_usec(&t_diff);
curr_timing->slack = timespec_to_lusec(&t_slack);
curr_timing->resp_time = timespec_to_usec(&t_resp);
}
if (!timings)
log_timing(data->log_handler, curr_timing);
t_next = timespec_add(&t_next, &data->period);
data->deadline = timespec_add(&data->deadline, &data->period);
#ifdef TRACE_END_LOOP
if (opts.ftrace)
log_ftrace(ft_data.marker_fd, "[%d] end loop %d", data->ind, i);
#endif
if (curr_timing->slack < 0)
log_notice("[%d] DEADLINE MISS !!!", data->ind+1);
i++;
}
free(timings);
}