基于可变参数函数的输入构建OpenMP的预处理程序指令

时间:2018-04-29 13:19:46

标签: c++ boost openmp preprocessor variadic

该函数采用可变参数列表来委派给OpenMP的预处理程序指令。可变列表在编译时是已知的。它在运行时扩展,在预处理阶段没有帮助。有关如何做到这一点的任何建议/解决方案?我想要实现的一个例子如下:

void dependencies(int count, ...) {  
    va_list args;
    va_start(args, count);
    int* arr[count];    // an array of pointers to the dependencies
    int start[count];   // starting element of the array
    int end[count];     // ending element of the array 
    int direction[count];   // direction of dependency
    for (int i = 0; i < count; ++i) {
        arr[i] = va_arg(args, int*);
        start[i] = va_arg(args, int);
        end[i]   = va_arg(args, int);
        direction[i] = va_arg(args, int);
    }
    va_end(args);

// repeat count number of times while respecting the input params  
#pragma omp task depend(direction_:arr_[start_:end_]) 

}
// for example 
int a[3];
int b[5];
dependencies(2, a, 0, 3, inout, b, 0, 5, out);

// should yield 
#pragma omp task depend(inout:a[0:3]) depend(out:b[0:5])

P.S。我将Boost添加到标签列表中,因为我相信可以使用Boost预处理器功能完成某些操作。我无法找到有用的参考资料。

0 个答案:

没有答案