我正在写一个python脚本来检查我做的一个C程序。有时,当从脚本调用我的可执行文件时
subprocess.CalledProcessError: Command Command '['./parallel_snake', 'input/input1', 'output/output1', '20000']' returned non-zero exit status -11
这是我调用可执行文件的行:
^{pr2}$为什么我会遇到这个错误,我如何才能消除它?在
编辑我的代码:
input_files = [f for f in listdir("input")]
num_threads = [2, 4, 6, 8]
for input_file in input_files:
print "Checking " + input_file + "\n"
for num in num_threads:
os.environ['OMP_NUM_THREADS'] = str(num)
p = subprocess.check_output(["./parallel_snake", "input/" + input_file, "output/" + input_file.replace("in", "out"), "20000"])
print "\t" + str(num) + " threads: " + str(p)
并行趵snake C程序的输入:
3 // there are 3 snakes
1 2 1 N // head of a snake (1, 2)/its encoding (1)/its move direction (N)
5 7 2 E // second snake
3 4 3 S // third snake
9 9 // dimensions of the map
0 0 0 0 0 0 0 0 0
0 0 1 0 0 0 0 0 0
0 0 1 0 3 3 3 3 0
0 1 1 0 3 0 0 0 0
0 0 0 0 0 0 0 0 0
0 0 0 0 0 2 2 2 0
0 0 0 0 0 2 0 0 0
0 0 0 2 2 2 0 0 0
0 0 0 0 0 0 0 0 0 // the map with the 3 snakes
The purpose is to move the snakes in the indicated direction as long as they do not collide. As you can see, if snake 1 goes up and 2 goes to right, they will collide in 5 steps
I used #pragma omp parallel for to count from 0 to the maximum number of movements, which was 20 000. If I decide to not paralelise the counting, but to paralelise the iteration through the snakes (i have an array of them), the problem does not appear.
目前没有回答
相关问题 更多 >
编程相关推荐