 	//}
 
 	// set to pinned memory
-	checkCuda (cudaSetDeviceFlags(cudaDeviceMapHost));
+	checkCuda(cudaSetDeviceFlags(cudaDeviceMapHost));
 
 	// Allocate matrixA
 	//int matrixARowSize = n;

	constantInit(matrixD, n, n, 0);
	multiply(h_matrixA, h_matrixB, matrixD, n, n, n);
	bool verifyResult = verify(h_matrixC, matrixD, n, n);

	if (DEBUG) {
		if (verifyResult) {
			printf("Verify PASSED!\n");
		} else {
			printf("Verify FAILED!\n");
		}
		printf("matrixC:\n");
		printArr(h_matrixC, n, n);
		printf("matrixD:\n");

	unsigned block_idxx = blockIdx.x;
	int thread_idxx = threadIdx.x;

	int matrixARowSize = n;
	int matrixAColSize = m;
	int matrixBRowSize = m;
	int matrixBColSize = n;

	// Check for wrong matrix sizes
	if (matrixAColSize != matrixBRowSize) {
		return;
	}

	// Check if thread and block is in matrix range
	if ((block_idxx < matrixBColSize * blockSliceSize)
			&& (thread_idxx < matrixBRowSize * threadSliceSize)) {

		cuPrintf("[%d,%d]device_method started. thread_id: %d, block_id: %d\n",
				thread_idxx, block_idxx, thread_idxx, block_idxx);

		// Setup multipliers of matrix B (slized Matrix)
		int multipliers[10][10]; //[blockSliceSize][threadSliceSize];
		for (int k = 0; k < blockSliceSize; k++) {
			for (int j = 0; j < threadSliceSize; j++) {
				multipliers[k][j] = d_matrixB[((thread_idxx * threadSliceSize
						+ j) * matrixAColSize) + (block_idxx * blockSliceSize)
						+ k];

				cuPrintf("[%d,%d]multipliers[%d][%d]: %d\n", thread_idxx,
						block_idxx, k, j, multipliers[k][j]);
			}
		}

		// Setup columns of matrix A
		int matrixAColumns[10][10]; //[threadSliceSize][matrixARowSize]
		for (int k = 0; k < threadSliceSize; k++) {
			for (int i = 0; i < matrixARowSize; i++) {
				matrixAColumns[k][i] = d_matrixA[(i * matrixAColSize)
						+ (thread_idxx * threadSliceSize) + k];

				cuPrintf("[%d,%d]matrixAColumn[%d][%d]: %d\n", thread_idxx,
						block_idxx, k, i, matrixAColumns[k][i]);
			}
		}

		// Calculate scalar multiplication
		for (int k = 0; k < blockSliceSize; k++) {
			for (int i = 0; i < matrixARowSize; i++) {

				int sum = 0;
				for (int j = 0; j < threadSliceSize; j++) {

					cuPrintf("[%d,%d]matrixAColumns[%d][%d]: %d\n", thread_idxx,
							block_idxx, j, i, matrixAColumns[j][i]);
					cuPrintf("[%d,%d]multipliers[%d][%d]: %d\n", thread_idxx,
							block_idxx, k, j, multipliers[k][j]);

					sum += matrixAColumns[j][i] * multipliers[k][j];
				}

				cuPrintf("[%d,%d]sum: %d\n", thread_idxx, block_idxx, sum);

				intermediateSums[thread_idxx] = sum;

				syncthreads();

				// do reduction in shared memory
				// 1-bit right shift = divide by two to the power 1
				for (int s = matrixARowSize / 2; s > 0; s >>= 1) {

					if (thread_idxx < s) {
						intermediateSums[thread_idxx] +=
								intermediateSums[thread_idxx + s];
					}
					syncthreads();
				}

				if (thread_idxx == 0) {
					cuPrintf("[%d,%d]final sum: %d\n", thread_idxx, block_idxx,
							intermediateSums[thread_idxx]);

					d_matrixC[(i * matrixARowSize) + block_idxx + k] =
							intermediateSums[thread_idxx];
				}

			}
		}
	}
}
