This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
#include <stdlib.h> | |
#include <time.h> | |
#include <cuda_runtime.h> | |
#include "kernel.h" | |
#include "kernel.cu" | |
#include "dev_array.h" | |
#include <math.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
#include<cuda.h> | |
__global__ void arradd(int *x,int *y, int *z) | |
{ | |
int id=blockIdx.x * blockDim.x+threadIdx.x; | |
/* blockIdx.x gives the respective block id which starts from 0 */ | |
/* threadIdx.x gives the respective thread id which starts from 0 */ | |
/* blockDim.x gives the dimension of block i.e. number of threads in one block */ | |
z[id]=x[id]+y[id]; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <cuda.h> | |
#define N 3 // Matrix size (3x3) | |
__global__ void matrixMultiply(int *a, int *b, int *c) | |
{ | |
int row = blockIdx.y * blockDim.y + threadIdx.y; | |
int col = blockIdx.x * blockDim.x + threadIdx.x; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
// Matrix dimensions | |
#define N 4 | |
#define M 4 | |
#define P 4 | |
// CUDA kernel for matrix multiplication | |
__global__ void matrixMul(int *a, int *b, int *c) { | |
int row = blockIdx.y * blockDim.y + threadIdx.y; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright (c) 2018 SUSE LLC | |
* | |
* This software is licensed to you under the GNU General Public License, | |
* version 2 (GPLv2). There is NO WARRANTY for this software, express or | |
* implied, including the implied warranties of MERCHANTABILITY or FITNESS | |
* FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 | |
* along with this software; if not, see | |
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. | |
* |
NewerOlder