id stringlengths 26 28 | content stringlengths 1.06k 5.5k |
|---|---|
pareval_translation_data_1 | #include <omp.h>
struct Point {
double x, y;
};
double triangleArea(Point const& A, Point const& B, Point const& C) {
return 0.5 * std::abs( A.x*(B.y-C.y) + B.x*(C.y-A.y) + C.x*(A.y-B.y) );
}
/* Return the area of the smallest triangle that can be formed by any 3 points.
Use OpenMP to compute in parallel.
E... |
pareval_translation_data_2 | #include <omp.h>
double distance(double x1, double x2) {
return std::abs(x1 - x2);
}
/* Return the distance between the closest two elements in the vector x.
Use OpenMP to compute in parallel.
Example:
input: [7, 3, 9, 12, 31, 1]
output: 2
*/
double closestPair(std::vector<double> const& x) {
double d... |
pareval_translation_data_3 | #include <omp.h>
struct Point {
double x, y;
};
double distance(Point const& p1, Point const& p2) {
return std::sqrt(std::pow(p2.x-p1.x, 2) + std::pow(p2.y-p1.y, 2));
}
/* Return the distance between the closest two points in the vector points.
Use OpenMP to compute in parallel.
Example:
input: [{2, 3},... |
pareval_translation_data_4 | #include <omp.h>
/* Return the number of vertices in the largest component of the undirected graph defined by the adjacency matrix A.
A is an NxN adjacency matrix stored in row-major. A is an undirected graph.
Use OpenMP to compute in parallel.
Example:
input: [[0, 1, 0, 0], [1, 0, 0, 0], [0, 0, 0, 1], [0,... |
pareval_translation_data_5 | #include <omp.h>
/* Count the number of connected components in the undirected graph defined by the adjacency matrix A.
A is an NxN adjacency matrix stored in row-major. A is an undirected graph.
Use OpenMP to compute in parallel.
Example:
input: [[0, 1, 0, 0], [1, 0, 0, 0], [0, 0, 0, 1], [0, 0, 1, 0]]
o... |
pareval_translation_data_6 | #include <omp.h>
/* Count the number of edges in the directed graph defined by the adjacency matrix A.
A is an NxN adjacency matrix stored in row-major. A represents a directed graph.
Use OpenMP to compute in parallel.
Example:
input: [[0, 0, 0, 1], [0, 0, 0, 1], [0, 0, 0, 1], [1, 1, 1, 0]]
output: 3
*/... |
pareval_translation_data_7 | #include <omp.h>
/* Compute the highest node degree in the undirected graph. The graph is defined in the adjacency matrix A.
A is an NxN adjacency matrix stored in row-major. A is an undirected graph.
Use OpenMP to compute in parallel.
Example:
input: [[0, 0, 0, 1], [0, 0, 0, 1], [0, 0, 0, 1], [1, 1, 1, 0]... |
pareval_translation_data_8 | #include <omp.h>
/* Return the length of the shortest path from source to dest in the undirected graph defined by the adjacency matrix A.
A is an NxN adjacency matrix stored in row-major. A is an undirected graph.
Use OpenMP to compute in parallel.
Example:
input: [[0, 1, 1, 0], [1, 0, 0, 1], [1, 0, 0, 1],... |
pareval_translation_data_9 | #include <omp.h>
/* Return the value of the smallest odd number in the vector x.
Use OpenMP to compute in parallel.
Examples:
input: [7, 9, 5, 2, 8, 16, 4, 1]
output: 1
input: [8, 36, 7, 2, 11]
output: 7
*/
int smallestOdd(std::vector<int> const& x) {
/* Return the value of the smallest odd number... |
pareval_translation_data_10 | #include <omp.h>
/* Return the product of the vector x with every odd indexed element inverted.
i.e. x_0 * 1/x_1 * x_2 * 1/x_3 * x_4 ...
Use OpenMP to compute product in parallel.
Example:
input: [4, 2, 10, 4, 5]
output: 25
*/
double productWithInverses(std::vector<double> const& x) {
/* Return the pr... |
pareval_translation_data_11 | #include <omp.h>
/* Return the sum of the minimum value at each index of vectors x and y for all indices.
i.e. sum = min(x_0, y_0) + min(x_1, y_1) + min(x_2, y_2) + ...
Use OpenMP to sum in parallel.
Example:
input: x=[3, 4, 0, 2, 3], y=[2, 5, 3, 1, 7]
output: 10
*/
double sumOfMinimumElements(std::vec... |
pareval_translation_data_12 | #include <omp.h>
/* Return the average of the vector x.
Use OpenMP to compute in parallel.
Examples:
input: [1, 8, 4, 5, 1]
output: 3.8
input: [2, 2, 2, 3]
output: 2.25
*/
double average(std::vector<double> const& x) {
/* Return the average of the vector x.
Examples:
input: [1, 8, 4, 5, 1... |
pareval_translation_data_13 | #include <omp.h>
/* Return the logical XOR reduction of the vector of bools x.
Use OpenMP to reduce in parallel.
Example:
input: [false, false, false, true]
output: true
*/
bool reduceLogicalXOR(std::vector<bool> const& x) {
/* Return the logical XOR reduction of the vector of bools x.
Example:
in... |
pareval_translation_data_14 | #include <omp.h>
/* Compute the prefix sum array of the vector x and return its sum.
Use OpenMP to compute in parallel.
Example:
input: [-7, 2, 1, 9, 4, 8]
output: 15
*/
double sumOfPrefixSum(std::vector<double> const& x) {
/* Compute the prefix sum array of the vector x and return its sum.
Example:
... |
pareval_translation_data_15 | #include <omp.h>
/* Replace the i-th element of the vector x with the minimum value from indices 0 through i.
Use OpenMP to compute in parallel.
Examples:
input: [8, 6, -1, 7, 3, 4, 4]
output: [8, 6, -1, -1, -1, -1, -1]
input: [5, 4, 6, 4, 3, 6, 1, 1]
output: [5, 4, 4, 4, 3, 3, 1, 1]
*/
void partia... |
pareval_translation_data_16 | #include <omp.h>
/* Compute the prefix sum of the vector x into output.
Use OpenMP to compute in parallel.
Example:
input: [1, 7, 4, 6, 6, 2]
output: [1, 8, 12, 18, 24, 26]
*/
void prefixSum(std::vector<double> const& x, std::vector<double> &output) {
/* Compute the prefix sum of the vector x into out... |
pareval_translation_data_17 | #include <omp.h>
/* In the vector x negate the odd values and divide the even values by 2.
Use OpenMP to compute in parallel.
Example:
input: [16, 11, 12, 14, 1, 0, 5]
output: [8, -11, 6, 7, -1, 0, -5]
*/
void negateOddsAndHalveEvens(std::vector<int> &x) {
/* In the vector x negate the odd values and div... |
pareval_translation_data_18 | #include <omp.h>
bool isPowerOfTwo(int x) {
return (x > 0) && !(x & (x - 1));
}
/* Apply the isPowerOfTwo function to every value in x and store the results in mask.
Use OpenMP to compute in parallel.
Example:
input: [8, 0, 9, 7, 15, 64, 3]
output: [true, false, false, false, false, true, false]
*/
void... |
pareval_translation_data_19 | #include <omp.h>
/* Replace every element of the vector x with 1-1/x.
Use OpenMP to compute in parallel.
Example:
input: [2, 4, 1, 12, -2]
output: [0.5, 0.75, 0, 0.91666666, 1.5]
*/
void oneMinusInverse(std::vector<double> &x) {
/* Replace every element of the vector x with 1-1/x.
Example:
input: ... |
pareval_translation_data_20 | #include <omp.h>
/* Compute the ReLU function on every element of x. Elements less than zero become zero,
while elements greater than zero stay the same.
Use OpenMP to compute in parallel.
Example:
input: [-1.8, 24.0, 1.2, 0.0, -5.1, -0.2, 4.5]
output: [0, 24.0, 1.2, 0, 0, 0, 4.5]
*/
void relu(std::vec... |
pareval_translation_data_21 | #include <omp.h>
/* Replace every element of x with the square of its value.
Use OpenMP to compute in parallel.
Example:
input: [5, 1, 2, -4, 8]
output: [25, 1, 4, 16, 64]
*/
void squareEach(std::vector<int> &x) {
/* Replace every element of x with the square of its value.
Example:
input: [5, 1, 2... |
pareval_translation_data_22 | #include <omp.h>
struct COOElement {
size_t row, column;
double value;
};
/* Compute y = alpha*A*x + beta*y where alpha and beta are scalars, x and y are vectors,
and A is a sparse matrix stored in COO format.
A has dimensions MxN, x has N values, and y has M values.
Use OpenMP to parallelize.
Examp... |
pareval_translation_data_23 | #include <omp.h>
struct COOElement {
size_t row, column;
double value;
};
/* Compute the matrix multiplication Y=AX. A is a sparse MxK matrix in COO format.
X is a sparse KxN matrix in COO format. Y is a dense MxN matrix in row-major.
Use OpenMP to compute in parallel.
Example:
input: A=[{0,0,-2}, ... |
pareval_translation_data_24 | #include <omp.h>
struct COOElement {
size_t row, column;
double value;
};
/* Factorize the sparse matrix A into A=LU where L is a lower triangular matrix and U is an upper triangular matrix.
A is a sparse NxN matrix stored in COO format.
Use OpenMP to compute in parallel.
Example:
input: A=[{0,0,4}... |
pareval_translation_data_25 | #include <omp.h>
/* For each letter in the alphabet, count the number of strings in the vector s that start with that letter.
Assume all strings are in lower case. Store the output in `bins` array.
Use OpenMP to compute in parallel.
Example:
input: ["dog", "cat", "xray", "cow", "code", "type", "flower"]
... |
pareval_translation_data_26 | #include <omp.h>
/* Vector x contains values between 0 and 100, inclusive. Count the number of
values in [0,10), [10, 20), [20, 30), ... and store the counts in `bins`.
Use OpenMP to compute in parallel.
Example:
input: [7, 32, 95, 12, 39, 32, 11, 71, 70, 66]
output: [1, 2, 0, 3, 0, 0, 1, 2, 0, 1]
*/
v... |
pareval_translation_data_27 | #include <omp.h>
struct Point {
double x, y;
};
/* Count the number of cartesian points in each quadrant. The vector points contains a list of `Point` objects.
Store the counts in `bins`.
Use OpenMP to count in parallel.
Example:
input: [{x=1.5, y=0.1}, {x=-3, y=1.1}, {x=5, y=9}, {x=1.5, y=-1}, {x=3, ... |
pareval_translation_data_28 | #include <omp.h>
/* Count the number of doubles in the vector x that have a fractional part
in [0, 0.25), [0.25, 0.5), [0.5, 0.75), and [0.75, 1). Store the counts in `bins`.
Use OpenMP to compute in parallel.
Examples:
input: [7.8, 4.2, 9.1, 7.6, 0.27, 1.5, 3.8]
output: [2, 1, 2, 2]
input: [1.9, ... |
pareval_translation_data_29 | #include <omp.h>
/* Count the number of pixels in image with each grayscale intensity.
The vector `image` is a grayscale image with values 0-255.
Store the results in `bins`.
Use OpenMP to count in parallel.
Example:
input: image=[2, 116, 201, 11, 92, 92, 201, 4, 2]
output: [0, 0, 2, 0, 1, ...]
*... |
pareval_translation_data_30 | #include <omp.h>
/* Return the index of the first even number in the vector x.
Use OpenMP to parallelize the search.
Examples:
input: [7, 3, 9, 5, 5, 7, 2, 9, 12, 11]
output: 6
input: [3, 8, 9, 9, 3, 4, 8, 6]
output: 1
*/
size_t findFirstEven(std::vector<int> const& x) {
/* Return the index of the... |
pareval_translation_data_31 | #include <omp.h>
/* Return true if the vector x contains the value `target`. Return false otherwise.
Use OpenMP to search in parallel.
Examples:
input: x=[1, 8, 2, 6, 4, 6], target=3
output: false
input: x=[1, 8, 2, 6, 4, 6], target=8
output: true
*/
bool contains(std::vector<int> const& x, int ... |
pareval_translation_data_32 | #include <omp.h>
/* Return true if `val` is only in one of vectors x or y.
Return false if it is in both or neither.
Use OpenMP to search in parallel.
Examples:
input: x=[1,8,4,3,2], y=[3,4,4,1,1,7], val=7
output: true
input: x=[1,8,4,3,2], y=[3,4,4,1,1,7], val=1
output: false
*/
bool xorContain... |
pareval_translation_data_33 | #include <omp.h>
struct Book {
std::string title;
int pages;
};
/* Return the index of the last Book item in the vector books where Book.pages is less than 100.
Use OpenMP to search in parallel.
Example:
input: [{title="Green Eggs and Ham", pages=72}, {title="gulliver's travels", pages=362}, {title="St... |
pareval_translation_data_34 | #include <omp.h>
/* Return the index of the value in the vector x that is closest to the math constant PI.
Use M_PI for the value of PI.
Use OpenMP to search in parallel.
Example:
input: [9.18, 3.05, 7.24, 11.3, -166.49, 2.1]
output: 1
*/
size_t findClosestToPi(std::vector<double> const& x) {
/* Retur... |
pareval_translation_data_35 | #include <omp.h>
/* Compute the fourier transform of x. Store real part of results in r and imaginary in i.
Use OpenMP to compute in parallel.
Example:
input: [1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0]
output: r: [4, 1, 0, 1, 0, 1, 0, 1] i: [0, -2.41421, 0, -0.414214, 0, 0.414214, 0, 2.41421]
*/
void fft(st... |
pareval_translation_data_36 | #include <omp.h>
/* Compute the fourier transform of x in-place. Return the imaginary conjugate of each value.
Use OpenMP to compute in parallel.
Example:
input: [1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0]
output: [{4,0}, {1,-2.41421}, {0,0}, {1,-0.414214}, {0,0}, {1,0.414214}, {0,0}, {1,2.41421}]
*/
void ff... |
pareval_translation_data_37 | #include <omp.h>
/* forward declare fft. computes fourier transform in-place */
void fft(std::vector<std::complex<double>> &x);
/* Compute the inverse fourier transform of x in-place.
Use OpenMP to compute in parallel.
Example:
input: [1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0]
output: [{0.5,0}, {0.125,0... |
pareval_translation_data_38 | #include <omp.h>
/* Compute the discrete fourier transform of x. Store the result in output.
Use OpenMP to compute in parallel.
Example:
input: [1, 4, 9, 16]
output: [30+0i, -8-12i, -10-0i, -8+12i]
*/
void dft(std::vector<double> const& x, std::vector<std::complex<double>> &output) {
/* Compute the discr... |
pareval_translation_data_39 | #include <omp.h>
/* Compute the fourier transform of x. Store the result in output.
Use OpenMP to compute in parallel.
Example:
input: [1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0]
output: [{4,0}, {1,-2.42421}, {0,0}, {1,-0.414214}, {0,0}, {1,0.414214}, {0,0}, {1,2.41421}]
*/
void fft(std::vector<std::complex<... |
pareval_translation_data_40 | #include <omp.h>
/* Compute z = alpha*x+y where x and y are vectors. Store the result in z.
Use OpenMP to compute in parallel.
Example:
input: x=[1, -5, 2, 9] y=[0, 4, 1, -1] alpha=2
output: z=[2, -6, 5, 17]
*/
void axpy(double alpha, std::vector<double> const& x, std::vector<double> const& y, std::vec... |
pareval_translation_data_41 | #include <omp.h>
/* Solve the linear system Ax=b for x.
A is an NxN matrix in row-major. x and b have N elements.
Use OpenMP to compute in parallel.
Example:
input: A=[[1,4,2], [1,2,3], [2,1,3]] b=[11, 11, 13]
output: x=[3, 1, 2]
*/
void solveLinearSystem(std::vector<double> const& A, std::vector<do... |
pareval_translation_data_42 | #include <omp.h>
/* Multiply the matrix A by the matrix B. Store the results in the matrix C.
A is an MxK matrix, B is a KxN matrix, and C is a MxN matrix. The matrices are stored in row-major.
Use OpenMP to compute in parallel.
Example:
input: A=[[1, -1, 2], [0, -2, 1]] B=[[4, 1], [-1, 0], [2, 2]]
out... |
pareval_translation_data_43 | #include <omp.h>
/* Multiply the matrix A by the vector x. Store the results in the vector y.
A is an MxN matrix stored in row-major, x has N elements, and y has M elements.
Use OpenMP to compute in parallel.
Example:
input: A=[[1, -1, 2], [0, -3, 1]] x=[2, 1, 0]
output: y=[1, -3]
*/
void gemv(std::vec... |
pareval_translation_data_44 | #include <omp.h>
/* Factorize the matrix A into A=LU where L is a lower triangular matrix and U is an upper triangular matrix.
Store the results for L and U into the original matrix A.
A is an NxN matrix stored in row-major.
Use OpenMP to compute in parallel.
Example:
input: [[4, 3], [6, 3]]
output... |
pareval_translation_data_45 | #include <omp.h>
/* For each value in the vector x compute its index in the sorted vector.
Store the results in `ranks`.
Use OpenMP to compute in parallel.
Examples:
input: [3.1, 2.8, 9.1, 0.4, 3.14]
output: [2, 1, 4, 0, 3]
input: [100, 7.6, 16.1, 18, 7.6]
output: [4, 0, 1, 2, 3]
*/
void ranks(... |
pareval_translation_data_46 | #include <omp.h>
/* Sort the vector x in ascending order ignoring elements with value 0.
Leave zero valued elements in-place.
Use OpenMP to sort x in parallel.
Example:
input: [8, 4, 0, 9, 8, 0, 1, -1, 7]
output: [-1, 1, 0, 4, 7, 0, 8, 8, 9]
*/
void sortIgnoreZero(std::vector<int> &x) {
/* Sort the v... |
pareval_translation_data_47 | #include <omp.h>
/* Find the k-th smallest element of the vector x.
Use OpenMP to compute in parallel.
Example:
input: x=[1, 7, 6, 0, 2, 2, 10, 6], k=4
output: 6
*/
int findKthSmallest(std::vector<int> const& x, int k) {
/* Find the k-th smallest element of the vector x.
Example:
input: x=[1... |
pareval_translation_data_48 | #include <omp.h>
struct Result {
int startTime, duration;
float value;
};
/* Sort vector of Result structs by start time in ascending order.
Use OpenMP to sort in parallel.
Example:
input: [{startTime=8, duration=4, value=-1.22}, {startTime=2, duration=10, value=1.0}, {startTime=10, duration=3, val... |
pareval_translation_data_49 | #include <omp.h>
/* Sort the vector x of complex numbers by their magnitude in ascending order.
Use OpenMP to sort in parallel.
Example:
input: [3.0-1.0i, 4.5+2.1i, 0.0-1.0i, 1.0-0.0i, 0.5+0.5i]
output: [0.5+0.5i, 0.0-1.0i, 1.0-0.0i, 3.0-1.0i, 4.5+2.1i]
*/
void sortComplexByMagnitude(std::vector<std::c... |
pareval_translation_data_50 | #include <omp.h>
/* Set every cell's value to 1 if it has exactly one neighbor that's a 1. Otherwise set it to 0.
Note that we only consider neighbors and not input_{i,j} when computing output_{i,j}.
input and output are NxN grids of ints in row-major.
Use OpenMP to compute in parallel.
Example:
input:... |
pareval_translation_data_51 | #include <omp.h>
/* Simulate one generation of Game of Life on `input`. Store the results in `output`.
A cell is 1 if it is alive and 0 if it is dead.
If a live cell has fewer than 2 live neighbors then it dies.
If a live cell has 2 or 3 live neighbors then it lives on.
If a live cell has more than 3 live ... |
pareval_translation_data_52 | #include <omp.h>
/* Compute one iteration of a 3-point 1D jacobi stencil on `input`. Store the results in `output`.
Each element of `input` will be averaged with its two neighbors and stored in the corresponding element of `output`.
i.e. output[i] = (input[i-1]+input[i]+input[i+1])/3
Replace with 0 when readi... |
pareval_translation_data_53 | #include <omp.h>
const int edgeKernel[3][3] = {{-1, -1, -1}, {-1, 8, -1}, {-1, -1, -1}};
/* Convolve the edge kernel with a grayscale image. Each pixel will be replaced with
the dot product of itself and its neighbors with the edge kernel.
Use a value of 0 for pixels outside the image's boundaries and clip outp... |
pareval_translation_data_54 | #include <omp.h>
/* Compute one iteration of a 5-point 2D jacobi stencil on `input`. Store the results in `output`.
Each element of `input` will be averaged with its four neighbors and stored in the corresponding element of `output`.
i.e. output_{i,j} = (input_{i,j-1} + input_{i,j+1} + input_{i-1,j} + input_{i+1... |
pareval_translation_data_55 | #include <mpi.h>
struct Point {
double x, y;
};
double triangleArea(Point const& A, Point const& B, Point const& C) {
return 0.5 * std::abs( A.x*(B.y-C.y) + B.x*(C.y-A.y) + C.x*(A.y-B.y) );
}
/* Return the area of the smallest triangle that can be formed by any 3 points.
Use MPI to compute in parallel. Assume ... |
pareval_translation_data_56 | #include <mpi.h>
double distance(double x1, double x2) {
return std::abs(x1 - x2);
}
/* Return the distance between the closest two elements in the vector x.
Use MPI to compute in parallel. Assume MPI is already initialized.
Example:
input: [7, 3, 9, 12, 31, 1]
output: 2
*/
double closestPair(std::vect... |
pareval_translation_data_57 | #include <mpi.h>
struct Point {
double x, y;
};
double distance(Point const& p1, Point const& p2) {
return std::sqrt(std::pow(p2.x-p1.x, 2) + std::pow(p2.y-p1.y, 2));
}
/* Return the distance between the closest two points in the vector points.
Use MPI to compute in parallel. Assume MPI has already been initial... |
pareval_translation_data_58 | #include <mpi.h>
/* Return the number of vertices in the largest component of the undirected graph defined by the adjacency matrix A.
A is an NxN adjacency matrix stored in row-major. A is an undirected graph.
Use MPI to compute in parallel. Assume MPI has already been initialized.
Every rank has a complete c... |
pareval_translation_data_59 | #include <mpi.h>
/* Count the number of connected components in the undirected graph defined by the adjacency matrix A.
A is an NxN adjacency matrix stored in row-major. A is an undirected graph.
Use MPI to compute in parallel. Assume MPI has already been initialized.
Every rank has a complete copy of A. The c... |
pareval_translation_data_60 | #include <mpi.h>
/* Count the number of edges in the directed graph defined by the adjacency matrix A.
A is an NxN adjacency matrix stored in row-major. A represents a directed graph.
Use MPI to compute in parallel. Assume MPI has already been initialized.
Every rank has a complete copy of A. The result is re... |
pareval_translation_data_61 | #include <mpi.h>
/* Compute the highest node degree in the undirected graph. The graph is defined in the adjacency matrix A.
A is an NxN adjacency matrix stored in row-major. A is an undirected graph.
Use MPI to compute in parallel. Assume MPI has already been initialized.
Every rank has a complete copy of A.... |
pareval_translation_data_62 | #include <mpi.h>
/* Return the length of the shortest path from source to dest in the undirected graph defined by the adjacency matrix A.
A is an NxN adjacency matrix stored in row-major. A is an undirected graph.
Use MPI to compute in parallel. Assume MPI has already been initialized.
Every rank has a comple... |
pareval_translation_data_63 | #include <mpi.h>
/* Return the value of the smallest odd number in the vector x.
Use MPI to compute in parallel. Assume MPI is already initialized.
Every rank has a complete copy of x. Return the result on all ranks.
Examples:
input: [7, 9, 5, 2, 8, 16, 4, 1]
output: 1
input: [8, 36, 7, 2, 11]
o... |
pareval_translation_data_64 | #include <mpi.h>
/* Return the product of the vector x with every odd indexed element inverted.
i.e. x_0 * 1/x_1 * x_2 * 1/x_3 * x_4 ...
Use MPI to compute product in parallel. Assume MPI has already been initialized.
Every rank has a complete copy of x. Return the product on all ranks.
Example:
input:... |
pareval_translation_data_65 | #include <mpi.h>
/* Return the sum of the minimum value at each index of vectors x and y for all indices.
i.e. sum = min(x_0, y_0) + min(x_1, y_1) + min(x_2, y_2) + ...
Use MPI to sum in parallel. Assume MPI has already been initialized.
Every rank has a complete copy of x and y. Return the sum on all ranks.
... |
pareval_translation_data_66 | #include <mpi.h>
/* Return the average of the vector x.
Use MPI to compute in parallel. Assume MPI has already been initialized.
Every rank has a complete copy of x. Return the average on all ranks.
Examples:
input: [1, 8, 4, 5, 1]
output: 3.8
input: [2, 2, 2, 3]
output: 2.25
*/
double average(... |
pareval_translation_data_67 | #include <mpi.h>
/* Return the logical XOR reduction of the vector of bools x.
Use MPI to reduce in parallel. Assume MPI is already initialized.
Every rank has a complete copy of x. Return the result on all ranks.
Example:
input: [false, false, false, true]
output: true
*/
bool reduceLogicalXOR(std::ve... |
pareval_translation_data_68 | #include <mpi.h>
/* Compute the prefix sum array of the vector x and return its sum.
Use MPI to compute in parallel. Assume MPI is already initialized.
Every rank has a complete copy of x. Return the result on rank 0.
Example:
input: [-7, 2, 1, 9, 4, 8]
output: 15
*/
double sumOfPrefixSum(std::vector<d... |
pareval_translation_data_69 | #include <mpi.h>
/* Replace the i-th element of the vector x with the minimum value from indices 0 through i.
Use MPI to compute in parallel. Assume MPI has already been initialized.
Every rank has a complete copy of x. Store the result in x on rank 0.
Examples:
input: [8, 6, -1, 7, 3, 4, 4]
output: [8... |
pareval_translation_data_70 | #include <mpi.h>
/* Compute the prefix sum of the vector x into output.
Use MPI to compute in parallel. Assume MPI is already initialized.
Every rank has a complete copy of x. Store the result in output on rank 0.
Example:
input: [1, 7, 4, 6, 6, 2]
output: [1, 8, 12, 18, 24, 26]
*/
void prefixSum(st... |
pareval_translation_data_71 | #include <mpi.h>
/* In the vector x negate the odd values and divide the even values by 2.
Use MPI to compute in parallel. Assume MPI has already been initialized.
Every rank has a complete copy of x. The final result is stored on rank 0.
Example:
input: [16, 11, 12, 14, 1, 0, 5]
output: [8, -11, 6, 7,... |
pareval_translation_data_72 | #include <mpi.h>
bool isPowerOfTwo(int x) {
return (x > 0) && !(x & (x - 1));
}
/* Apply the isPowerOfTwo function to every value in x and store the results in mask.
Use MPI to compute in parallel. Assume MPI has already been initialized.
Every rank has a complete copy of x. The final result is stored in mask ... |
pareval_translation_data_73 | #include <mpi.h>
/* Replace every element of the vector x with 1-1/x.
Use MPI to compute in parallel. Assume MPI has already been initialized.
Every rank has a complete copy of x. The final result is stored on rank 0.
Example:
input: [2, 4, 1, 12, -2]
output: [0.5, 0.75, 0, 0.91666666, 1.5]
*/
void one... |
pareval_translation_data_74 | #include <mpi.h>
/* Compute the ReLU function on every element of x. Elements less than zero become zero,
while elements greater than zero stay the same.
Use MPI to compute in parallel. Assume MPI has already been initialized.
Every rank has a complete copy of x. The final result is stored on rank 0.
Examp... |
pareval_translation_data_75 | #include <mpi.h>
/* Replace every element of x with the square of its value.
Use MPI to compute in parallel. Assume MPI has already been initialized.
Every rank has a complete copy of x. The final result is stored on rank 0.
Example:
input: [5, 1, 2, -4, 8]
output: [25, 1, 4, 16, 64]
*/
void squareEach... |
pareval_translation_data_76 | #include <mpi.h>
struct COOElement {
size_t row, column;
double value;
};
/* Compute y = alpha*A*x + beta*y where alpha and beta are scalars, x and y are vectors,
and A is a sparse matrix stored in COO format.
A has dimensions MxN, x has N values, and y has M values.
Use MPI to parallelize. Assume MPI ... |
pareval_translation_data_77 | #include <mpi.h>
struct COOElement {
size_t row, column;
double value;
};
/* Compute the matrix multiplication Y=AX. A is a sparse MxK matrix in COO format.
X is a sparse KxN matrix in COO format. Y is a dense MxN matrix in row-major.
Use MPI to compute in parallel. Assume MPI has already been initialized... |
pareval_translation_data_78 | #include <mpi.h>
struct COOElement {
size_t row, column;
double value;
};
/* Factorize the sparse matrix A into A=LU where L is a lower triangular matrix and U is an upper triangular matrix.
A is a sparse NxN matrix stored in COO format.
Use MPI to compute in parallel. Assume MPI has already been initiali... |
pareval_translation_data_79 | #include <mpi.h>
/* For each letter in the alphabet, count the number of strings in the vector s that start with that letter.
Assume all strings are in lower case. Store the output in `bins` array.
Use MPI to compute in parallel. Assume MPI has already been initialized.
Every rank has a complete copy of s. Th... |
pareval_translation_data_80 | #include <mpi.h>
/* Vector x contains values between 0 and 100, inclusive. Count the number of
values in [0,10), [10, 20), [20, 30), ... and store the counts in `bins`.
Use MPI to compute in parallel. Assume MPI has already been initialized.
Every rank has a complete copy of x. The result is stored in bins on... |
pareval_translation_data_81 | #include <mpi.h>
struct Point {
double x, y;
};
/* Count the number of cartesian points in each quadrant. The vector points contains a list of `Point` objects.
Store the counts in `bins`.
Use MPI to count in parallel. Assume MPI has already been initialized.
Every rank has a complete copy of points. The r... |
End of preview. Expand in Data Studio
README.md exists but content is empty.
- Downloads last month
- 4