serial_no int64 1 24.2k | cuda_source stringlengths 11 9.01M |
|---|---|
4,901 | #include <stdio.h>
__device__ unsigned A(unsigned a, unsigned b)
{
while( a & b )
{
unsigned X = a ^ b;
unsigned Y = (a&b)<<1;
a = X;
b = Y;
}
return a ^ b;
}
__device__ unsigned G(unsigned a, unsigned b)
{
for(;b;b^=a^=b^=a%=b);
return !--a;
}
__device__ unsi... |
4,902 | /************************************************************
This program uses Cuda and an Nvidia GPU for matrix multiplication.
A serial version and a parallel version are both implemented. The
serial version uses a single thread on the GPU to do all the
calculations. However, the parallel version uses one thread ... |
4,903 | #include "includes.h"
__global__ void kernel0(int n, float a, float *x, float *y){
int i = blockIdx.x*blockDim.x + threadIdx.x;
if (i < n){
y[i] = a*x[i] + y[i];
}
} |
4,904 | // test the size of shared memory for each block
#include <iostream>
#include <cstdio>
using namespace std;
#define N 100
__const__ int NN = 1;
__global__
void fun(double *py)
{
printf("NN = %d\n", NN);
double a[NN];
*py = 0.;
for (int i=0; i<1000000; ++i)
*py += 3.1415927;
}
int main()
{
double *py, y;
i... |
4,905 | // mpi authors
#include <algorithm> // swap
#include <cstdio>
#include <fstream> // file io
#include <iomanip>
#include <iostream> // io
#include <cmath>
#include <sstream> // string stream
#include <string> // strings
#include <time.h>
using namespace std;
const int VERT = 317080; // from http://snap.stanford.ed... |
4,906 | #include <stdio.h>
__global__ void helloFromGPU() {
int t = threadIdx.x;
printf("Hello World from GPU %d!\n", t);
}
int main() {
printf("Hello World from CPU!\n");
helloFromGPU <<<1,10>>>();
//cudaDeviceReset();
return 0;
} |
4,907 | #include <cstdio>
#define N 64
#define B 1
#define T 64
#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)... |
4,908 |
/*
// Cython function from 'thinc' library
class NumpyOps(Ops):
def backprop_max_pool(self, float[:, ::1] d_maxes,
int[:, ::1] which, int[::1] lengths):
cdef int B = lengths.shape[0]
cdef int O = d_maxes.shape[1]
cdef int T = 0
for length in lengths[:B]:
T ... |
4,909 | #include "cuda_runtime.h"
#include <stdio.h>
#include <iostream>
#include <time.h>
#define M 5
#define N 3
// cuComplex or cuDoubleComplex
#define CPLX cuDoubleComplex
void init_crand(int *data,int size){
for (int i = 0; i < size*2; ++i)
data[i] = rand() %100 - 50;
}
void print_cplx(int *data,int m,int ... |
4,910 |
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <iostream>
#include <stdio.h>
#include <cstdlib>
#include <ctime>
#include <algorithm>
/*
TODOs
Wrong result when size != 2^n
Cannot handle (wrong result) when size is huge
*/
using namespace std;
static void HandleError(cudaError_t err,
co... |
4,911 | #include "includes.h"
__global__ void updateState(float *B, float *external, int dim, float timestep, int length, float L, float M) {
int index = (blockIdx.x * blockDim.x) + threadIdx.x + length;
if (index < length + dim) {
float input = B[index] + external[index];
float old_output = B[index - dim];
float d_layers = (-... |
4,912 | #include "includes.h"
// Device code for ICP computation
// Currently working only on performing rotation and translation using cuda
#ifndef _ICP_KERNEL_H_
#define _ICP_KERNEL_H_
#define TILE_WIDTH 256
#endif // #ifndef _ICP_KERNEL_H_
__global__ void CalculateTotalError(double * distance_d, int... |
4,913 | #include <stdio.h>
#include <inttypes.h>
#ifndef tile_size_x
#define tile_size_x 1
#endif
#ifndef block_size_x
#define block_size_x 512
#endif
#ifndef block_size_y
#define block_size_y 1
#endif
#ifndef window_width
#define window_width 1500
#endif
#define USE_READ_ONLY_CACHE read_only
#if USE_READ_ONLY_CACH... |
4,914 | #include <cuda.h>
#include <cuda_runtime.h>
#include <device_launch_parameters.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#define VALUESMAX 100
#define BMARK -1
#define SIZE 100
#define PRINTMATRIX 1
#define PRINTPERM 0
#define SINGLETONS 0 //1 if singletons 0 if inversions
#define RA... |
4,915 | #include "includes.h"
__global__ void kernel(unsigned char *ptr, int ticks){
// map from threadIdx/BlockIdx to pixel positions
int x = threadIdx.x + blockIdx.x * blockDim.x;
int y = threadIdx.y + blockIdx.y * blockDim.y;
int offset = x + y * blockDim.x * gridDim.x;
// now calculate the value at that position
float fx ... |
4,916 | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define INF 1073741824
#define BLOCK_SZ 16
#define BUFFER_SZ 32
int m; // nodes
int n; // dimensions
int k; // k-nearest
// input sample file
int* load(const char *input)
{
FILE *file = fopen(input, "r");
if (!file) {
fprintf(stderr, "Error: no... |
4,917 | //pass
//--gridDim=[32768,1,1] --blockDim=[512,1,1]
__global__ void init_array(int *g_data, int *factor, int num_iterations)
{
int idx = blockIdx.x * blockDim.x + threadIdx.x;
for (int i=0; i<num_iterations; i++)
{
g_data[idx] += *factor; // non-coalesced on purpose, to burn time
}
}
|
4,918 | #include "includes.h"
__global__ void cuSincInterpolation_kernel(const int nImages, const float * imagesIn, const int inNX, const int inNY, float * imagesOut, const int outNX, const int outNY, const float * r_filter_, const int i_covs_, const int i_decfactor_, const int i_intplength_, const int i_startX, const int i_st... |
4,919 | //
// Created by bluet on 06/04/2021.
//
/**
*\file normal_force_hertz.c
*\brief body of the function normal_force_hertz
*/
#include "normal_force_hertz.cuh"
__device__ double normal_force_hertz(double deltan,double deltandot, double rij, double Eij, double Aij)
{
double fcnij;
// The interaction force is ... |
4,920 | #include <cstdlib>
#include <iostream>
#include <algorithm>
#include <random>
#include <chrono>
#include <cuda.h>
#include <cuda_runtime.h>
__host__
__device__
void vector_mul(float *out, float *a,
float *b, size_t n) {
for(size_t i = 0; i < n; i ++){
out[i] = a[i] * b[i];
}
}
__global__
void ... |
4,921 | // FILE: ising3d_q.c
//
// 1) H = -J \sum_{\langle i,j \rangle} \sigma_i \sigma_j , J > 0 for FM
//
//
// 2. Lattice labelings :
//
//
// j3
// . j4 (+z)
// | . +z
// | / ... |
4,922 |
#include <iostream>
using namespace std;
__global__ void kernel( int* n) { *n = 3;}
int main()
{
int n;
int* d_n;
// store in d_n the address of a memory
// location on the device
cudaMalloc( (void**)&d_n, sizeof(int));
kernel<<<1,1>>>(d_n);
cudaMemcpy( &n, d_n, sizeof(int), cudaMemcpyDeviceToHost);... |
4,923 | // The cuda device properties
#include <stdio.h>
int main() {
cudaDeviceProp dev_prop;
cudaGetDeviceProperties(&dev_prop, 0);
printf("Comput cappbility %i and %i\n", dev_prop.major, dev_prop.minor);
printf("SP count %i\n", dev_prop.multiProcessorCount);
printf("The maximum amount of threads per Bloc... |
4,924 | #include <stdlib.h>
#include <time.h>
#include <stdio.h>
#include <cuda.h>
#include "cuda_runtime.h"
#define ROWSIZE 8192 // Number of Columns
#define COLSIZE 8192 // Number of Rows
#define SIZE (ROWSIZE * COLSIZE) // total Size
#define BLOCKWORK 2
#define num_threads 32 // number of threads per block
int num_blo... |
4,925 | #include <stdio.h>
void test1() {
int* a = new int;
*a = 3;
*a = *a + 2;
printf("%d\n", *a);
}
void test2() {
int* a = (int*)malloc(sizeof(int));
int* b = (int*)malloc(sizeof(int));
if (!(a && b)) {
printf("Out of memory\n");
exit(-1);
}
*a = 2;
*b = 3;
}
void... |
4,926 | #include "includes.h"
extern "C"
{
}
__global__ void updateParams(int N, int M, float alpha, float beta1, float beta2, float t, float *PARAMS, float *GRADS, float *m, float *v)
{
int i = blockIdx.x * blockDim.x + threadIdx.x;
int j = blockIdx.y * blockDim.y + threadIdx.y;
int index = j*N + i;
float beta1r... |
4,927 | #include <iostream>
#include <stdio.h>
#include <time.h>
#include <math.h>
#define N 2000
using namespace std;
void fill_matrix(int *m,char c){
cout<<"Llenamos matriz "<<endl;
for(int i=0;i<N;i++){
for(int j=0;j<N;j++){
switch(c){
case 's':
m[i*N+j] = sin(i);break;
case 'c':
m[i*N+j] = cos(i... |
4,928 | #include<cuda_runtime.h>
#include<cufft.h>
#include<cufftXt.h>
#include<stdio.h>
#include<string>
#include<math.h>
cufftComplex* read_file(std::string file_path, size_t * size, bool shrink){
size_t size2 = 1000000;
//*size = get_data_size(file_path);
//shrink the sample into a power of 2 so that transformations are ... |
4,929 | template<typename T>
__device__ void vectorAddScalar(const T* A, const T scalar, T* C, const int length) {
int bx = blockIdx.x;
int tx = threadIdx.x;
int index = bx * blockDim.x + tx;
if (index < length) {
C[index] = A[index] + scalar;
}
}
template<typename T>
__device__ void vectorSubScalar(const T* ... |
4,930 | #include "includes.h"
// First solution with global memory
// Shared memory residual calculation
// Reduction code from CUDA Slides - Mark Harris
__global__ void gpu_Heat (float *u, float *utmp, float *residual,int N) {
// TODO: kernel computation
int sizey = N;
int j = blockIdx.x * blockDim.x + threadIdx.x;
int i ... |
4,931 | #include <stdio.h>
#include <math.h>
#define THRDS_P_BLK 256
__global__
void saxpy(int n, float a, float *x, float *y)
{
int i = blockIdx.x*blockDim.x + threadIdx.x;
if (i < n) y[i] = a*x[i] + y[i];
}
__global__
void normalization_and_sum(int size, double maxx, double range, double *inputArr, double *x0, double... |
4,932 | #include "includes.h"
extern "C" {
}
#define TB 256
#define EPS 0.1
#undef MIN
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#undef MAX
#define MAX(a, b) ((a) > (b) ? (a) : (b))
__global__ void Ring_kernel( float *A, float *BP, int *corrAB, float *M, int ring, int c, int h, int w )
{
int id1 = blockIdx.x * blockDim.... |
4,933 | #include "includes.h"
/*
* Copyright 1993-2015 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 soft... |
4,934 | #include <bits/stdc++.h>
#include <cuda.h>
#define BLOCK_SIZE 1024
using namespace std;
__global__ void sum(int *d_A, int *d_B, int *d_C, int n) {
int i = blockIdx.x * blockDim.x + threadIdx.x;
//if(i < n*n)
d_C[i] = d_A[i] + d_B[i];
}
__global__ void sumR(int *d_A, int *d_B, int *d_C, int n) {
int i = bl... |
4,935 | /*
Kam Pui So (Anthony)
CS510 GPU
Project Group A
Application:
Matrix Multiplication based on CUDA TOOLKIT Documentation
This version of matrix multiplication does not use share memory.
*/
#include <stdio.h>
#include <time.h>
#include <sys/time.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#define SC... |
4,936 | __global__ void fillTwoFloatsArraysKernel(
int numberRows,
int numberEntries,
float* firstArray,
float firstConstant,
float* secondArray,
float secondConstant) {
int index = blockIdx.x * numberEntries + blockIdx.y * numberRows + threadIdx.x;
firstArray[index] = firstConstant;
secon... |
4,937 | //
// Created by root on 2020/11/20.
//
#include "stdio.h"
#include "cuda_runtime.h"
#define BDIM 32
#define RADIUS 4
#define a0 0.00000f
#define a1 0.80000f
#define a2 -0.20000f
#define a3 0.03809f
#define a4 -0.00357f
__constant__ float coef[RADIUS + 1];
// constant memory is 64KB for each proc... |
4,938 | #include "cuda_runtime.h"
#include<iostream>
#include <chrono>
#include <cstdlib>
#include "device_launch_parameters.h"
// Select the size of the matix of dim [ SIZE X SIZE ]
#define SIZE 1024
using namespace std;
//Ensure to add the __global__ block when performing GPU operations
__global__ void gpu_multer(double... |
4,939 | #include "includes.h"
//Library Definition
//Constant Definition
#define PI 3.141592654
#define blocksize 32
#define Repetitions 8192
//Print matrix into standard output
void print(double * M,int cols,int rows);
void dot(double * a,double * b, double & c, int cols);
void Create_New_Matrix(double * M,double * New,int... |
4,940 | #include "includes.h"
__global__ void kernel(double *Dens, double *VradInt, double *VthetaInt, double *TemperInt, int nrad, int nsec, double *invdiffRmed, double *invdiffRsup, double *DensInt, int Adiabatic, double *Rmed, double dt, double *VradNew, double *VthetaNew, double *Energy, double *EnergyInt)
{
int j = thread... |
4,941 | #define d_vx(z,x) d_vx[(x)*(nz)+(z)]
#define d_vy(z,x) d_vy[(x)*(nz)+(z)]
#define d_vz(z,x) d_vz[(x)*(nz)+(z)]
#define d_sxx(z,x) d_sxx[(x)*(nz)+(z)]
#define d_szz(z,x) d_szz[(x)*(nz)+(z)]
#define d_sxz(z,x) d_sxz[(x)*(nz)+(z)]
#define d_vz_adj(z,x) d_vz_adj[(x)*(nz)+(z)]
#define d_vx_adj(z,x) d_vx_adj[(x)*(nz)+(z... |
4,942 | #include <iostream>
#include <cuda.h>
// includes CUDA Runtime
#include <cuda_runtime.h>
#include <cuda_profiler_api.h>
/*
written by George Strauch on 4/21/2020
c++ program to sort an array with bubblesort on gpu
Execution syntax:
$ ./exec {int num of elements}
Example run:
$ nvcc gpu_bubble.cu -arch='sm_35' -rdc... |
4,943 | #define INF 2e10f
struct Sphere{
float r,b,g;
float radius;
float x,y,z;
__device__ float hit (float ox,float oy,float *n){
float dx = ox - x;
float dy = oy - y;
if(dx*dx + dy*dy < radius*radius){
float dz = sqrtf(radius*radius - dx*dx - dy*dy);
*n = dz /... |
4,944 | #include <stdio.h>
#define SRC_SIZE 65536
#define DST_SIZE 65536
#define CPY_SIZE 8192
int main() {
int *h_mem = (int*)malloc(SRC_SIZE*sizeof(int));
memset(h_mem, 0, SRC_SIZE*sizeof(int));
int *d_mem;
cudaMalloc((void**)&d_mem, DST_SIZE*sizeof(int));
cudaMemset(d_mem, 0, DST_SIZE*sizeof(int));
... |
4,945 | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <assert.h>
inline cudaError_t checkCuda(cudaError_t result)
{
if (result != cudaSuccess) {
fprintf(stderr, "CUDA Runtime Error: %s\n", cudaGetErrorString(result));
assert(result == cudaSuccess);
}
return result;
}
__globa... |
4,946 | #include <stdio.h>
#include <math.h>
#include <float.h>
typedef struct {
int x, y;
} Point;
typedef struct {
float4 avg;
double inverse_cov[3][3];
double log_det;
} Class;
__constant__ Class dev_class[32];
float4 Average(uchar4 *data, int w, int h, Point *class_points, int point_n) {
float4 res... |
4,947 | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <cuda_runtime_api.h>
#include <curand.h>
#include "curand_kernel.h"
#include <assert.h>
// L should be (multiple of (THR_NUMBER - 2) ) + 2
#define L 114
const int AREA = L*L;
const int NTOT = (L-2)*(L-2);
// #define T 6.
// #define T 0.1
// #define T... |
4,948 | /* ==================================================================
Programmer: Yicheng Tu (ytu@cse.usf.edu)
The basic SDH algorithm implementation for 3D data
To compile: nvcc SDH.c -o SDH in the rc machines
==================================================================
*/
/*
Daniel Burkholder
June 6 2... |
4,949 |
__global__ void buildUstar(float *Ustar, float *U, float *R, float *ShearSource, float dt, int m, int n)
{
// Calculate the row and column of the thread within the thread block
int row = blockIdx.y * blockDim.y + threadIdx.y;
int col = blockIdx.x * blockDim.x + threadIdx.x;
// First check if the thread is opera... |
4,950 | //////////////////////////////////////////////////////////////////////////
////This is the code implementation for GPU Premier League Round 2: n-body simulation
//////////////////////////////////////////////////////////////////////////
#include <iostream>
#include <fstream>
#include <vector>
#include <chrono>
#include ... |
4,951 | #include "includes.h"
__global__ void findLabels(int nPixels, int filterCount, int clusterCount, float* responses, float* centroids, int* clusters, int* changes) {
__shared__ float sharedCentroids[34 * 32];
__shared__ unsigned int localChanges;
int x = blockDim.x * blockIdx.x + threadIdx.x;
if (threadIdx.x < 32) {
for(... |
4,952 |
/*************************************
* Matrix-Vector product CUDA kernel *
* V2: With Shared memory *
*************************************/
#include <stdio.h>
#define CUDA_SAFE_CALL( call ) { \
cudaError_t err = call; ... |
4,953 | #include <iostream>
#include <stdio.h>
#include <cuda.h>
#include <math.h>
#include <chrono>
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
__global__ void maximum(int *input) {
int tid = threadIdx.x;
int step_size = 1;
int number_of_threads = blockDim.x;
while(number... |
4,954 | #include <stdio.h>
#include <stdlib.h>
#include <time.h>
__device__ void partition_by_bit(unsigned int *values, unsigned int bit);
__global__ void radix_sort(unsigned int *values)
{
int bit;
for( bit = 0; bit < 32; ++bit )
{
partition_by_bit(values, bit);
__syncthreads();
}
}
__devi... |
4,955 | #include<bits/stdc++.h>
#include<cuda.h>
#define PI 3.14159265
#define BlockSize 1024
using namespace std;
__global__ void FD(float *U_d, int T, int N,float r){
int idx = blockIdx.x*blockDim.x + threadIdx.x;
for(int t=1; t<T; ++t){
U_d[t*N]=0;
U_d[t*N+(N-1)]=0;
if(idx>0 && idx<N-1){
... |
4,956 | //#include "thand.h"
#include <cuda.h>
#include <cuda_runtime_api.h>
#include <stdio.h>
#include <pthread.h>
#define CYCLE 1024 * 1024 * 1024
#define THREAD 1
int * count;
__global__ void Check_gpu(int * count)
{
#if 1
__syncthreads();
while(*count < CYCLE)
{
//printf("\n\n\n\n\n\n");
//printf("____________G... |
4,957 | #include "includes.h"
__global__ void dset_kernel(double *vals, int N, double mu)
{
// Taken from geco.mines.edu/workshop/aug2010/slides/fri/cuda1.pd
int myblock = blockIdx.x + blockIdx.y * gridDim.x;
/* how big is each block within a grid */
int blocksize = blockDim.x * blockDim.y * blockDim.z;
/* get thread within a ... |
4,958 | #include <iostream>
#include <iomanip>
#include <cstdlib>
#include <stdlib.h>
#include <cstdio>
// Fourth order interpolation function.
__host__ __device__ inline double interp(const double m2, const double m1, const double p1, const double p2)
{
return (-1./16)*(m2+p2) + (9./16)*(m1+p1);
}
// Fourth order gradient... |
4,959 | #include "includes.h"
__global__ void calc_avg_activation_kernel(float *src, float *dst, int size, int channels, int batches)
{
int i = blockIdx.x * blockDim.x + threadIdx.x;
int xy = i % size;
int b = i / size;
if (i < size*batches) {
dst[i] = 0;
for (int c = 0; c < channels; ++c) {
dst[i] += src[xy + size*(c + chann... |
4,960 | // REQUIRES: x86-registered-target
// REQUIRES: nvptx-registered-target
// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm \
// RUN: -fopenmp -fopenmp-version=50 -o - %s | FileCheck %s
// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm \
// RUN: -fopenmp -fopenmp-version=50 -o - -x c++ %s... |
4,961 | #define REORDER 0
#define GOOD_WEATHER 0
#define BAD_WEATHER 1
#define TAG_Car 0
#define TAG_Pedestrian 1
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
//#include <random>
//#include <array>
#include <algorithm>
#define NUM_CARS 4096
#define NUM_PEDS 16384
#define NUM_STREETS 500
#define MAX_CONNECTION... |
4,962 | #include "includes.h"
__global__ void transpose_unroll4_row(int * mat, int * transpose, int nx, int ny)
{
int ix = blockIdx.x * blockDim.x * 4 + threadIdx.x;
int iy = blockIdx.y * blockDim.y + threadIdx.y;
int ti = iy * nx + ix;
int to = ix * ny + iy;
if (ix + 3 * blockDim.x < nx && iy < ny)
{
transpose[to] = ma... |
4,963 | #define CUDA_SAFE_CALL(func) \
do { \
cudaError_t err = (func); \
if (err != cudaSuccess) { \
fprintf(stderr, "[Error] %s (error code: %d) at %s line %d\n", cudaGetErrorString(err), err, __FILE__, __LINE__); \
exit(err); \
} \
} while (0)
__global__ void
cudaProc... |
4,964 | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <cuda.h>
typedef unsigned char BYTE;
#define IMAGE_SIZE 6*1000*1000
#define MAXITER 1000
#define X_RES 1000
#define Y_RES 1000
// Write Mandelbrot image in PGM format
void writeOutput(const char *fileName, BYTE *image, int width, int height) {
... |
4,965 | #include <iostream>
// Everything done by Rolf Andreassen!
using namespace std;
__device__ bool* syncArray = 0;
__device__ void device_vector_reduce_blocks_recursive (double* toBeReduced, int workingLength) {
syncArray[blockDim.x] = false;
// First reduce this block
// Copy from global to shared memory for... |
4,966 | #include <stdio.h>
#include <stdlib.h>
#include <sys/timeb.h>
#include <cuda_runtime.h>
#define N 1500000000
int cudaCheck(cudaError_t code) {
if(code == cudaSuccess) {
//printf("cudaSuccess\n");
return 0;
} else {
printf("cudaCheck(): %s\n", cudaGetErrorString(cudaGetLastError()));
return -1;
}
}
int mai... |
4,967 | // Multiplicação de matrizes em CUDA
// Disciplina: OPRP001 - Programação Paralela
// Prof.: Mauricio Pillon
// Aluno: Renato Tanaka
#include <cuda.h>
#include <stdio.h>
#include <math.h>
// Matriz Quadrada (nro_linhas = nro_colunas)
#define N 4 // Número de linhas
// Número de colunas
// GPU: Multiplic... |
4,968 | // ][ -> *n+
__device__ void lubksb(float* a, int* indx, float* b)
{
int i,ii=0,ip,j;
float sum;
int n = 5;
for (i=0;i<n;i++) {
ip=indx[i];
sum=b[ip];
b[ip]=b[i];
if (ii != 0)
for (j=ii-1;j<i;j++) sum -= a[i*n+j]*b[j];
else if (sum != 0.0)
ii=i+1;
b[i]=sum;
}
for (i=n-1;i>=0;i--) {
sum=b[i];... |
4,969 | #include <stdio.h>
__global__ void test(int* dataD, int* sumD) {
for (int i = 0; i < 1000000; i++) {
int x = dataD[0];
int y = dataD[1];
int z = dataD[2];
int sum = x+y+z;
*sumD += sum;
}
}
int main() {
int* dataH = (int*)malloc(sizeof(int)*10);
for (int i = 0; i < 10; i++) {
dataH[i] = i;
}
int* d... |
4,970 | #include <thrust/device_vector.h>
#include <stdio.h>
/*
* Function: load_char
* --------------------
* copies a subset u * m of data into output vector
*
* output_vector: destination output vector
* u: number of users to copy
* m: number of movies to copy
*
* returns: Nothing
*/
void load_char(thrust::... |
4,971 | #include <iostream>
#include <cuda.h>
#include <cuda_runtime.h>
#include <stdio.h>
#include <thrust/host_vector.h>
#define THREADS_PER_BLOCK 256
using namespace std;
__global__ void maskCompute(uchar4 *sourceImg,bool *mask,int cols,int rows)
{
int id=blockIdx.x*blockDim.x+threadIdx.x;
int size=cols*rows;
mask[id... |
4,972 | #include "includes.h"
__global__ void mAddDrip(float *dense, int centerX, int centerY, float redius) {
int Idx = blockIdx.x * blockDim.x + threadIdx.x;
int x = threadIdx.x;
int y = blockIdx.x;
float length = sqrt((float)((x-centerX)*(x-centerX))+(float)((y-centerY)*(y-centerY)));
if(length < redius) {
dense[Idx] += 20... |
4,973 | #include "includes.h"
__global__ void k2(int *Aux,int *S){
Aux[threadIdx.x]=S[(threadIdx.x+1)*B-1];
} |
4,974 | #include "includes.h"
__global__ void myset(unsigned long long *p, unsigned long long v, long long n) {
const long long tid = blockIdx.x * blockDim.x + threadIdx.x;
if (tid < n) {
p[tid] = v;
}
return;
} |
4,975 | #include <cuda.h>
#include <cuda_runtime.h>
#include <stdio.h>
__global__ void transformKernel(float *outputData, int width, int height, float theta, cudaTextureObject_t tex){
// calculate normalized texture coordinates
unsigned int x = blockIdx.x*blockDim.x + threadIdx.x;
unsigned int y = blockIdx.y*blockD... |
4,976 | #include <cuda_runtime_api.h>
#include <cuda.h>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
using namespace std;
void cuSetDeviceFlags(){
cudaSetDeviceFlags(cudaDeviceMapHost);
}
void cuMallocManaged(void** h_img, int r, int c){
cudaMallocManaged(h_img,sizeof(unsigned char)*r*c);
}
void cuMalloc(vo... |
4,977 | #include "includes.h"
__global__ void rgb2gray (float * input, float *output, int height, int width)
{
int x = blockIdx.x * blockDim.x + threadIdx.x;
int y = blockIdx.y * blockDim.y + threadIdx.y;
if(x<height && y<width)
{
unsigned int idx = x* width + y;
float r = input[3 * idx];
float g = input[3 * ... |
4,978 | #include "includes.h"
__global__ void KerComputeVelMod(unsigned n,const float4 *vel,float *velmod)
{
unsigned p=blockIdx.x*blockDim.x + threadIdx.x; //-Number of particle.
if(p<n){
const float4 r=vel[p];
velmod[p]=r.x*r.x+r.y*r.y+r.z*r.z;
}
} |
4,979 | /*
Compiling with nvcc:
nvcc mat_mul.cu -o mat_mul -std=c++11
./mat_mul
Sample Output:
[Enter size of square matrix]
100
[matrix multiplication of 100 elements]
Time taken for matrix multiplication without shared memory : 20 microseconds
Time taken for matrix multiplication with shared memory : 9 microseconds
*/
// Ma... |
4,980 | #include<stdio.h>
#include<stdlib.h>
__device__ int gpuHistogram[10];
__global__ void computeGpuHistogram(int *arr, int noOfElements)
{
//clear the global gpu Histogram array
if(blockIdx.x == 0 && threadIdx.x < 10)
gpuHistogram[threadIdx.x] = 0;
//force all threads to wait for the first 10 threads
__syncth... |
4,981 | #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#define ITERATIONS 100
#define ARR_SIZE 1000000
#define ARR_SIZE_PRINT_LIMIT 100
//CUDA values
#define NUM_BLOCKS 4096
#define NUM_THREADS 1
//Random values range
const int MIN_RAND_NUM = -100;
const int MAX_RAND_NUM = 100;
void print_array(... |
4,982 | #include "includes.h"
__global__ void update(int* U, int* F, int* d, int* del, size_t gSize) {
int globalThreadId = blockIdx.x * blockDim.x + threadIdx.x;
if (globalThreadId < gSize) {
F[globalThreadId] = 0;
if(U[globalThreadId] && d[globalThreadId] < del[0]) {
U[globalThreadId] = 0;
F[globalThreadId] = 1;
}
}
} |
4,983 | #include <cuda.h>
#include <thrust/sort.h>
#include <thrust/host_vector.h>
#include <thrust/device_vector.h>
#include <stdlib.h>
#include <stdio.h>
int main(){
thrust::host_vector<float> H;
float r;
for(int i=0; i<100; i++ ){
r = static_cast <float> (rand()) / static_cast <float> (RAND_MAX);
... |
4,984 | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
__global__ void vectorSum(float *a, float *b, float *c){
int i = threadIdx.x + blockIdx.x * blockDim.x;
c[i] = a[i] + b[i];
}
int main(int argc, char *argv[]){
unsigned int length = 4194304;
int i, Size;
float *a, *b, *c, *copyC, *gp... |
4,985 | extern "C" {
//灰度图像一维数据第一种访问方式
__global__ void image_add_gray_1(int* img1, int* img2, int* imgres, int length){
// 一维数据索引计算(万能计算方法)
int tid = blockIdx.z * (gridDim.x * gridDim.y) * (blockDim.x * blockDim.y * blockDim.z) \
+ blockIdx.y * gridDim.x * (blockDim.x * blockDim.y * b... |
4,986 | /*
* Ejercicio 4 Práctica 4: CUDA
* Mariana Hernández
* Alan Córdova
*/
#include <stdlib.h>
#include <math.h>
#include <stdio.h>
#include <time.h>
# define NPOINTS 2000
# define MAXITER 2000
#define ARRAY_SIZE 256
#define NUM_BLOCKS 1
#define THREADS_PER_BLOCK 256
struct complex{
double real;
double ima... |
4,987 | /* CUDA version of the DBNN code for classification of stars, galaxies. The code was originally written by Prof. Sajeeth
Author: Ajay Vibhute
*/
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <iostream>
using namespace std;
#include <stdlib.h>
#include<sys/times.h> // times() fun. is here.
#inclu... |
4,988 | // cuda_example3.cu : Defines the entry point for the console application.
//
#include <stdio.h>
#include <string.h>
#include <cuda.h>
const int N = 64;
__global__ void foo( float **a, int N )
{
int i = blockIdx.x * blockDim.x + threadIdx.x;
int j = blockIdx.y * blockDim.y + threadIdx.y;
if ( i < N && j... |
4,989 | //pass
//--gridDim=8 --blockDim=512
__global__ void simpleKernel(int *dst, int *src, int num)
{
// Dummy kernel
int idx = blockIdx.x * blockDim.x + threadIdx.x;
dst[idx] = src[idx] / num;
}
|
4,990 | #include<stdio.h>
#include<assert.h>
#include<cuda.h>
#include<errno.h>
#include<math.h>
#include<sys/time.h>
#define MAX_VAL 10
#define BLOCK_WIDTH 256
#define MAX_SIZE 2048*2048*2
cudaError_t cuerr;
float* createArray(int size)
{
float *temp;
int err=0;
errno = 0;
temp = (float*) malloc (sizeof(float)... |
4,991 | #include <stdio.h>
#include <stdlib.h>
__global__ void foo(int *ptr){
*ptr = 7;
}
int main(){
foo<<<1,1>>>(0);
cudaThreadSynchronize();
cudaError_t error = cudaGetLastError();
if(error != cudaSuccess){
printf("Cuda error: %s\n", cudaGetErrorString(error));
exit(-1);
}
return 0;
} |
4,992 | #include <thrust/host_vector.h>
#include <thrust/device_vector.h>
#include <thrust/sort.h>
#include <thrust/copy.h>
#include <thrust/sequence.h>
#include <thrust/random.h>
#include <thrust/generate.h>
#include <thrust/detail/type_traits.h>
#include <algorithm>
#include <time.h>
#include <limits.h>
#include <math.h>
b... |
4,993 | #include <iostream>
#include "../include/matrixMultiplication.cuh"
namespace blas3{
namespace cudaBlas {
__global__ void
naiveMatrixMultiplication(float *MatA, float *MatB, float *result, size_t m, size_t n, size_t k) {
unsigned int column_id = blockIdx.x * blockDim.x + threadIdx.x;
... |
4,994 | #include "includes.h"
__global__ void setTensorCheckPatternKernel(unsigned int* data, unsigned int ndata) {
for (unsigned int i = threadIdx.x + blockIdx.x*blockDim.x;i < ndata;i += blockDim.x*gridDim.x) {
data[i] = i;
}
} |
4,995 | #include <stdio.h>
#include <float.h>
void __global__ kernel_isnan(float* array_device, int* rowArray, int rowArrayLength, int* colArray, int colArrayLength, int totalCols, int totalRows, float* results)
{
int n = blockIdx.x * blockDim.x + threadIdx.x;
int m = blockIdx.y * blockDim.y + threadIdx.y;
if (n < rowA... |
4,996 | #include "cuda_runtime.h"
#include <iostream>
#include <fstream>
#include <chrono>
#include <string>
__global__ void reduction(const int* data, const int size, int* output) {
extern __shared__ int shared_data[];
int indx = blockIdx.x * blockDim.x + threadIdx.x;
shared_data[threadIdx.x] = data[indx];
__syncthre... |
4,997 | #include "includes.h"
__global__ void grayscale(float4* imagem, int width, int height)
{
const int i = blockIdx.x * (blockDim.x * blockDim.y) + blockDim.x * threadIdx.y + threadIdx.x;
if(i < width * height)
{
float v = 0.3 * imagem[i].x + 0.6 * imagem[i].y + 0.1 * imagem[i].z;
imagem[i] = make_float4(v, v, v, 0);
}
} |
4,998 | #include <stdio.h>
#include <assert.h>
#include <cuda_runtime.h>
//#include <helper_functions.h>
//#include <helper_cuda.h>
#ifndef MAX
#define MAX(a, b) (a > b ? a : b)
#endif
__global__ void testKernel(int val)
{
printf("[%d, %d]:\t\tValue is:%d\n", blockIdx.y*gridDim.x+blockIdx.x, \
threadIdx.z*blockDim.x*bloc... |
4,999 |
#include <cuda_runtime.h>
#include <device_launch_parameters.h>
#include <cuda.h>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <ctype.h>
// #include "cudaDefines.h"
struct ImgProp {
uint32_t Hpixels;
uint32_t Vpixels;
uint8_t HeaderInfo[14];
uint8_... |
5,000 | #include "includes.h"
__global__ void calculateError(float *aFourth, float *err, int expectedOutput)
{
int i = threadIdx.x;
err[i] = aFourth[i] - (i + 1 == expectedOutput);
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.