您好,OpenACC专家,
我遇到了一个使用OpenACC将数组元素写入文件的问题。以下是相关的代码片段:
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ofstream THeOutfile;
THeOutfile.open("TheIndianNumbers.txt", ios::app);
const int arraySize = 1000001;
long long int* thenumbersarray = new long long int[arraySize];
for (int m = 0; m < 4000; m++)
{
#pragma acc parallel loop
for (int i = 0; i < arraySize - 1; i++)
{
thenumbersarray[i] = 6000000000LL + i;
cout << "Calculation Done " << i << endl;
}
for (int x = 0; x < arraySize - 1; x++)
{
THeOutfile << thenumbersarray[x] << endl;
cout << "Writing Done " << x << endl;
}
}
delete[] thenumbersarray;
THeOutfile.close();
return 0;
}
问题在于负责将数组元素写入文件的循环。它运行不正常,我需要你的专业知识来修复它。
我正在寻求建议或代码片段,以使用OpenACC指令正确地并行化循环,并确保将所有数组元素成功写入文件。
提前感谢您的帮助!