serial_no int64 1 24.2k | cuda_source stringlengths 11 9.01M |
|---|---|
801 | #include <stdio.h>
int main(void){
printf("hello world!!\n");
return 0;
}
|
802 | #include <iostream>
#include <random>
#include <cuda_runtime_api.h>
#include <sys/time.h>
#include <vector>
struct RGBPoint {
float x;
float y;
float z;
float r;
float g;
float b;
float a;
RGBPoint() {}
RGBPoint(float x, float y, float z, float r, float g, float b, float a) : x(x), ... |
803 | //MIT License
//
//Copyright(c) 2020 Zheng Jiaqi @NUSComputing
//
//Permission is hereby granted, free of charge, to any person obtaining a copy
//of this software and associated documentation files(the "Software"), to deal
//in the Software without restriction, including without limitation the rights
//to use, copy, m... |
804 | #include "stdio.h"
#include "float.h"
#include <cuda.h>
#define HILOS 128
#define PATH "./inputs/randomData_2M_3feature.csv"
#define CANT_FEATURES 3
#define CANT_MEANS 4
#define CANT_ITERACIONES 100
#define MAX_DOUBLE DBL_MAX
//Funciones CUDA
__global__ void kMeansClusterAssignment(double* means_dev, double* items_de... |
805 | /*
* EzUpdaterTM.cpp
*
* Created on: 11 янв. 2016 г.
* Author: aleksandr
*/
#include "EzUpdaterTM.h"
#include "SmartIndex.h"
#include <thrust/device_vector.h>
#include <thrust/functional.h>
// x x x x x
// x o o o x
// x o o o x
// x o o o x
// x x x x x
/*__host__ __device__
void EzUpdaterTM::... |
806 | #include "includes.h"
/*This file is part of quantumsim. (https://github.com/brianzi/quantumsim)*/
/*(c) 2016 Brian Tarasinski*/
/*Distributed under the GNU GPLv3. See LICENSE.txt or https://www.gnu.org/licenses/gpl.txt*/
//kernel to transform to pauli basis (up, x, y, down)
//to be run on a complete complex density ... |
807 | #include <cuda_runtime.h>
#include <device_launch_parameters.h>
#include <cufft.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#define TPBx 32 // TPBx * TPBy = number of threads per block
#define TPBy 32
__global__ void real2complex(cufftDoubleComplex *c, double *a, int n);
__global__ void complex2re... |
808 | #include <stdio.h>
#include <cuda.h>
// setting array and block size
#define ARRAY_SIZE 1048576
#define BLOCK_SIZE 1024
// helper function for calculating upper ceil of division
int upper_ceil(int numerator, int denominator) {
if(numerator % denominator == 0){
return numerator/denominator;
}
retu... |
809 | #include <stdio.h>
#include <time.h>
#include "md5LibCPU.cu"
#define WORD_SIZE 512
#define MD5_SIZE 32
#define UINT4 uint
int getNumberOfWords(FILE*);
int main(int argc, char ** argv){
// Random Seed
srand(time(NULL));
// Get file name where MD5 to be cracked is stored
FILE * inputFile = fopen(argv[1],"r");
// ... |
810 | #include "includes.h"
__global__ void add(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];
} |
811 |
#include <cuda.h>
#include <cuda_runtime.h>
#include <iostream>
int __host__ file1_sq_func(int x)
{
cudaError_t err;
int nDevices = 0;
err = cudaGetDeviceCount(&nDevices);
if(err != cudaSuccess)
{
std::cout << "nDevices: " << nDevices << std::endl;
std::cout << "err: " << err << std::endl;
retur... |
812 | #include <cstdio>
#define cudaErrChk(ans) { cudaAssert((ans), __FILE__, __LINE__); }
inline void cudaAssert(cudaError_t code, const char *file, int line, bool abort=true)
{
if (code != cudaSuccess)
{
fprintf(stderr,"CUDA assert: %s %s %d\n", cudaGetErrorString(code), file, line);
if (abort) exit(cod... |
813 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include <math.h>
#include<time.h>
#include<stdlib.h>
#define arrayLength 10000
float a[10240000],b[10240000];
float c[1048576];
cudaError_t addWithCuda(float *c, const float *a, const float *b, unsigned int size);
double randf()
{
... |
814 | #include "includes.h"
/**
* Maestría en Ciencias - Mención Informática
* -------------------------------------------
* Escriba un programa CUDA que calcule C = n*A + B, en donde A, B, C son vectores
* y n una constante escalar.
*
* Adaptado de https://www.olcf.ornl.gov/tutorials/cuda-vector-addition/
*
* Presentado por... |
815 |
#include <stdio.h>
#include <stdlib.h>
// Kernel to give a value
__global__ void value( int *a ){
*a = 1;
}
// Main program
int main(void){
int *a; // Host memory
int *a_dev; // Device memory
int size = sizeof(int); // size of integer
a = (int *) mallo... |
816 | #include <iostream>
#include <cstdio>
#include <chrono>
using namespace std;
__global__ void kernel(double *res, double *arr1, double *arr2, int n) {
int idx = blockDim.x * blockIdx.x + threadIdx.x; // Абсолютный номер потока
int offset = blockDim.x * gridDim.x; // Общее кол-во потоков
for(int i = ... |
817 | // fermi
/*
* Copyright 2018 Vrije Universiteit Amsterdam, The Netherlands
*
* 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
* Unles... |
818 | #include "Datastructures.cuh"
#include <thrust/host_vector.h>
#include <vector>
#include <iterator>
#include <algorithm>
namespace DATASTRUCTURES {
thrust::host_vector<double6> hostVectorD6FromStdVector(std::vector<std::vector<double>> & orig){
thrust::host_vector<double6> out;
std::for_each(orig.begin(),ori... |
819 | #include <stdio.h>
#include <stdlib.h>
#include <time.h>
__global__ void euler_step(float * array, int m, int step) {
float dt = powf(10,-3);
int tId = threadIdx.x + blockIdx.x * blockDim.x;
if (tId < m) {
array[tId] = array[tId] + dt*(4*(dt*step)-array[tId]+3+tId);
};
};
int main() {
cudaEvent_t start, s... |
820 | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
__global__ void maxPerRow(double *values, int *gl_max, int n){
// Get our global thread ID
int id = blockIdx.x*blockDim.x+threadIdx.x;
int val = values[id];
//figure this out
if(id < n)
atomicMax(&gl_max[blockIdx.x], val);
}
int main( int argc, char* arg... |
821 | //TEST(smoke):COMPILE: -pass-through nvrtc -target ptx -entry hello tests/cuda/cuda-compile.cu
__global__
void hello(char *a, int *b)
{
a[threadIdx.x] += b[threadIdx.x];
}
|
822 | #include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
// Define constants and data types
#define PAGE_SIZE 32
#define PHYSICAL_MEM_SIZE 32768
#define STORAGE_SIZE 131072
#define DATAFILE "./data.bin"
#define OUTPUTFILE "./snapshot.bin"
typedef unsigned char uchar;
typedef ... |
823 | #include "includes.h"
__device__ unsigned int concatenate(float* array)
{
unsigned int rvalue=0;
unsigned int sign;
for (int i = 0; i < 32; i++)
{
sign = (array[i]>=0);
rvalue = rvalue | (sign<<i);
}
return rvalue;
}
__global__ void concatenate_cols_kernel(float *a, unsigned int *b, int m, int n)
{
int j = blockIdx.... |
824 | #include<iostream>
#include<chrono>
#include<cuda.h>
#include<cmath>
#include<cuda_runtime.h>
#define N 1024
using namespace std;
using namespace std::chrono;
static const int wholeArraySize = 10000000;
static const int blockSize = 1024;
static const int gridSize = 24; //this number is hardware-dependent; usually #S... |
825 | #include "includes.h"
__global__ void calcPrimes(int *d_IL, int *d_PL, int numOfPrimes, int lenInputList) {
int index = threadIdx.x + blockIdx.x * blockDim.x;
if(index < numOfPrimes) {
for(int i = d_PL[numOfPrimes-1]+1; i < lenInputList; i++) {
if(i % d_PL[index] == 0) {
d_IL[i] = 0;
}
}
}
} |
826 | #include <stdlib.h>
#include <stdio.h>
__global__ void kernel( void ) { }
int main()
{
kernel<<< 1, 1 >>>();
printf("Hello World!\n");
return EXIT_SUCCESS;
}
|
827 | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
typedef unsigned long long bignum;
//return 1 if it is a prime else return 0
//save as main.cu
// CUDA kernel. Each thread takes care of one element of c
__host__ __device__ bignum checkIfValIsPrime(bignum number)
{
if(number ==1) return (bignum) 0;
if... |
828 | #include <iostream>
using namespace std;
#define gpuErrchk(ans) { gpuAssert((ans), __FILE__, __LINE__); }
inline void gpuAssert(cudaError_t code, const char *file, int line, bool abort=true)
{
if (code != cudaSuccess)
{
fprintf(stderr,"GPUassert: %d %s %s %d\n", code, cudaGetErrorString(code), file, line)... |
829 | /*
============================================================================
Name : review_chp3_2.cu
Author : freshield
Version :
Copyright : Your copyright notice
Description : CUDA compute reciprocals
============================================================================
*/
#includ... |
830 | #include <stdio.h>
#define BLOCKDIM 1024
#define RSIZE 1024
//------------------------------------------------------------------------------------------------------------------------------------------------
//try thread coarsening
__global__ void Action_noImage_center_GPU(double *D_,double *maskCenter,double *Solve... |
831 | #include "losses.cuh"
#define BLOCK_SIZE 1024
#define DIVIDE(A,B) ((A+B-1)/B)
#define BLOCKS(N) DIVIDE(N,BLOCK_SIZE)
__global__ void gpu_deriv_mse(float* yt, float* yp, const unsigned int size, float* ans)
{
int i = threadIdx.x + blockDim.x * blockIdx.x;
if (i < size)
ans[i] = yp[i] - yt[i];
}
float losses::func... |
832 | #include<cstdio>
struct RGB {
unsigned char r, g, b, a;
};
extern "C" {
__global__
void BlackWhite(RGB *image, int width, int height) {
int thidx = blockIdx.x*blockDim.x + threadIdx.x;
if (thidx >= width*height) {
return;
}
unsigned char tmp = 0.299*image[thidx].r +
0.587*image[thidx].g + 0... |
833 | #include "includes.h"
__global__ void copyPixelsInSlicesRGB(float *ptrinput0, float *ptrkslices0, int dH, int dW, int kH, int kW, int size1, int size2, int isize1, int isize2, int nInputPlane, int padleft, int padright, int padup, int paddown, int inputstr0, int kslicesstr0, int batchsize)
{
// each block does one pixe... |
834 | #define COALESCED_NUM 16
#define blockDimX 256
#define blockDimY 1
#define gridDimX (gridDim.x)
#define gridDimY (gridDim.y)
#define idx (blockIdx.x*blockDimX+threadIdx.x)
#define idy (blockIdx.y*blockDimY+threadIdx.y)
#define bidy (blockIdx.y)
#define bidx (blockIdx.x)
#define tidx (threadIdx.x)
#define tidy (threadId... |
835 | #include "includes.h"
__global__ void multiply( float *A2, float *B2, float *C, int N, int threads_num ){
__shared__ float *A;
__shared__ float *B;
A = A2; B = B2;
float tmp;
int k, pos;
int a = N * N * (blockDim.x * blockIdx.x + threadIdx.x) / threads_num, b;
if ( blockDim.x * blockIdx.x + threadIdx.x == threads_n... |
836 | /*
@EECE528 Project - BDD Parallelization
@Authors: Yu Lei, Haotian Zhang
@Date: 2017/12/3
*/
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include"cuda.h"
#define MAXNODENUM 16000
#define MAXLINE 256 /* Maximum length of each input line read. */
typedef struct bddNode_ {
float index;
... |
837 |
#define MOVEBITS 22 //Using 22 bits for Supervertex IDs, hope this is enough, leaving 10 bits for weights, max 1K weight range
#define APPEND_VERTEX_BITS 32
#define INF 100000000
#define MAX_THREADS_PER_BLOCK 512
__global__ void makeVertexList(unsigned int *d_vertices, unsigned int *d_edge_flag, int *d_pick_array... |
838 | #include "includes.h"
__device__ unsigned int getGid3d3d(){
int blockId = blockIdx.x + blockIdx.y * gridDim.x
+ gridDim.x * gridDim.y * blockIdx.z;
int threadId = blockId * (blockDim.x * blockDim.y * blockDim.z)
+ (threadIdx.y * blockDim.x)
+ (threadIdx.z * (blockDim.x * blockDim.y)) + threadIdx.x;
return threadId;
}
_... |
839 |
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include "curand.h"
#include "curand_kernel.h"
#include <stdio.h>
#include <time.h>
__global__ void mhNoSwitch(unsigned int *randNums, bool *results)
{
unsigned int idx = blockIdx.x * 1024 + threadIdx.x;
unsigned int rand0 = randNums[2*idx];
unsigned... |
840 | #include <iostream>
#include <stdio.h>
#include <math.h>
#include <time.h>
//============================= GPU Kernel ====================================
__global__
void d_add(int n, float *x, float *y)
{
int index = blockIdx.x * blockDim.x + threadIdx.x;
int stride = blockDim.x * gridDim.x;
for (int i = index;... |
841 | #include<stdio.h>
#include<cuda.h>
#include<time.h>
__global__ void zad2(float *a,float *b,float *c, int N)
{
int idx = blockIdx.x * blockDim.x + threadIdx.x;
if(idx<N) c[idx] = a[idx] + b[idx];
}
int main(void)
{
clock_t t1,t2,t5,t6,t7,t8;
float *a_h,*b_h,*c_h;
float *a_d,*b_d,*c_d;
const int N = 50000000;
size_t ... |
842 | #include <stdio.h>
#include <stdlib.h>
#include <cmath>
#include <thrust/extrema.h>
#include <thrust/device_vector.h>
using namespace std;
void zzz2(int c){
if(c<10){
char a=c+'0';
printf("%c",a);
}else{
char a=c-10+'a';
printf("%c",a);
}
}
void zzz1(uchar3 a){
int x=a... |
843 | __device__ void _sum_32_20_0(volatile float *x, int i) {
//for optimizing warps
//volatile must be used as register optimization will lead to wrong answers
float ai, xi;
ai=x[i]; xi=x[i+32]; x[i]=ai+xi;
ai=x[i]; xi=x[i+16]; x[i]=ai+xi;
ai=x[i]; xi=x[i+ 8]; x[i]=ai+xi;
ai=x[i]; xi=x[i+ 4]; x[i]=ai+xi;
ai=x[i... |
844 | //pass
//--blockDim=2 --gridDim=2
struct S {
struct {
int * p;
int * q;
} s;
};
__global__ void foo(struct S A) {
A.s.p[threadIdx.x + blockDim.x*blockIdx.x] =
A.s.q[threadIdx.x + blockDim.x*blockIdx.x] + threadIdx.x;
A.s.q[threadIdx.x + blockDim.x*blockIdx.x] = threadIdx.x;
}
|
845 | //Based on the work of Andrew Krepps
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <time.h>
#include <cuda.h>
#define N 32*32
#define BLOCK_SIZE 16
#define NUM_BLOCKS N/BLOCK_SIZE
#define ARRAY_SIZE N
#define ARRAY_SIZE_IN_BYTES (sizeof(int) * (ARRAY_SIZE))
///generate data//
__host__ void ge... |
846 | #include <stdio.h>
#include <sys/time.h>
#define IMG_DIMENSION 32
#define N_IMG_PAIRS 10000
typedef unsigned char uchar;
#define OUT
#define CUDA_CHECK(f) do { \
cudaError_t e = f; ... |
847 | #include "includes.h"
__global__ void kernel(int* d_vec, int n) {
int tid = threadIdx.x;
if(threadIdx.x < n) {
int i = d_vec[tid];
d_vec[tid] = i > 5 ? -i : i;
}
} |
848 | #include "includes.h"
__device__ unsigned int getGid3d3d(){
int blockId = blockIdx.x + blockIdx.y * gridDim.x
+ gridDim.x * gridDim.y * blockIdx.z;
int threadId = blockId * (blockDim.x * blockDim.y * blockDim.z)
+ (threadIdx.y * blockDim.x)
+ (threadIdx.z * (blockDim.x * blockDim.y)) + threadIdx.x;
return threadId;
}
_... |
849 | /* File: vec_add.cu
* Purpose: Implement vector addition on a gpu using cuda
*
* Compile: nvcc [-g] [-G] -o vec_add vec_add.cu
* Run: ./vec_add
*/
#include <stdio.h>
#include <time.h>
#include <unistd.h>
#include <stdlib.h>
#include <math.h>
__global__ void Vec_add(float x[], float y[], float z[], int... |
850 | #include "includes.h"
__global__ void LRMomentaKernel (double *RadMomP, double *RadMomM, double *ThetaMomP, double *ThetaMomM, double *Dens, double *Vrad, double *Vtheta, int nrad, int nsec, double *Rmed, double OmegaFrame)
{
int j = threadIdx.x + blockDim.x*blockIdx.x;
int i = threadIdx.y + blockDim.y*blockIdx.y;
if ... |
851 | #include "includes.h"
__global__ void pictureKernel(float* d_pix,int X, int Y) {
int thread_x=blockDim.x*blockIdx.x+threadIdx.x;
int thread_y=blockDim.y*blockIdx.y+threadIdx.y;
// printf("thread_x=%d,blockDim.x=%d,blockIdx.x=%d,threadIdx=%d\n",thread_x,blockDim.x,blockIdx.x,threadIdx.x);
// printf("thread_y=%d,blockDim... |
852 | #include <stdio.h>
#include <cuda.h>
#define N 4096 // Define size of array
#define THREADS_PER_BLOCK 1024
__global__ void vectorAddKernel(int *a, int *b, int *c) {
int i = blockIdx.x * blockDim.x + threadIdx.x;
c[i] = a[i] + b[i];
}
int main() {
// Initialise grid and block variables
dim3 grid(N / THREADS_PE... |
853 | #include <iostream>
#include <cstdlib>
#include <sys/time.h>
#define N 32 // Only powers of 2 to simplify the code
#define BLOCK_SIZE 8
#define NUM_BLOCKS N
#define NUM_THREADS_PER_BLOCK N
#define NUM_BLOCKS_TILED (N*N)/(BLOCK_SIZE*BLOCK_SIZE)
#define NUM_THREADS_PER_BLOCK_TILED BLOCK_SIZE*BLOCK_SIZE
#define TIME_RESO... |
854 | #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_szz(z,x) d_szz[(x)*(nz)+(z)] // Pressure
#define d_mem_dszz_dz(z,x) d_mem_dszz_dz[(x)*(nz)+(z)]
#define d_mem_dsxx_dx(z,x) d_mem_dsxx_dx[(x)*(nz)+(z)]
#define d_Lambda(z,x) d_Lambda[(x)*(nz)+(... |
855 | #include "includes.h"
__global__ void SimpleKernel(int N, float* a){
int idx = blockIdx.x * blockDim.x + threadIdx.x;
if (idx < N) {
for (int x=0;x<1000;x++)
a[idx] = asin(a[idx]+x);
}
} |
856 | /*
Transformer function helper function.
Written by tomztyang,
2021/08/23
*/
#include <math.h>
#include <stdio.h>
#define THREADS_PER_BLOCK 256
#define DIVUP(m,n) ((m) / (n) + ((m) % (n) > 0))
// #define DEBUG
template <unsigned int d>
__global__ void rpe_q_forward_v2(
int b, int total_query_num, int local_siz... |
857 | #include <cuda.h>
#include <stdio.h>
void cudasafe(int error, char message[50], char file[100], int line) {
if (error != cudaSuccess) {
fprintf(stderr, "CUDA Error: %s : %i. In %s line %d\n", message, error, file, line);
exit(-1);
}
}
int main(int argc, c... |
858 | #include "includes.h"
__global__ void sumArraysZeroCopyWithUVA(float *A, float *B, float *C, const int N)
{
int i = blockIdx.x * blockDim.x + threadIdx.x;
if (i < N) C[i] = A[i] + B[i];
} |
859 |
#include <stdio.h>
#include <cuda.h>
extern "C" {
void mandelbrot_row_calc(int *nStep_ptr, float *deltaStep_ptr, float *start_x_ptr, float *start_y_ptr, int *mandelSize_ptr, int *innerLoopSize_ptr, int *outerLoopSize_ptr, unsigned int *results);
void mini_mandelbrot_calc(float *start_x_ptr, float *start_y_ptr, ... |
860 | // 16CO145 Sumukha PK
// 16CO234 Prajval M
#include <stdio.h>
#include <stdlib.h>
#include <cuda.h>
#include <math.h>
__global__ void generate(float * A, int size, int num, int MAX_THREAD){
int idx = threadIdx.x + blockDim.x * blockIdx.x;
A[idx] = num;
}
void generate_in_cpu(float *A, int size){
for(int ... |
861 | #include "thrust/device_ptr.h"
#include "thrust/sort.h"
__global__ void calculate_hash(uint *hash_values, uint *particle_ids, int length)
{
int i = blockIdx.x*blockDim.x + threadIdx.x;
if(i >= length)
return;
hash_values[i] = 1;
particle_ids[i] = i;
}
void hash_particles_gpu(uint *d_hash_va... |
862 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <iostream>
__global__ void nabeatsuKernel(bool* result, int result_len)
{
int i = (blockIdx.x * blockDim.x) + threadIdx.x;
if (i < result_len) {
int val = i + 1;
result[i] = (val % 3) == 0;
while (val > 0) {
... |
863 | #include "includes.h"
__global__ void fp_bias_conv(float* preact, float* bias, const int size, const int n_channel)
{
const int pos = blockIdx.x * blockDim.x + threadIdx.x;
const int totalPos = blockDim.x * gridDim.x;
const int N = n_channel * size * size;
for (int n = N * pos / totalPos; n < N * (pos+1) / totalPos; ... |
864 | #include "includes.h"
/*
waveform.cu:°üº¬µÄº¯ÊýÖ÷ÒªÊǶÔÓ¦SpikeDetect²¿·ÖµÄwaveformµÄһЩ²Ù×÷
º¯Êý×÷ÓÃÈçÏ£º
comps_wave()£º¶ÔÓÚdetect²¿·ÖÌáÈ¡µ½µÄcomponents£¬´Ó±ä»»ºóµÄ²¨ÐÎdata_tÖÐÌáÈ¡¶ÔÓ¦µÄwave
normalize()£º¶ÔÓÚ²¨ÐÎÖеĵçλֵ£¬Í¨¹ý¸ßãÐÖµtsºÍµÍãÐÖµtw½øÐйéÒ»»¯£¬·½±ãÖ®ºó¼ÆËãmasksºÍ¼â·åµÄÖÐÐÄʱ¼ä
compute_masks():¶ÔÓÚÿһ¸... |
865 | #include "includes.h"
__global__ void iReduceSum(int *idata, int *odata, unsigned int ncols) {
int i;
unsigned int tid = threadIdx.x;
extern __shared__ int sdata[];
unsigned int startPos = blockDim.x + threadIdx.x;
int colsPerThread = ncols/blockDim.x;
int blockOffset = threadIdx.x *(ncols/blockDim.x);
int myPart = 0;
... |
866 | #include "includes.h"
__global__ void STREAM_Scale_Optimized_double(double *a, double *b, double scale, size_t len)
{
/*
* Ensure size of thread index space is as large as or greater than
* vector index space else return.
*/
if (blockDim.x * gridDim.x < len) return;
size_t idx = threadIdx.x + blockIdx.x * blockDim.x;
... |
867 | #include <cuda_runtime.h>
#include <iostream>
#include <stdlib.h>
#include <time.h>
__global__ void zhuanshi(int *d_b,int *d_bt,int n)
{
int ITdx = threadIdx.x;
int IBdx = blockIdx.x;
d_bt[ITdx * n + IBdx] = d_b[IBdx * n + ITdx];
}
__global__ void neiji(int *d_a,int *d_bt,int *d_c,int *d_data,int ICTdx,int ICBdx,i... |
868 | #include "includes.h"
__global__ void multiply(int a, int b, int *c) {
*c = a * b;
} |
869 | #include "includes.h"
__global__ void median_reduce_shuffle_gpu(const float *d_in, float *d_out, float *d_random_numbers, int n_in) {
/**************/
/* initialize */
/**************/
// compute indices
int t_ind = threadIdx.x;
int g_ind = blockIdx.x * MED_BLOCK_SIZE + t_ind;
// allocate shared memory
__shared__ ... |
870 | #include <stdio.h>
#include <math.h>
#define MAX 8192
#define LOG_MAX 13
#define BLOCK_SIZE 512
#define N 10
__host__ void fftHost(float x_r[], float x_i[])
{
float tmp_r, tmp_i ;
int i, j, i_lower ;
int stage, dft_pts, num_bf;
float pi;
pi = -2 * M_PI;
float arg, e, cos_result, sin_result;
... |
871 | /*
** This program finds out the transfer bandwidth for a given transfer size (cudaMemcpy host to device).
*/
#include <stdio.h>
#define PG (4*1024)
__global__ void add_kern(float *x)
{
int current = 0;
for (int i = 0; i < 9; i++) {
for (; current < (int)(1024 * (1<<(i+2))); current+=(int)(1024 * (1<<(i+2)))... |
872 | #include "includes.h"
__global__ void group_point_grad_gpu(int b, int n, int c, int m, int nsample, const float *grad_out, const int *idx, float *grad_points) {
int batch_index = blockIdx.x;
idx += m*nsample*batch_index;
grad_out += m*nsample*c*batch_index;
grad_points += n*c*batch_index;
int index = threadIdx.x;
int ... |
873 | #include <stdio.h>
#include <stdlib.h>
#include <thrust/sort.h>
#include <thrust/merge.h>
#define NUM_SETS 100000
#define DSIZE 100
typedef int mytype;
// for ascending sorted data
#define cmp(A,B) ((A)<(B))
#define nTPB 512
#define nBLK 128
#include <time.h>
#include <sys/time.h>
#define USECPSEC 1000000ULL
long l... |
874 |
#include <math.h>
#include <stdio.h>
extern "C" __global__ void
jacobikernel( float* a, float* newa, float* lchange, int n, int m, float w0, float w1, float w2 )
{
int ti = threadIdx.x;
int tj = threadIdx.y;
int i = blockIdx.x * blockDim.x + ti + 1;
int j = blockIdx.y * blockDim.y + tj + 1;
newa[... |
875 | #include <cuda.h>
#include <cuda_runtime.h>
#include <time.h>
#include <algorithm>
#include <iostream>
#include <cuda_fp16.h>
using namespace std;
#define N 32*1024*1024
#define kBlockSize 256
// CUDA: grid stride looping
#define CUDA_1D_KERNEL_LOOP(i, n) ... |
876 | #include "includes.h"
__global__ void calculatePi(double *piTotal, long int iterations, int totalThreads)
{ long int initIteration, endIteration;
long int i = 0;
double piPartial;
int index = (blockDim.x * blockIdx.x) + threadIdx.x;
initIteration = (iterations/totalThreads) * index;
endIteration = initIteration + (... |
877 | #define N 10016
#define NR N
#define NC N
#define BLOCKSIZE 8
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
void printMat(float A[NR][NC]);
void initMat(float A[NR][NC], float B[NR][NC]);
__global__ void multiply(float *A, float *B, float *C);
int main(){
int blocksize = BLOCKSIZE;
static float A[NR][NC];... |
878 |
/* This is a automatically generated test. Do not modify */
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
__global__
void compute(float comp, int var_1,int var_2,float var_3,float* var_4,int 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,float va... |
879 | #include "includes.h"
__global__ void suma(float *A, float *B, float *C)
{
//indice de las columnas
int columna = threadIdx.x;
//indice de las filas
int fila = threadIdx.y;
//indice lineal
int Id = columna + fila * blockDim.x;
//sumamos cada elemento
C[Id] = A[Id] + B[Id];
} |
880 | #include <iostream>
#include <cstdlib>
__global__
void cuda_add(const int *ar, const int *br, int *cr) {
const unsigned idx = threadIdx.x + blockDim.x * blockIdx.x;
const int a = ar[idx];
const int b = br[idx];
cr[idx] = a + b;
}
__host__
int main(void) {
const unsigned threads = 1<<16;
const unsigned si... |
881 | #include <stdio.h>
#include <math.h>
#include <stdint.h>
#include <stdlib.h>
#include <cuda.h>
#define WID 1024
#define HEI 1024
#pragma pack(push,1)
typedef struct tagBITMAPFILEHEADER
{
unsigned short bfType;
uint32_t bfSize;
unsigned short bfReserved1;
unsigned short bfReserved2;
uint32_t bf0ffBits;
}B... |
882 | // Matrix Multiplication
#include <stdio.h>
#include <stdlib.h>
__global__ void matrixMul(int* m, int* n,int* p,int size)
{
//Calculate ow and Column
int row = blockIdx.y * blockDim.y + threadIdx.y;
int column = blockIdx.x * blockDim.x + threadIdx.x;
int p_sum = 0;
for(int i=0;i<size;i++)
{
... |
883 | #include "includes.h"
__global__ void And( bool * x, size_t idx, size_t N)
{
for (int i = blockIdx.x * blockDim.x + threadIdx.x; i < N; i += blockDim.x * gridDim.x)
{
x[(idx-2)*N + i] = x[(idx-2)*N + i] & x[(idx-1)*N + i];
}
return;
} |
884 | #include <stdio.h>
#include <assert.h>
#include <cuda.h>
#define BLOCK_SIZE 5 //number of thread blocks
#define THREAD_NUM 5 //number of threads per block
#define STEP_SIZE 10000
__global__ void calculate(float* sum, int nbin, int step, int nthreads, int nblocks) {
float x;
int idx = blockIdx.x * blockDim.x + threa... |
885 | // Import the relevant header files.
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
// While taking readings, modify N to small and large values to observe CPU compute_time
#define N 10000 //Default matrix size NxN
// Performing the Covolution... |
886 | #include <iostream>
#include <stdio.h>
using namespace std;
__host__ __device__ void deriv(double* x0, double* array, double c, int size, double* ki, double*
ko);
__global__ void rk4(double* x0, double* array, double* h, int size);
int main(){
int n_voxel = 10;
int n_species = 100;
int species_... |
887 | extern "C"
{
__global__ void gfill_32(const int n, const float *a, float *c)
{
int i = threadIdx.x + blockIdx.x * blockDim.x;
if (i<n)
{
c[i] = a[0];
}
}
} |
888 | #include "includes.h"
__global__ void totalWithThreadSyncInterleaved(float *input, float *output, int len) {
//@@ Compute reduction for a segment of the input vector
int tid = threadIdx.x, i = blockIdx.x * blockDim.x + threadIdx.x;
for(unsigned int j = 1; j <blockDim.x; j *= 2)
{
if (tid % (2 * j) == 0)
input[i] += in... |
889 | #include "includes.h"
__global__ void convert2DVectorToAngleMagnitude_kernel( uchar4 *d_angle_image, uchar4 *d_magnitude_image, float *d_vector_X, float *d_vector_Y, int width, int height, float lower_ang, float upper_ang, float lower_mag, float upper_mag) {
const int x = __mul24(blockIdx.x, blockDim.x) + threadIdx.x;
... |
890 | #include<math.h>
#include<time.h>
#include<stdexcept>
#include<iostream>
using namespace std;
__global__ void kernel_sum( int* A, int* B, int* C, int NUMBERofELEMENTS);
void sum( int* A, int* B, int* C, int n_el);
int main()
{
int NUMBER_OF_ELEMENTS;
cout<<"\nEnter number of elements:";
cin>>NUMBER_OF_ELEME... |
891 | //
// Created by kindr on 2021/5/12.
//
#include "graphConcurrent.cuh"
#include "multiKernelConcurrent.cuh"
const int N = 1 << 25;
void graphConcurrent() {
cudaStream_t s1, s2;
cudaStreamCreate(&s1);
cudaStreamCreate(&s2);
// 开始捕获流操作
cudaStreamBeginCapture(s1, cudaStreamCaptureModeGlobal);
... |
892 | #include <algorithm>
#include <cmath>
#include <cstdlib>
#include <dirent.h>
#include <fstream>
#include <iostream>
#include <limits>
#include <sstream>
#include <stdio.h>
#include <string.h>
#include <tuple>
#include <vector>
using namespace std;
template <class T>
void coutV (string text, vector<T> someVector) {
... |
893 | #include <stdio.h>
#include <stdlib.h>
#include <cuda.h>
#include <cuda_runtime.h>
#define REPEAT 1
__global__ void arrayFunc(float* d_idata, float* d_jdata, float* d_odata, int size)
{
int tid = blockDim.x * blockIdx.x + threadIdx.x;
if (tid < size) {
for(int i=0; i < REPEAT; i++)
d_odata[tid] = d_i... |
894 | /* calculate how much memory can be really allocated (which is not the same as free)
https://stackoverflow.com/a/8923966/9201239
*/
#include <stdio.h>
#include <cuda.h>
#include <unistd.h>
const size_t Mb = 1<<20; // Assuming a 1Mb page size here
int main() {
size_t total;
size_t avail;
cudaError_t c... |
895 | #define TIMES 10
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <cuda.h>
#include <sys/time.h>
double
gettime ()
{
struct timeval t;
gettimeofday (&t, NULL);
return t.tv_sec + t.tv_usec * 1e-6;
}
__global__ void
dummy_function (int *array, unsigned int howlarge)
{
int ... |
896 |
/* Includes, system */
#include <stdio.h>
#include <cuda.h>
#include <cuda_runtime.h>
#define N 1024
/* DEVICE CODE */
__global__ void suma_2_enteros(int *d1, int *d2, int *sum){
int idBloque = blockIdx.y * gridDim.x + blockIdx.x;
int idThread = idBloque * blockDim.z * blockDim.y * blockDim.x + thre... |
897 | #include <cuda.h>
#include <stdio.h>
#include <stdlib.h>
//increment wird auf host und device definiert
__host__ __device__ int increment(int a)
{
return a+1;
}
__global__ void kernel(int *a, int *b, int size)
{
int tid = threadIdx.x; //lokaler Thread Index
int bid = blockIdx.x; //Index des Bloc... |
898 | #include <stdio.h>
#include <stdio.h>
__global__ void matrixExponentiation(float *A,float *C, float *D, float *E, float *Coeff, unsigned *N, unsigned *rowsPerThread)
{
unsigned i,j,k,row,order;
/*Initializing by the identity matrix. And initialized the matrix C by matrix A.*/
for(i=0;i<(*rowsPerThread);i++)
{
... |
899 | #include <math.h>
#include <time.h>
#include <stdio.h>
float* CPUEuler(float t_0, float y_0, float delta_t){
int n=10/delta_t + 1;
float *y = (float*) malloc(sizeof(float)*n);
for (int i=0;i<n;i++){
y[i]=y_0;
for (int j=0;j<i;j++){
float t_j=t_0+j*delta_t;
y[i]+=delta_t*(9*powf(t_j,2)-4*t_j+5);
}
}
re... |
900 | #include "includes.h"
__global__ void kInRangeExc(float* gData, float lower, float upper, float* target, unsigned int numElements) {
const unsigned int idx = blockIdx.x * blockDim.x + threadIdx.x;
for (unsigned int i = idx; i < numElements; i += blockDim.x * gridDim.x)
target[i] = gData[i] > lower && gData[i] < upper;... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.