나는 반복을위한 pxq 행렬에 대해 Conway의 GOL의 실행에서 만들어 질 전이 수를 계산하려고한다. 예를 들어 초기 상태가 1 개의 깜박임 (아래 참조) 인 1 번의 반복이 주어집니다. 5 전환 (2 출생, 1 생존, 과소 인구에서 2 사망) 것입니다. 이미이 작업을 수행하고 있지만이 논리를 CUDA를 사용하여 실행하고 싶습니다. 아래는 CUDA로 포팅하고 싶습니다.conway의 삶의 게임을위한 쿠다 커널
코드 :
static void gol() // call this iterations x's
{
int[] tempGrid = new int[rows * cols]; // grid holds init conditions
for (int i = 0; i < rows; i++)
{
for (int j = 0; j < cols; j++)
{
tempGrid[i * cols + j] = grid[i * cols + j];
}
}
for (int i = 0; i < rows; i++)
{
for (int j = 0; j < cols; j++)
{
int numNeighbors = neighbors(i, j); // finds # of neighbors
if (grid[i * cols + j] == 1 && numNeighbors > 3)
{
tempGrid[i * cols + j] = 0;
overcrowding++;
}
else if (grid[i * cols + j] == 1 && numNeighbors < 2)
{
tempGrid[i * cols + j] = 0;
underpopulation++;
}
else if (grid[i * cols + j] == 1 && numNeighbors > 1)
{
tempGrid[i * cols + j] = 1;
survival++;
}
else if (grid[i * cols + j] == 0 && numNeighbors == 3)
{
tempGrid[i * cols + j] = 1;
birth++;
}
}
}
grid = tempGrid;
}
특별히 도움이 필요한 것은 무엇입니까? - 병렬화 방법, 저장 방법, 실제 CUDA 프로그래밍 등 ? – Rup
죄송합니다. 어떻게 병렬 처리에 접근해야합니까? – dnbwise