假设我们有一个a.json文件。该文件包含许多属性。例如在文件中,我只显示了两个属性“name”和“age”。实际上,还有更多具有数值的属性。
{
"name":[
"James",
"Alek",
"Bob"
],
"age":[
35,
25,
23
]
...//other attributes with numerical values
}
Run Code Online (Sandbox Code Playgroud)
我们如何转换如下文件?
{
"name":[
"James",
"Alek",
"Bob"
],
"age":[
"35",
"25",
"23"
]
...//other attributes with numerical values
}
Run Code Online (Sandbox Code Playgroud) 我有一个函数f ,我可以使用并行处理.为此,我使用了openmp.但是,多次调用此函数,似乎每次调用都会创建线程.
我们如何重用线程?
void f(X &src, Y &dest) {
... // do processing based on "src"
#pragma omp parallel for
for (...) {
}
...// put output into "dest"
}
int main() {
...
for(...) { // It is impossible to make this loop processing parallel one.
f(...);
}
...
return 0;
}
Run Code Online (Sandbox Code Playgroud)