Open main menu

CDOT Wiki β

Changes

GPU610 Team Tsubame

1,177 bytes removed, 12:00, 5 April 2017
PHASE 2
PM> '''Install-Package libpng'''
6. In VS, Open MazePng.cpp, Replace replace the entire MazePng.cpp file with Paralleling code in the followingcode:
/*
* MazePng.cpp
// Call the kernel wrapper...
kw_drawWalls(row_pointers, this->cells, this->width, this->height, width, height, WALL, start);
// createImage(row_pointers, 0);
fp = fopen("out.png", "wb");
}
void inline MazePng::setPixel(png_bytep *row_pointers, unsigned int x, unsigned int y,
png_byte type) {
row_pointers[y][0 + 3 * x] = row_pointers[y][1 + 3 * x] = row_pointers[y][2 + 3 * x] = type;
}
void MazePng::createImage(png_bytep *row_pointers, unsigned int scale) {
if (start < width) {
setPixel(row_pointers, start * 2 + 1, 0, PATH);
}
for (unsigned int y = 0; y < height; ++y) { // for each row in range [1, actual height (not the number of pixels) )...
for (unsigned int x = 0; x < width; ++x) { // for each cell in range [1, actual width)...
switch ((cells[(y * width) + x] & 0xC0) >> 6) {
case 2:
setPixel(row_pointers, 2 + (x * 2), (y * 2) + 1, PATH); // even x, odd y
break;
case 1:
setPixel(row_pointers, 1 + (x * 2), (y * 2) + 2, PATH); // odd x, even y
break;
case 0:
setPixel(row_pointers, 2 + (x * 2), (y * 2) + 1, PATH); // even x, odd y
setPixel(row_pointers, 1 + (x * 2), (y * 2) + 2, PATH); // odd x, even y
break;
}
setPixel(row_pointers, 1 + (x * 2), (y * 2) + 1, PATH); // odd
}
}
}
7. In VS, right click on the project in the Solution explorer and Add -> '''New Item'''; Add a new '''Cuda c++ header''' file, name it '''"MazePng.cuh"'''
8. Cope Copy and paste the following code into '''"MazePng.cuh"''':
// MazePng.cuh
9. In VS, right click on the project in the Solution explorer and Add -> '''New Item'''; Add a new '''Cuda c++''' file, name it '''"MazePng.cu"'''
10. Cope Copy and paste the following code into '''"MazePng.cu"''':
// MazePng.cu
}
// Kernel wrapper...
void kw_drawWalls(png_bytep*& row_pointers, const short* cells, const int width, const int height, const int pixWidth, const int pixHeight, const png_byte WALL, const int start) {
int rowLen = pixWidth * 3;
k_drawWalls << <nblks, ntpb >> > (d_rows, d_cells, width, height, rowLen, szRows);
// cudaDeviceSynchronize();
cudaStream_t* stream = new cudaStream_t[pixHeight];
12. In VS, go to menu Build -> Build Solution
 
 
'''Parallelize:'''
== PHASE 3 ==
240
edits