我想编译一个ispc程序。我正在尝试为他们的示例程序之一生成可执行文件。
我有以下内容的 simple.cpp
#include <stdio.h>
#include <stdlib.h>
// Include the header file that the ispc compiler generates
#include "simple_ispc.h"
using namespace ispc;
int main() {
float vin[16], vout[16];
// Initialize input buffer
for (int i = 0; i < 16; ++i)
vin[i] = (float)i;
// Call simple() function from simple.ispc file
simple(vin, vout, 16);
// Print results
for (int i = 0; i < 16; ++i)
printf("%d: simple(%f) = %f\n", i, vin[i], vout[i]);
return 0;
}
我有以下内容的 simple.ispc
export void simple(uniform float vin[], uniform float vout[],
uniform int count) {
foreach (index = 0 ... count) {
// Load the appropriate input value for this program instance.
float v = vin[index];
// Do an arbitrary little computation, but at least make the
// computation dependent on the value being processed
if (v < 3.)
v = v * v;
else
v = sqrt(v);
// And write the result to the output array.
vout[index] = v;
}
}
我可以使用 cmake https://github.com/ispc/ispc/tree/main/examples/cpu/simple来获取可执行文件,但我想知道运行 simple.cpp 文件需要执行的原始命令。有人能告诉我如何用 ispc 编译和运行 simple.cpp 文件吗?