serial_no int64 1 24.2k | cuda_source stringlengths 11 9.01M |
|---|---|
19,601 | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
char * getstr(FILE* f, char * str)
{
char l = 'A';
size_t size = 20;
int pos = 0;
str = (char*) malloc(size);
while(l != '\n')
{
scanf("%c", &l);
str[pos] = l;
pos++;
if(pos > si... |
19,602 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <math.h>
typedef unsigned long ulint;
typedef unsigned long long ulint64;
int banyakdata = 10240;
int dimensigrid = 80;
int dimensiblok = 128;
void modexp(ulint a, uli... |
19,603 | /*
* Copyright (c) 2022-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable... |
19,604 | #include <stdio.h>
#include <time.h>
#include <cuda.h>
#define M 400
#define N 400
#define R 400
#define THREADS_PER_BLOCK 512
__global__ void gpu_matmul(int *a, int *b, int *c, int m, int n, int r)
{
int i = threadIdx.y + blockIdx.y * blockDim.y;
int j = threadIdx.x + blockIdx.x * blockDim.x;
int sum = 0;
if ... |
19,605 | #include<stdio.h>
#include<iostream>
#include<cuda.h>
using namespace std;
//Catch Cuda errors
void catchCudaError(cudaError_t error){
if(error!=cudaSuccess) {
printf("\n====== Cuda Error Code %i ======\n %s\n",error,cudaGetErrorString(error));
exit(-1);
}
}
//================================... |
19,606 | /**
Name: Anand Jhunjhunwala
Roll Number: 17EC30041
Assignment 1: Linear Transformation
**/
#include <stdio.h>
#include <stdlib.h>
#include <cuda.h>
#include <cuda_runtime.h>
// Defining kernels as specified from assignment
__global__ void process_kernel1(float *input1, float *input2, float *output_k1, int datasize... |
19,607 | /************************************************************/
// Cuda function to allocate space for the file using
// CudaMallocManaged. This file is used with io-main.c
// 05/01/2020
/***********************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <... |
19,608 | #include "includes.h"
__global__ void huber(float *a, const size_t width, const size_t height, const float alpha, const float strength, const size_t pixelsPerThread, float *f)
{
const size_t col = (blockIdx.x * blockDim.x + threadIdx.x) % width;
const size_t crow = (blockIdx.x * blockDim.x + threadIdx.x) / width * pix... |
19,609 |
/* This is a automatically generated test. Do not modify */
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
__global__
void compute(float comp, float var_1,float var_2,float var_3,float var_4,float var_5,float var_6,float var_7,float var_8,float var_9,float var_10,float var_11,float var_12,float var_13,floa... |
19,610 | //pass
//--gridDim=1 --blockDim=32 --no-inline
__global__ void kernel(uint4 *out) {
uint4 vector = {0,0,0,0};
out[threadIdx.x] = vector;
}
|
19,611 |
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include <stdlib.h> // rand
#include <time.h>
#define WIDTH 128
#define TILE_WIDTH 32
cudaError_t multiplyWithCuda(int *c, int *a, int *b, unsigned int size, double &tt);
int multiplyWithCPU(int *c, int *a, int *b, unsigned int w);
b... |
19,612 | #include <stdio.h>
#include <assert.h>
__global__ void swap_gpu(int *a, int *b)
{
int tmp = *a;
*a = *b;
*b = tmp;
}
int main()
{
int h_a, h_b;
h_a = 3;
h_b = 9;
int *dev_a, *dev_b;
size_t varSize = sizeof(int);
cudaMalloc((void **)&dev_a, varSize);
cudaMalloc((void **)&dev_b, varSize);
cudaMemcpy(d... |
19,613 | #include "includes.h"
__global__ void cuComputeDistanceGlobal( float* A, int wA, float* B, int wB, int dim, float* AB){
// Declaration of the shared memory arrays As and Bs used to store the sub-matrix of A and B
__shared__ float shared_A[BLOCK_DIM][BLOCK_DIM];
__shared__ float shared_B[BLOCK_DIM][BLOCK_DIM];
// Sub... |
19,614 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
* Copyright (c) 2019 <GTEP> - All Rights Reserved *
* This file is part of HERMES Project. *
* Unauthorized copying of this file, via any medium is strictly prohibited. *
... |
19,615 | //#include "xdynamics_parallel/xParallelSPH_decl.cuh"
//#include <thrust/device_ptr.h>
//#include <thrust/iterator/zip_iterator.h>
//#include <thrust/sort.h>
//
//__constant__ device_sph_parameters scte;
//
//void setSPHSymbolicParameter(device_sph_parameters *h_paras)
//{
// checkCudaErrors(cudaMemcpyToSymbol(scte, h_... |
19,616 | #include "includes.h"
#define SIZ 20
#define num_inp 4
using namespace std;
typedef struct edge {
int first, second;
} edges;
__global__ void dhidden_cal_kernel(double * a1,double * dhidden,int size)
{
int i = blockIdx.x;
int j = threadIdx.x;
if (a1[i*size + j] <= 0)
{
dhidden[i*size + j] = 0;
}
} |
19,617 | //
// TauSelection.cpp
// HiggsAnalysis_new
//
// Created by Joona Havukainen on 5/14/19.
// Copyright © 2019 Joona Havukainen. All rights reserved.
//
//#include "TauSelection.cuh"
__device__
float deltaR(float eta1, float eta2, float phi1, float phi2)
{
float deta = eta2-eta1;
float dphi = phi2-phi1;
if(dphi... |
19,618 | #include "includes.h"
__global__ void matrixTranspose(unsigned int* A_d, unsigned int *T_d, int rowCount, int colCount) {
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// **** Populate vecADD kernel function ****
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
int col = blockIdx.x * blockDim.x + threadIdx.x;
int row = bl... |
19,619 | #include <sys/time.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
float elapsed_time( struct timeval t1, char str[] ) {
struct timeval t2;
long dt, dut;
int dd, dh, dm, ds;
gettimeofday( &t2, NULL );
dt = t2.tv_sec - t1.tv_sec;
dut = t2.tv_usec - t1.tv_usec;
if ( dut < 0 ) {
dt -= 1;
dut +=... |
19,620 | #include <stdio.h>
#define epsilon (float)1e-5
// Thread block size
#define NB 32
// Forward declaration
void randomInit (float*, int);
void MatMul_cpu (const float *, const float *, float *, int );
void MatMul_gpu (const float *, const float *, float *, int );
__global__ void MatMul_kernel(float *, float *, float *,... |
19,621 | #include <stdint.h>
#include <cuda.h>
extern "C" __global__ void bench(uint32_t *a, uint32_t *b, uint32_t *c, uint32_t n){
int i = blockIdx.x * blockDim.x + threadIdx.x;
int j = blockIdx.y * blockDim.y + threadIdx.y;
if(i<n&&j<n){
int idx = i*n+j;
c[idx] = a[idx] + b[idx];
}
}
|
19,622 | #include "includes.h"
/*
* Multiplying a 2D matrix using CUDA
*/
#define BLOCK_SIZE 16
__global__ void gpu_matrix_mul( int *a, int *b, int *c, int m, int n, int k){
int row = blockIdx.y + blockDim.y * threadIdx.y;
int col = blockIdx.x + blockDim.x * threadIdx.x;
int sum = 0;
if(col < k && row < m){
for(int i = 0; ... |
19,623 | #include "includes.h"
__global__ void matrix_mul_shared(float *ad,float *bd,float *cd,int N)
{
float pvalue=0;
int TILE=blockDim.x;
int ty=threadIdx.y;
int tx=threadIdx.x;
//allocate shared memory per block
__shared__ float ads[16][16];
__shared__ float bds[16][16];
//find Row and Column corresponding to a data eleme... |
19,624 | #include "includes.h"
__global__ void CopyVectorKernel( float *from, int fromOffset, float *to, int toOffset, int vectorSize )
{
int threadId = blockDim.x*blockIdx.y*gridDim.x //rows preceeding current row in grid
+ blockDim.x*blockIdx.x //blocks preceeding current block
+ threadIdx.x;
if(threadId < vectorSize)
{... |
19,625 | // ver 20170219 by jian
// ref: http://www.nvidia.com/docs/IO/116711/sc11-cuda-c-basics.pdf
//cudaMalloc(), cudaFree(), cudaMemcpy()
//malloc(), free(), memcpy()
// concept of block, and thread
#include <stdio.h>
__global__ void add(int *a, int *b, int *c, int n) {
//c[blockIdx.x] = a[blockIdx.x] + b[blockIdx.x];
//c... |
19,626 | #include <stdio.h>
#include <stdlib.h>
#include <cuda.h>
#include <curand_kernel.h>
#include <time.h>
const int num_blocks = 1024;
const int num_threads = 256;
const int num_iterations = 10;
__global__ void setup_states(curandState* states){
int id = threadIdx.x + num_threads * blockIdx.x;
// Initialisatio... |
19,627 | #include <stdlib.h> // for calloc();
#include <assert.h> // ensure successfull allocation
#include <stdbool.h> // bool variables
#include <stdio.h> // printf...
#include <string.h>
#include <dirent.h> // Directory management
#include <sys/stat.h> // system commands ?
#include <sys/types.h> // Extra ty... |
19,628 | #include <stdio.h>
#include <time.h>
int blockSize=256;
int gridSize=256;
__global__ void gameOfLife(int *indata, int *outdata, int width, int height)
{
__shared__ int sodata[2566];
__shared__ int sidata[256*3];
int tSize=width*height;
int x, y, x0,x1,y0,y1, n;
int tid;
int bid;
int cid;
for(bid=0;bid<grid... |
19,629 | #include "includes.h"
__global__ void kApplyLog1PlusExpExact(float* mat, float* target, unsigned int len) {
const unsigned int idx = blockIdx.x * blockDim.x + threadIdx.x;
const unsigned int numThreads = blockDim.x * gridDim.x;
float mat_i;
for (unsigned int i = idx; i < len; i += numThreads) {
mat_i = mat[i];
if (mat... |
19,630 | #include <iostream>
#define HD __host__ __device__
#define gpuErrchk(ans) { gpuAssert((ans), __FILE__, __LINE__); }
inline void gpuAssert(cudaError_t code, char *file, int line, bool abort=true)
{
if (code != cudaSuccess)
{
fprintf(stderr,"GPUassert: %s %s %d\n", cudaGetErrorString(code), file, line);
... |
19,631 |
__host__ __device__ float4 operator+(float4 a, float4 b) { return make_float4(a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w); }
__host__ __device__ float4 operator/(float4 a, float4 b) { return make_float4(a.x / b.x, a.y / b.y, a.z / b.z, a.w / b.w); }
__host__ __device__ float4 operator/(float4 a, float b) { return mak... |
19,632 | #include <stdlib.h>
#include <stdio.h>
#include <cuda_runtime.h>
#include <time.h>
#include <math.h>
#define VSQR 0.1
#define TSCALE 1.0
#define __DEBUG
#define CUDA_CALL( err ) __cudaSafeCall( err, __FILE__, __LINE__ )
#define CUDA_CHK_ERR() __cudaCheckError(__FILE__,__LINE__)
int tpdt(double *t, double dt, dou... |
19,633 | /* asum: sum of all entries of a vector.
* This code only calculates one block to show the usage of shared memory and synchronization */
#include <stdio.h>
#include <cuda.h>
typedef double FLOAT;
/* sum all entries in x and asign to y */
__global__ void reduction_1(const FLOAT *x, FLOAT *y)
{
__shared__ FLOAT s... |
19,634 | #include "includes.h"
__global__ void __extractmat2d(float *a, long long *b, int nrows, int ncols) {
int tid = threadIdx.x + blockDim.x * (blockIdx.x + gridDim.x * blockIdx.y);
const int signbit = 0x80000000;
const int mag = 0x7fffffff;
for (int i = tid; i < nrows*ncols; i += blockDim.x*gridDim.x*gridDim.y) {
int v... |
19,635 | #include <stdlib.h>
#include <stdio.h>
#define N 10
__global__ void VecAssign(float* A, float *B) {
int i = threadIdx.x;
A[i] = 10.0 * i;
B[i] = 20.0 * i; // bad: B is not alloced by CUDA
}
int main() {
float *xA, *xB;
cudaMallocHost(&xA, N * sizeof(float));
printf("uva ptr=%p\n", xA);
... |
19,636 | /*
* Copyright (c) 2022 Mohamed Khaled <Mohamed_Khaled_Kamal@outlook.com>
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the ... |
19,637 | #include "raytracer.cuh"
#include <float.h>
#include "vec3.cuh"
#include "ray.cuh"
#include "surface.cuh"
#include "surface_list.cuh"
#include "sphere.cuh"
#include "material.cuh"
#include "camera.cuh"
void Raytracer::check_cuda(cudaError_t result, char const *const func, const char *const file, int const line) {
... |
19,638 | #ifdef _GLIBCXX_USE_INT128
#undef _GLIBCXX_USE_INT128
#endif
#ifdef _GLIBCXX_ATOMIC_BUILTINS
#undef _GLIBCXX_ATOMIC_BUILTINS
#endif
#include <thrust/host_vector.h>
#include <thrust/device_vector.h>
#include <thrust/generate.h>
#include <thrust/reduce.h>
#include <thrust/functional.h>
#include <cstdlib>
int main(voi... |
19,639 | #include "includes.h"
__global__ void field_summary( const int x_inner, const int y_inner, const int halo_depth, const double* volume, const double* density, const double* energy0, const double* u, double* vol_out, double* mass_out, double* ie_out, double* temp_out)
{
const int gid = threadIdx.x+blockDim.x*blockIdx.x;
... |
19,640 | // headers
#include <stdio.h>
int main(void)
{
// function declarations
void PrintCUDADeviceProperties(void);
// code
PrintCUDADeviceProperties();
}
void PrintCUDADeviceProperties(void)
{
// function declarations
int ConvertSMVersionNumberToCores(int, int);
// code
printf("CUDA INFORMATION :... |
19,641 | #include "includes.h"
__global__ void gpu_grey_and_blur(unsigned char* Pout, unsigned char* Pin, int width, int height){
int channels = 3;
int col = threadIdx.x + blockIdx.x * blockDim.x;
int row = threadIdx.y + blockIdx.y * blockDim.y;
// check if pixel within range
if (col < width && row < height){
int gOffset = ro... |
19,642 | // 20181130
// Yuqiong Li
// Matrix multiplication with CUDA, add tiling
#include <stdlib.h>
#include <cuda.h>
#include <time.h>
#include <stdio.h>
#define index(i, j, n) ((i) * (n) + (j))
const unsigned int TW = 16; // tile width
// declare global kernel function
__global__ void matrixMulKernel(float * a, float... |
19,643 | /*
* Copyright 2015 Netherlands eScience Center, VU University Amsterdam, and Netherlands Forensic Institute
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses... |
19,644 | #include<stdio.h>
#include<stdlib.h>
void my_cudasafe( cudaError_t error, char* message)
{
if(error!=cudaSuccess)
{
fprintf(stderr,"ERROR: %s : %s\n",message,cudaGetErrorString(error));
exit(-1);
}
}
__global__ void arradd(int* md, int* nd, int* pd, int size)
{
int myid = blockIdx.x*blockDim.x + threadIdx... |
19,645 | #include <stdio.h>
#include <stdint.h>
static __device__ __inline__ uint32_t __mysmid(){
uint32_t smid;
asm volatile("mov.u32 %0, %%smid;" : "=r"(smid));
return smid;
}
static __device__ __inline__ uint32_t __mywarpid(){
uint32_t warpid;
asm volatile("mov.u32 %0, %%warpid;" : "=r"(warpid));
return warpid;... |
19,646 | #include "includes.h"
__global__ void grayscale( unsigned char * rgb, unsigned char * g, std::size_t cols, std::size_t rows ) {
auto i = blockIdx.x * blockDim.x + threadIdx.x;
auto j = blockIdx.y * blockDim.y + threadIdx.y;
if( i < cols && j < rows ) {
g[ j * cols + i ] = (
307 * rgb[ 3 * ( j * cols + i ) ]
+ 604 * rgb... |
19,647 | // A C / C++ program for Prim's Minimum
// Spanning Tree (MST) algorithm. The program is
// for adjacency matrix representation of the graph
#include <stdio.h>
#include <limits.h>
#include<stdbool.h>
#include <cstdlib>
#include <ctime>
#include <algorithm>
// Number of vertices in the graph
#define V 26
#defin... |
19,648 | /*
* Copyright 1993-2012 NVIDIA Corporation. All rights reserved.
*
* Please refer to the NVIDIA end user license agreement (EULA) associated
* with this source code for terms and conditions that govern your use of
* this software. Any use, reproduction, disclosure, or distribution of
* this software and related... |
19,649 | #include <cuda_runtime_api.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
/***********************************************************************
**
Compile with:
nvcc -o CrackAZ99-With-Data-cuda CrackAZ99-With-Data-cuda.cu
./CrackAZ99-With-Data-cuda
Dr Kevan Buckley, U... |
19,650 | #include "cuda_runtime.h"
#include "device_functions.h"
#include "device_launch_parameters.h"
#include <stdio.h>
extern "C" {
__global__ void FactorKernel(int* m, int v)
{
//int i = threadIdx.x + (blockDim.x * blockIdx.x);
//m[i] = v*i;
m[threadIdx.x + (blockDim.x * blockIdx.x)] *= v;
... |
19,651 | #include <iostream>
#include <cstdio>
#define LOG_NUM_BANKS 5
#define GET_OFFSET(idx) (idx >> LOG_NUM_BANKS)
#define BLOCK_SIZE 256
__global__
void BlockScan(int* in_data, int* out_data, int* sum, int size) {
extern __shared__ int shared_data[];
unsigned int tid = threadIdx.x;
if (tid < size) {
shared_d... |
19,652 | #include "includes.h"
__global__ void kernel_histo_per_vertex( unsigned int *ct, unsigned int *histo){
// get unique id for each thread in each block
unsigned int tid_x = threadIdx.x + blockDim.x*blockIdx.x;
unsigned int tid_y = threadIdx.y + blockDim.y*blockIdx.y;
if( tid_x >= constant_n_test_vertices ) return;
uns... |
19,653 | #include "includes.h"
__global__ void matrixMultiply(float* a, float* b, float* c, int n)
{
//use block dimentions to calculate column and row
int col = blockIdx.x*blockDim.x + threadIdx.x;
int row = blockIdx.y*blockDim.y + threadIdx.y;
for(int i = 0; i<n; i++)
{
c[row*n + col]+= a[row*n + i] + b[i*n + col];
}
} |
19,654 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
__global__ void warpTest()
{
printf("BlockId: %d, ThreadId: %d\n", blockIdx.x, threadIdx.x);
}
int example2()
{
warpTest << <5, 32 >> > ();
//
getchar();
return 0;
} |
19,655 | #include <stdio.h>
#define N 5
#define M 10
//global means it is called by host, run by device
//mat is the original matrix *already allocated on GPU*
//mat_res is the matrix to store the result *already allocated on GPU*
//s is the scalar, passed directly from host to function
__global__
void mat_mult(int *mat, int... |
19,656 | ///
/// \file multiply_kernel.cuh
/// \brief This file provide different kernel function definations \
/// of matrix multiply. a is M*K, b is K*N. c = a*b, c is M*N.
///
/// \author Rudan Chen
/// \date 2016-01-21
__global__ void kComputeMatMultiply_v1(const float *a, const float *b, \
float *c, const int M, const ... |
19,657 | //Yuxuan Huang
#include <stdio.h>
__global__ void square(float * d_out, float * d_in, int N){
int idx = threadIdx.x + blockIdx.x*blockDim.x;
if (idx < N)
{
float f = d_in[idx];
d_out[idx] = f * f;
}
}
int main(int argc, char ** argv) {
int ARRAY_SIZE;
// taking user input
printf("Pleas... |
19,658 | #include <cuda_runtime_api.h>
#include <iostream>
#include <cstdlib>
#include <time.h>
__global__ void just_launch(){ };
int main(int argc, char** argv){
if (argc != 4){
std::cout << "number_of_blocks number_of_threads cycles" << std::endl;
};
cudaError_t status;
str... |
19,659 | #include "cuda.h"
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <sys/time.h>
void print_matrix(float* mat, int n)
{
std::cout << "matrix:" << std::endl;
for (int i = 0; i < n; ++i)
{
for (int j = 0; j < n; ++j)
{
std::cout << mat[i * n + j] << " ";
}
std::cout << std::endl;
}
}
//... |
19,660 | #include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include <iostream>
#include <iomanip>
#define speed 3.0e8
#define mass 0.511
#define hbar 1.68e-10
#define pi 3.1415
#define S 0.5 //Symmetry factor for two body event
#define g 2.002319 //coupling constant for theory
/********... |
19,661 | #include<bits/stdc++.h>
#include <thrust/device_vector.h>
#include <thrust/host_vector.h>
using namespace std;
int check( float *c, float *b, float *a, int n)
{
for(int i=0;i<n;i++)
{
if(c[i] !=a[i] +b[i])
return 0;
}
return 1;
}
int main(int argc, char *argv[]) {
float *hostInput1 = NULL;
flo... |
19,662 | #include "includes.h"
#define threads 32
#define size 5
using namespace std;
__global__ void callOperation(int *a, int *b, int *res, int k, int p, int n)
{
int tidx = blockDim.x * blockIdx.x + threadIdx.x;
int tidy = blockDim.y * blockIdx.y + threadIdx.y;
if (tidx >= n || tidy >= n) {
return;
}
int tid = tidx ... |
19,663 | //#include "CudaThreadProfiler.cuh"
|
19,664 | #include<time.h>
#include<stdio.h>
typedef unsigned long long Dtype;
__global__ void VecAdd(Dtype** A, int* N, unsigned long long* d_time, Dtype* xj, Dtype* xi)
{
Dtype *j = *A;
unsigned int start_t, end_t;
//for (int it=0; it < *N; it++)
j=*(Dtype **)j;
*xi=*j;
start_t... |
19,665 | /******************************************************************************
*cr
*cr (C) Copyright 2010-2013 The Board of Trustees of the
*cr University of Illinois
*cr All Rights Reserved
*cr
***************************************************************... |
19,666 | #include "includes.h"
__device__ float get_prediction(int factors, const float *p, const float *q, float user_bias, float item_bias, float global_bias) {
float pred = global_bias + user_bias + item_bias;
for (int f = 0; f < factors; f++)
pred += q[f]*p[f];
return pred;
}
__global__ void loss_kernel(int factors, int use... |
19,667 | #include<cuda_runtime.h>
#include<device_launch_parameters.h>
#include<stdio.h>
#include<cmath>
int main(int argc, char **argv) {
printf("%s Starting...\n,argv[0]");
int deviceCount = 0;
cudaError_t error_id = cudaGetDeviceCount(&deviceCount);
if (error_id!=cudaSuccess) {
printf("cudaGetDeviceCount returned %d... |
19,668 | #include <stdio.h>
#include <stdlib.h>
#define N 4096
#define block_Size 256
/* function to integrate, defined as a function on the GPU device */
__device__ float myfunction(float a)
{
return a*a+2.0*a + 3.0;
}
/* kernel function to compute the summation used in the trapezoidal rule
for numerical integration... |
19,669 | // heavy assistance provided from nVidia's CUDA documentation and `vectorAdd.cu` piece of sample code
#include <stdio.h>
#include <sys/time.h>
// For the CUDA runtime routines (prefixed with "cuda_")
#include <cuda_runtime.h>
int* generate_array(int); // prototypes at the top of a non-header, because I hate C.
char* r... |
19,670 | #include <cuda_runtime.h>
#include <stdio.h>
__global__ void checkIndex(void);
int main(int argc, char **argv) {
int nElem = 6;
dim3 block(3); // 1-D block containing 3 threads
dim3 grid((nElem+block.x-1)/block.x); // grid size is rounded up to the multiple of block size
// check grid and block dim ... |
19,671 | #include <thrust/host_vector.h>
#include <thrust/device_vector.h>
#include <thrust/generate.h>
#include <thrust/sort.h>
#include <algorithm>
#include <cstdlib>
#include <cuda.h>
int main(int argc, char* argv[])
{
size_t N = 10000; // Default value
cudaEvent_t start;
cudaEvent_t end;
float elapsed_time;
... |
19,672 | #include "includes.h"
cudaError_t sortWithCuda(int *a, size_t size, float* time);
typedef long long int64;
typedef unsigned long long uint64;
__global__ void swapOnKernel(int *a, int size)
{
int i = blockDim.x * blockIdx.x + threadIdx.x * 2;
int cacheFirst;
int cacheSecond;
int cacheThird;
for (int j = 0; j < siz... |
19,673 | #include "includes.h"
__global__ void simple_corner_turn_kernel(unsigned short *d_input, float *d_output, int nchans, int nsamp) {
size_t t = blockIdx.x * blockDim.x + threadIdx.x;
size_t c = blockIdx.y * blockDim.y + threadIdx.y;
d_output[(size_t)(c * nsamp) + t] = (float) __ldg(&d_input[(size_t)(t * nchans) + c]);
... |
19,674 | #include <cuda.h>
#include <cuda_runtime_api.h>
#include <stdio.h>
#include <assert.h>
#define N 2//8
__device__ double C[2][2][2];
__device__ int index (int a, int b, int c){
return 4*a + 2*b + c;
}
__global__ void foo(double *H) {
int idx = index (threadIdx.x,threadIdx.y,threadIdx.z);
H[idx] = C[threadIdx.... |
19,675 |
#include <stdio.h>
#include <cuda.h>
//
__global__ void MatrixMulKernel(float* M, float* N,float * P,int width,int height,int one_stripe){
int Row = blockIdx.y * blockDim.y + threadIdx.y;
int Col = blockIdx.x * blockDim.x + threadIdx.x;
if((Row<height) && (Col < width)){
float Pvalue = 0;
... |
19,676 | #include <cuda.h>
#include <cuda_runtime.h>
#include <iostream>
using namespace std;
__global__ void arrayadd(int *a,int *b,int *c){
int row=threadIdx.y;
int col=threadIdx.x;
c[2*row+col]=a[2*row+col]+b[2*row+col];
}
int main()
{
int size=4;
int a[size],b[size],c[size];
int *h_a,*h_b,*h_c;
for(int i=0;i... |
19,677 | #include <cuda_runtime.h>
#include <iostream>
#include <vector>
#include <utility>
#include <stdio.h>
#include <math.h>
using namespace std;
#define K 3
#define BLCH 8
#define BLCW 32
#define gpuErrchk(ans) { gpuAssert((ans), __FILE__, __LINE__); }
inline void gpuAssert(cudaError_t code, const char *file, int line, boo... |
19,678 | //
// CUDA code to compute minimu distance between n points
//
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <sys/time.h>
#define MAX_POINTS 1048576
#define BLOCK_SIZE 1024
// ----------------------------------------------------------------------------
// Kernel Function to compute distance betwe... |
19,679 | #include "includes.h"
__global__ void RecurrentWeightsRTRLDerivativesKernel( float *previousHiddenActivations, float *hiddenActivationDerivatives, float *recurrentWeights, float *recurrentWeightRTRLDerivatives, float *previousRecurrentWeightRTRLDerivatives )
{
int partialId = blockDim.x*blockIdx.y*gridDim.x //rows prec... |
19,680 | #include<stdio.h>
#include <stdlib.h>
#include<malloc.h>
#include <time.h>
#include<cuda.h>
#include <iostream>
typedef char* string;
#define HILOSXBLOCK 32 //¿máximo depende de la memorio compartida de la gpu?
//d_A, rowsA, colsA, d_B, rowsB, colsB, d_s_C
__global__
void multGPUSHARE(float* A,int filA,int colA,float... |
19,681 | #include "includes.h"
__global__ void kernel_C( float * _g_data, int dimx, int dimy )
{
float2* g_data = reinterpret_cast<float2 *>(_g_data);
int id = blockIdx.x*blockDim.x + threadIdx.x;
float2 value = g_data[id];
value.x += sqrtf( cosf(value.x) + 1.f );
value.y += sqrtf( logf(value.y) + 1.f );
g_data[id] = ... |
19,682 | #include "includes.h"
__global__ void read_coaleased_write_stride_mat_trans(float* input, float* output, const int nx, const int ny)
{
int ix = blockIdx.x * blockDim.x + threadIdx.x;
int iy = blockIdx.y * blockDim.y + threadIdx.y;
if (ix < nx && iy < ny)
{
output[ix*ny + iy] = input[iy*nx + ix];
}
} |
19,683 | #include <stdio.h>
#include <string.h>
const int NUMCOLS = 8;
const int BLOCKSIZE = 2;
const int GRIDSIZE = 4;
__global__ void kernel (int *v)
{
int row = blockIdx.x * blockDim.x + threadIdx.x;
int col = blockIdx.y * blockDim.y + threadIdx.y;
int tid = row * NUMCOLS + col;
if (blockIdx.x == 0 && bloc... |
19,684 | #include <stdio.h>
#include <assert.h>
#include <curand.h>
#include <curand_kernel.h>
#include <time.h>
#include <sys/time.h>
// Placeholder for longer list of primes
struct list_node{
unsigned long long value;
list_node* next;
};
list_node* prime_list;
// List of primes less than 100 to be checked for divisibil... |
19,685 | #include "includes.h"
//Udacity HW 4
//Radix Sorting
__global__ void swap(unsigned int *in, unsigned int *in_pos, unsigned int *out, unsigned int *out_pos, unsigned int n)
{
unsigned int i = blockIdx.x * blockDim.x + threadIdx.x;
if (i < n)
{
unsigned int temp = in[i];
in[i] = out[i];
out[i] = temp;
temp = in_po... |
19,686 | #include "includes.h"
extern "C" {
}
#define IDX2C(i, j, ld) ((j)*(ld)+(i))
#define SQR(x) ((x)*(x)) // x^2
__global__ void assemble_tensors(double const* tensor_input, double* tensors, int tensor_input_elements){
int tensor_matrix_offset = blockIdx.x * TENSOR_DIMENSIONS * TENSOR_DIMENSION... |
19,687 | #include "fill.cuh"
#include <thrust/device_ptr.h>
#include <thrust/fill.h>
__global__ void borderFillKernel(float *data, int pitch, int width, int height, float value) {
int x = blockIdx.x * blockDim.x + threadIdx.x;
int y = blockIdx.y * blockDim.y + threadIdx.y;
if (x < width && y < height) {
data[y*pitch ... |
19,688 | // This code was devloped by David Barrie Thomas at Imperial College
// http://www.doc.ic.ac.uk/~dt10/research/rngs-gpu-uniform.html
// shared memory allocation for RNG
extern __shared__ unsigned WarpStandard_shmem[];
// RNG
// Public constants
const unsigned WarpStandard_K=32;
const unsigned... |
19,689 | //: nvcc add0.cu -o add0
#include <stdlib.h>
#include <stdio.h>
__global__ void cuda_add(int a, int b, int *c)
{
*c = a + b;
}
int main(int argc, char **argv)
{
int c;
int *dev_c;
cudaMalloc((void**)&dev_c, sizeof(int));
cuda_add<<<1,1>>>(2, 2, dev_c);
/*
* Arguments pour cudaMemcpy
... |
19,690 | #include <stdio.h>
#include <stdlib.h>
#include <cuda_runtime.h>
#include <unistd.h>
#include <sys/wait.h>
#include <sys/time.h>
__global__ void malloc_in_kernel(float* d_a,int n,int length){
float* x;
length = 5;
x = (float*)malloc(sizeof(float)*length);
for(int i = 0 ; i < length ; i ++){
x[i] = 1.0f... |
19,691 | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define err 0.00001
__device__
void f(float x, float *y)
{
// *y = exp(x)-5*pow(x,2); // slide
*y = (pow(x, 2)*(2.1-0.5*x)/(pow(1-x, 2)*(1.1-0.5*x)))-13.616; // 1.a
// *y = tan(x) - x + 1; // 1.b
// *y = 0.5*exp(x/3) - sin(x); // 1.c
}
__global... |
19,692 | #include "includes.h"
__global__ void NormalizeOutput(const int num_elements, const int* original, int64_t* to_normalize, int64_t batch_index, int64_t class_index) {
for (int idx = blockIdx.x * blockDim.x + threadIdx.x; idx < num_elements; idx += blockDim.x * gridDim.x) {
to_normalize[idx * 3] = batch_index;
to_normali... |
19,693 | /*
To Compile:
nvcc 2039281_Task3_A.cu -o task3_A
To Run:
./task3_A
/*****************************************************
BY Subin Shrestha
ID 2039281
--Code to crack code with 2 letters and 2 numbers E.g AA12 using CUDA
--A Custom encryption is made to run on device
--This program encrypts the given te... |
19,694 | #include "includes.h"
__global__ void add(int* a, int* b, int* c)
{
int idx = threadIdx.x + blockIdx.x * blockDim.x;
int idy = threadIdx.y + blockIdx.y * blockDim.y;
if (idx > WIDTH || idy > HEIGHT) return;
c[idy * WIDTH + idx] = a[idy * WIDTH + idx] + b[idy * WIDTH + idx];
} |
19,695 | #include "includes.h"
__global__ void sobelEdgeDetectionSharedMemOverlap(int *input, int *output, int width, int height, int thresh) {
static __shared__ int shMem[_TILESIZE_2 * _TILESIZE_2];
int blocksize = _TILESIZE_2;
int i = blockIdx.x * (_TILESIZE_) + threadIdx.x;
int j = blockIdx.y * (_TILESIZE_) + threadIdx.y;
... |
19,696 | # include <stdio.h>
# include <stdint.h>
# include "cuda_runtime.h"
//compile nvcc *.cu -o test
__global__ void global_latency (unsigned int * my_array, int array_length, int iterations, unsigned int * duration, unsigned int *index);
void parametric_measure_global(int N, int iterations);
void measure_global();
... |
19,697 | #include <stdio.h>
#include <stdlib.h>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <chrono>
//#define N 1000
//#define M 512
//nvcc testing.cu -o test
//
__global__ void add(int *a, int *b, int *c, int n) {
int index = threadIdx.x + blockIdx.x * blockDim.x;
if (index < n)
c[in... |
19,698 | /* userapp.cu
* by Brittle 2009
*
* Template for CUDA programming on AXEL cluster
*/
#include <stdio.h>
#define N 1000
#define tpb 256
#define SIZE N*sizeof(float)
__global__ void kernel(float *A, float *B, float *C) {
int i = blockIdx.x * 256 + threadIdx.x;
if (i < N) // check since some threads may be crea... |
19,699 | #include <stdio.h>
#include <iostream>
using namespace std;
int main() {
int nDevices;
cudaGetDeviceCount(&nDevices);
for (int i = 0; i < nDevices; i++) {
cudaDeviceProp prop;
cudaGetDeviceProperties(&prop, i);
printf("Device Number: %d\n", i);
printf("Device name: %s\n", prop.name);
cout <... |
19,700 | #include <stdio.h>
// Kernel-execution with __global__: empty function at this point
__global__ void kernel(void) {
// printf("Hello, Cuda!\n");
}
int main(void) {
// Kernel execution with <<<1,1>>>
kernel<<<1,1>>>();
printf("Hello, World!\n");
return 0;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.