51
edits
Changes
UnknownX
,→Assignment 2 - V1 Parallelization
== Assignment 2 - V1 Parallelization==
Output result(converted to PNG formate):
[[File:GpuassOutput.PNG]]
Run time graph:
[[File:Pygpu2.PNG]]
CPU code:
The most expensive part in the program.
for (int y = 0; y < N; ++y) {
for (int x = 0; x < N; ++x) {
}
int size = N * N;
int nblocks = (size + ntpb - 1) / ntpb;
Kernel: before: for (int y = 0; y < N; ++y) for (int x = 0; x < N; ++x)after: int idx = blockIdx.x * blockDim.x + threadIdx.x; int x = idx / N; int y = idx % N;
__global__ void kernel_tray(Vec3 pix_col, int N, int* pixs_x, int* pixs_y, int* pixs_z) {
pixs_z[y * N + x] = (int)pix_col.z;
}
Profile on nvvp:
[[File:matrix.senecac.on.ca/~zzha1/Capture.PNG]]
== Assignment 3 - Optimization ==
'''What problems does it solve?''' <br />
1. Using too many registers
To get 100%, we have to use less than 32 registers. If we change it from double to float, it reduces from 42 44 to 29.
Referances: https://www.youtube.com/watch?v=ARn_yhgk7aE
PPT: https://docs.google.com/presentation/d/10Cr_zIDUultkQLzdyC3_3B-GKO_bl6RJFHpWNg72tRk/edit#slide=id.g20678afd80_0_1313