如果我像这样使用嵌套并行for循环:
#pragma omp parallel for schedule(dynamic,1)
for (int x = 0; x < x_max; ++x) {
#pragma omp parallel for schedule(dynamic,1)
for (int y = 0; y < y_max; ++y) {
//parallelize this code here
}
//IMPORTANT: no code in here
}
Run Code Online (Sandbox Code Playgroud)
这相当于:
for (int x = 0; x < x_max; ++x) {
#pragma omp parallel for schedule(dynamic,1)
for (int y = 0; y < y_max; ++y) {
//parallelize this code here
}
//IMPORTANT: no code in here
}
Run Code Online (Sandbox Code Playgroud)
除了创建新任务之外,做外部并行吗?
删除已作为函数参数传递的指针(如下所示)是否合法(和合法):
#include<iostream>
class test_class{
public:
test_class():h(9){}
int h;
~test_class(){std::cout<<"deleted";}
};
void delete_test(test_class* pointer_2){
delete pointer_2;
}
int main(){
test_class* pointer_1;
while(true){
pointer_1 = new test_class;
//std::cout<<pointer_1->h;
delete_test(pointer_1);
}
}
Run Code Online (Sandbox Code Playgroud)
这个编译好了,但我只是想确保它永远都是那样.