serial_no int64 1 24.2k | cuda_source stringlengths 11 9.01M |
|---|---|
2,101 | #include <stdio.h>
#include <stdlib.h>
__global__ void kernel() {
int idx = threadIdx.x + blockIdx.x * blockDim.x;
printf("Hello from thread.\n");
}
int main(){
int host_a, host_b, host_c;
int *dev_a, *dev_b, *dev_c;
int size = sizeof (int);
cudaMalloc((void**) &dev_a, size);
cudaMalloc((void**) ... |
2,102 | #include "includes.h"
__global__ void matrix_add_matrix(float* mat1, float* mat2, float* mat3, int row, int col, int sign){
int id = blockIdx.x * blockDim.x + threadIdx.x;
int size = row*col;
if(id<size){
mat3[id] = mat1[id] + sign*mat2[id];
}
} |
2,103 | #include <stdlib.h>
#include <stdio.h>
__global__ void kernel1(int *a)
{
if(threadIdx.x > 2 )
a[blockIdx.x*blockDim.x + threadIdx.x]=100;
else
a[blockIdx.x*blockDim.x + threadIdx.x]=blockIdx.x;
}
int main() {
int n=20;
int memSize = n*sizeof(int);
int *a, *d_a;
a = (int*) malloc (n*... |
2,104 | #include "includes.h"
__global__ void __minImpurityb(long long *keys, int *counts, int *outv, int *outf, float *outg, int *outc, int *jc, int *fieldlens, int nnodes, int ncats, int nsamps) {} |
2,105 | // Device code
// A is assumed to be initialized by an
// initializer port to be uniformly 0.
// the length of the output is determined
// by a metaport.
// Given an input matrix A of length N'>N
// the ptask runtime code for this will
// allocate an output of size N. Output
// should be uniform scalar of size N
exter... |
2,106 | /*
* CUDALEAPINT.CU: program to integrate hamiltonian system using leapfrog
* and CUDA
* Based off of:
* https://courses.physics.ucsd.edu/2020/Winter/physics141/Assignments/leapint.c
*/
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <math.h>
#include <stdio.h>
#include ... |
2,107 | #include "includes.h"
//Author: Adriel Kim
//6-27-2020
//Updated 7-5-2020
/*
Desc: Basic 2D matrix operations - element-wise addition, subtraction, multiplication, and division.
To do:
- Use vector instead of array?
- Be able to test for varying sizes of images. (For now we manually define with constant N)
- Add timer... |
2,108 | #include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <stdint.h>
#include <assert.h>
#include <time.h>
#include <math.h>
/*
Author: Andrew DiPrinzio
Course: EN605.417.FA
*/
static const uint32_t DEFAULT_NUM_THREADS = 1024;
static const uint32_t DEFAULT_BLOCK_SIZE = 16;
static void usage(){
pri... |
2,109 | #define NDISP 48
typedef unsigned char uchar;
using namespace std;
__global__ void path_aggregate(int width, int height, int D, int P1, int P2,
int dir, int* Espace, cudaTextureObject_t Cost,
short* texturePerp, short* textureParallel)
{
__shared__ short... |
2,110 | #include <stdlib.h>
#include <stdio.h>
// Kernel adding entries of the adjacent array entries (radius of 3) of a 1D array
//
// even better
// * one thread reads needed data into shared memory
// * every thread-block computes blockDim.x partial sums
// * data read from shared memory
// even better
// * every thread re... |
2,111 | #include<stdio.h>
int main(){
int* series;
int const n = 1<<14;
int mSize = n*sizeof(int);
return 0;
}
|
2,112 | /**
* Yuri Gorokhov
* lab 4 - Rows vs Columns
*/
#include <stdio.h>
#include <cuda.h>
#define ARRAY_SIZE 256
__global__ void kernel_row();
__global__ void kernel_col();
int main (void) {
cudaEvent_t start, stop;
float elapsedTime;
cudaEventCreate(&start);
cudaEventCreate(&stop);
cudaEventRecord(start,0)... |
2,113 | #include <cassert>
#include <cstdlib>
#include <iostream>
void print_matrix(int *m, int y, int x) {
for(int i = 0; i < y; i++) {
printf("[");
for(int j = 0; j < x; j ++)
printf("%d, ", m[i * x + j]);
printf("]\n");
}
printf("\n");
}
void init_matrix(int *m, int l) {
for (int i = 0; i < l; i+... |
2,114 | #include <cuda_runtime.h>
#include <cufft.h>
__global__ void unpack_data_dual_channel(const unsigned char* const raw_data, cufftReal* const chan_a, cufftReal* const chan_b, const size_t num_bytes) {
const size_t idx = blockIdx.x * blockDim.x + threadIdx.x;
// Make sure we are at the start of a new sample (every 3 b... |
2,115 | #include <stdio.h>
#include <math.h>
#include <time.h>
#include <cuda.h>
//Code written by Alan Fleming
//CONSTANTS
#define MATRIXSIZE 2048
#define BLOCKSIZE 1024
void cpuHistogram(int* input, int* histogram, int size) {
for(int i = 0; i < size; i++) {
histogram[input[i]]++;
}
}
__global__ void histogram(int* in... |
2,116 | #include <fstream>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
__global__ void im2colOnDevice(unsigned int n, float* matAc, float* matA, int radiusF, int countF, int L, int M, int K, int C, int H)
{
for (int idx = blockIdx.x*blockDim.x+threadIdx.x; idx < n; idx += blockDim.x*gridDim.x)
{
... |
2,117 | #include "includes.h"
__global__ void ap_multiplication(float * values ,int * indeces,float* r ,float * p_sum ,int size)
{
int index = blockDim.x * blockIdx.x + threadIdx.x ;
p_sum[index] = 0;
__syncthreads() ;
if (index < size)
{
for (int i = 0 ; i<3 ; i++)
{
p_sum[index] += values[3*index + i] * r[indeces[3*index +... |
2,118 |
/* 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,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 ... |
2,119 | #include "includes.h"
/*
* G2S
* Copyright (C) 2018, Mathieu Gravey (gravey.mathieu@gmail.com) and UNIL (University of Lausanne)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version ... |
2,120 | #include "includes.h"
__device__ Query query_table(const int num_bucket, const int *bucket_start, const int key){
const unsigned int bucket_id = key;
const unsigned int list_start = (bucket_id > 0 ? bucket_start[bucket_id - 1] : 0);
const unsigned int next_list_start = bucket_start[bucket_id];
Query query(list_start, ... |
2,121 | #include "includes.h"
__global__ void matrixMulKernel(float* d_M, float* d_N, float* d_P, int width){
//compute row and column of the target element to compute
int row = blockDim.y * blockIdx.y + threadIdx.y;
int col = blockDim.x * blockIdx.x + threadIdx.x;
//check for safety if target element is within matrix dimens... |
2,122 | #include <stdio.h>
#include <stdlib.h>
#include <cuda.h>
#include <string.h>
#include <limits.h>
#include <stdbool.h>
#define MAX_EDGE 100000000
__global__ void BFS(int* off,int* edge,int* current,int* size,int N,int E,int* c_arr,int* c_size,int* dist){
int id = blockIdx.x*blockDim.x+threadIdx.x;
if(id <... |
2,123 | // Scott Gordon and Steven Kundert
// CMPS 5433 - Colmenares
// Two Loops Project - Collatz Conjecture Verification
// Sequential implementation
#include <stdio.h> //standard IO
#include <stdint.h> //limits file
FILE *f = fopen("VerifyConjecture.txt", "w");//file for writing output
static const int NUM = 10... |
2,124 | //===- kernels.cu ---------------------------------------------*--- C++ -*-===//
//
// Copyright 2022 ByteDance Ltd. and/or its affiliates. All rights reserved.
// 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... |
2,125 | #include <cuda.h>
#include <cuda_runtime.h>
__device__ void add(const float* a, const float* b, float* output) {
*output = *a + *b;
}
|
2,126 |
#include <cuda_runtime.h>
#include <stdio.h>
#include <iostream>
using namespace std;
__global__ void func(float* ptr){
int pos = blockIdx.x * blockDim.x + threadIdx.x;
if(pos == 999){
ptr[999] = 5;
}
}
int main(){
float* ptr = nullptr;
// 因为核函数是异步的,因此不会立即检查到他是否存在异常
func<<<100, 10>... |
2,127 | #include "includes.h"
__global__ void set_kernel(REAL* dst, REAL const value, std::size_t const count)
{
std::size_t const index = blockIdx.x * blockDim.x + threadIdx.x;
if (index >= count)
return;
dst[index] = value;
} |
2,128 | #include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <sys/resource.h>
//134217728
double dwalltime(){
double sec;
struct timeval tv;
gettimeofday(&tv,NULL);
sec = tv.tv_sec + tv.tv_usec/1000000.0;
return sec;
}
__global__ void sumM_kernel_cuda(double *d_matA,double *d_matB, unsigned long n){ ... |
2,129 | #include "cuda_runtime.h"
#include <iostream>
#include <fstream>
#include <array>
#include <chrono>
#include <random>
#include <vector>
#include <string>
#include <functional>
__global__ void main_histogram(const float* input, const long size, int* histogram, const int binsNumber) {
int indx = blockIdx.x * blockDi... |
2,130 | /*
* http://code.google.com/p/thrust/wiki/QuickStartGuide#Introduction
* install thrust library by just unziping it's content to
* /usr/local/cuda/include/
* compile using : nvcc version.cu -o version
* WARNING: requires cuda 3.2 or greater
* nvcc version.cu -o version -I /path/to/thrust
*/
#include <thrust... |
2,131 | #include <stdio.h>
#include <signal.h>
// There are ways to get this data but I'm too lazy
#define CUDA_CORES 384
//#define N 7
#define N 606
#define ITERATIONS 864000
// http://www.wolframalpha.com/input/?i=gravitational+constant+in+km%5E3%2F%28Yg+*+s%5E2%29
#define GRAVITATIONAL_CONSTANT 66.7 // km^3 / (Yg * s^... |
2,132 | #include "includes.h"
/**
* Project TACO: Parallel ACO algorithm for TSP
* 15-418 Parallel Algorithms - Final Project
* Ivan Wang, Carl Lin
*/
#define MAX_THREADS 128
__global__ void copyBestPath(int i, int *bestPathResult, int *pathResults) {
memcpy(bestPathResult, &pathResults[i * MAX_ANTS], MAX_CITIES * size... |
2,133 | #include "includes.h"
/******************************************************************************
* This program takes an initial estimate of m and c and finds the associated
* rms error. It is then as a base to generate and evaluate 8 new estimates,
* which are steps in different directions in m-c space. The best ... |
2,134 | //
// Created by igor on 03.06.2021.
//
#include <cstdio>
#include <fstream>
#include <iostream>
#include <sstream>
#include "Texture.cuh"
Texture::Texture(const char *path) {
std::ifstream inp(path, std::ios::in | std::ios::binary);
if (inp.is_open()) {
std::string line;
std::getline(inp, lin... |
2,135 | #include "includes.h"
__global__ void sync_ndconv_groups() { } |
2,136 | #include <stdio.h>
#include <iostream>
#include <string.h>
#include <sstream>
#include <fstream>
//#include <bits/stdc++.h>
//#include <stdlib.h>
//#include <time.h>
using namespace std;
/***DEFINING THE DEFINES FOR THE ARRAY INDICES****************************/
//#define N 1
#define C 384
#define H 15
#define W 15
#de... |
2,137 | #include "device_launch_parameters.h"
#include <cuda_runtime.h>
#include<stdlib.h>
#include<iostream>
using namespace std;
#define SIZE 1024
//call from host func (like order to gpu)
__global__ void vectoradd(int* a, int* b, int* c,int n) {
int i = threadIdx.x;//to distinct thread
for (i = 0; i < n; i++)c[i] = a[i... |
2,138 | __global__
void nekbone(double *w, double *u, double *g, double *d, const int N) {
const int e_size = N * N * N;
const int e_offset = e_size * blockIdx.x;
__shared__ double ur[1024];
__shared__ double us[1024];
__shared__ double ut[1024];
__shared__ double ul[1024];
__shared__ double d_s[128];
for (in... |
2,139 | #include "includes.h"
__global__ void add(int *output, int length, int *n) {
int blockID = blockIdx.x;
int threadID = threadIdx.x;
int blockOffset = blockID * length;
output[blockOffset + threadID] += n[blockID];
} |
2,140 | #include <stdio.h>
#include <iostream>
#include <fstream>
#define BUFLEN 500*1024*1024
using namespace std;
__constant__ int thread_counts;
__device__ unsigned int rol(const unsigned int value,
const unsigned int steps)
{
return ((value << steps) | (value >> (32 - steps)));
... |
2,141 | #include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
#include <arpa/inet.h>
#include <math.h>
#include "cs_cuda.h"
#include "cs_dbg.h"
#include "cs_helper.h"
#include "cs_edge_detect.h"
#include "cs_copy_box.h"
// #define CUDA_DBG... |
2,142 | #include "cufft.h"
#include "cuda_runtime_api.h"
typedef float2 Complex;
void
PerformCUDAFFT(float *inputData, float *outputData, unsigned int numSamples) {
cufftHandle plan;
cufftComplex *inputDataG, *outputDataG;
int i;
float *inputDataC, *outputDataC;
outputDataC = (float*) malloc(sizeof(float... |
2,143 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <iostream>
using namespace std;
extern float *Ex, *dev_Ex, coe_Ex, dt, dz;
extern int size_space, size_Ex;
const float epsilon = 8.85e-12;
void Ex_init_allocate(int size_Ex)
{
Ex = (float *)malloc(size_Ex* sizeof(float));
cudaMalloc(&dev_Ex, ... |
2,144 | /* Cuda GPU Based Program that use GPU processor for finding cosine of numbers */
/* --------------------------- header secton ----------------------------*/
#include<stdio.h>
#include<cuda.h>
#define COS_THREAD_CNT 2
#define N 10
/* --------------------------- target code ------------------------------*/
struct cos... |
2,145 | /* /\* */
/* * testconv_extras.cu */
/* * */
/* * Created on: Nov 10, 2009 */
/* * Author: Alex Krizhevsky (akrizhevsky@gmail.com) */
/* *\/ */
/* #include <assert.h> */
/* #include "testconv_extras.cuh" */
/* #include "convCPU.h" */
/* void test_conv_bw_fit_dyn_2per(int boardNum) { */
/* cudaSetDevice... |
2,146 | #include <iostream>
#include <sstream>
#include <stdio.h>
#include <cuda.h>
/**
* \brief writes CUDA array to a text file
* \details copies the cuda array to a local buffer, writes to buffer to a new file, then frees the local memory
* @param[in] array_in - device pointer to array to write
* @param[in] N ... |
2,147 | #include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cstring>
#include <cuda_runtime.h>
#include <cstdio>
#define CUDA_WARN(XXX) \
do { if (XXX != cudaSuccess) std::cerr << "CUDA Error: " << \
cudaGetErrorString(XXX) << ", at line " << __LINE__ \
<< std::endl; cudaDeviceSynchro... |
2,148 | #include <cuda.h>
#include <cufft.h>
#include <cuda_profiler_api.h>
#include <stdio.h>
template<typename T>
__device__ __forceinline__ T ldg(const T* ptr) {
#if __CUDA_ARCH__ >= 350
return __ldg(ptr);
#else
return *ptr;
#endif
}
extern "C"
__global__
void Hadamard(
int nx
, int ny
, int nz
, cufftComplex * input_f... |
2,149 | #include <stdio.h>
#define N 1
#define TPB 256
__global__ void mainKernel()
{
printf("Hello world! My threadId is %d\n", threadIdx.x);
}
int main()
{
// Launch kernel to compute and store distance values
mainKernel<<<N, TPB>>>();
cudaDeviceSynchronize();
return 0;
}
|
2,150 | #include<stdio.h>
#include<stdlib.h>
#include<cuda.h>
#include<time.h>
//************variables globales***************
int msk=3, dimx=1040, dimy=1388, tam_imag=1388*1040;
//*******************kernel********************
__global__ void kernel (int *Gext_d,float *var_d){
int i, dimy_ext, id_p, M_d[9], dimy=1388,tam... |
2,151 | // 提前退出与DR发生在同一个一级对象中,并且它们的父辈对象有循环
__global__ void test(float *A){
int i = threadIdx.x;
int x = 5;
while(x > 0){
A[i] = A[i+1];
x--;
if(i + x <= 3)
break; // or return
}
}
|
2,152 | #include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <string.h>
#define MAXBLOCKSIZE 512
int Size;
float *a, *b, *finalVec;
float *m;
FILE *fp;
void InitProblemOnce(char *filename);
void InitPerRun();
void ForwardSub();
void BackSub();
/*
Calculation of Multiplier matrix to introduce zero's in each... |
2,153 | #include <stdio.h>
void helloCPU()
{
printf("Hello from the CPU.\n");
}
/*
* The addition of `__global__` signifies that this function
* should be launced on the GPU.
*/
__global__ void helloGPU()
{
printf("Hello from the GPU.\n");
}
int main()
{
helloCPU();
/*
* Add an execution configuration with ... |
2,154 | /*
* misc.cpp
* GSPAN
*
* Created by Jinseung KIM on 09. 07. 19.
* Copyright 2009 KyungHee. All rights reserved.
*
*/
#include "gspan.cuh"
using namespace std;
const RMPath& DFSCode::buildRMPath() //buildRMPath là một phương thức của DFSCODE
{
rmpath.clear();
int old_from = -1;
for(int i = size() -1;i>=... |
2,155 | __global__ void test(float *A, const int N){
int i = threadIdx.x;
float x = 0;
if (i < 8){
if (i < N){
x = A[i+1];
}
if (i % 2 == 1){
if (i < 4){
A[i] = x;
}
}
}
}
|
2,156 | //
// Threshold-based Contrasting GPU implementation
//
#include <unistd.h>
#include <stdlib.h>
#define THREADS_PER_BLOCK 128
// CUDA kernel declaration
__global__ void cuda_flow_bitmap_kernel(unsigned char *u8data, unsigned char *u8res, unsigned int N, unsigned int thresh);
// C/C++ Wrapper
unsigned char *gpu_flow... |
2,157 |
#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>
#define MAX_SAVES 1000
#define QTD_NUMBERS 3
#define gpuErrchk(ans) { gpuAssert((ans), __FILE__, __LINE__); }
inline... |
2,158 | #include <stdio.h>
#include <iostream>
#include <ctime>
#include <unistd.h>
#include <sys/time.h>
using namespace std;
#define N 1000000
#define BLOCK_SIZE 16
//#define TIME_CHECK clock()/float(CLOCKS_PER_SEC)
typedef unsigned long long timestamp;
//get time in microseconds
timestamp get_timestamp()
{
struct... |
2,159 | #define BLOCK_SIZE 512
#include <stdio.h>
#include <cuda.h>
#include <math.h>
__constant__ float sigma;
__constant__ float rcut;
__constant__ float vrcut;
__constant__ float dvrc12;
__constant__ float dvrcut;
__constant__ int mx;
__constant__ int my;
__constant__ int mz;
__constant__ int natoms;
__constant__ int step;... |
2,160 | #include <iostream>
#include <thrust/host_vector.h>
#include <thrust/device_vector.h>
#include <thrust/sort.h>
#include <ctime>
#include <time.h>
#include <sstream>
#include <string>
#include <fstream>
#include <cuda.h>
#include <cuda_runtime.h>
using namespace std;
__global__ void reduce0(int *g_idata, int *g_odata... |
2,161 | #include <stdio.h>
#include <stdlib.h>
#define MIN(a, b) (a < b) ? a : b
__global__ void inputs_gen(float *in, int samples, float first, float last) {
int tid = blockIdx.x * blockDim.x + threadIdx.x;
float precision = (last - first) / (samples-1);
if (tid < samples) {
in[tid] = (tid*precision + first);
}
}
_... |
2,162 | #include <random>
#include <math.h>
#include <string.h>
#include <stdio.h>
#include <errno.h>
#include <chrono>
void ldpcEncoder (unsigned int *infoWord, unsigned int* W_ROW_ROM,
unsigned int numMsgBits, unsigned int numRowsinRom, unsigned int numParBits,
unsigned int shiftRegLengt... |
2,163 | #include <stdio.h>
#include <stdlib.h>
#include <fstream>
#include <iostream>
using namespace std;
//matrix structure
typedef struct {
int n;
int *el;
} Matrix;
//KERNEL
// D = AxB
__global__ void calcD(int n, Matrix D, Matrix A, Matrix B, Matrix C)
{
int Cv = 0;
int row = blockIdx.y * blockDim.y + threadIdx.y;
... |
2,164 | #include<iostream>
#include<math.h>
#include<stdlib.h>
#include<time.h>
#define N 2048
using namespace std;
void random_ints(int *vector, int size){
for(int i=0; i<size; i++)
vector[i] = rand()%10;
}
void copy_int_to_float(float *dest, int *src, int size){
for(int i=0; i<size; i++)
dest[i] = ... |
2,165 | /*
By : Johan S. Suarez L. or @jadry92 in twitter
This kernel make inverse of the matrix A in the matrix B
*/
// Macro for mastrix index
#define Ind(a,i,j) (a)[(j)+(i)*N]
#include <stdio.h> //manipulacion de ficheros, lectura-escritura ficheros, scandf-printf
#include <stdlib.h> //Convers... |
2,166 | #include<stdio.h>
#include<sys/time.h>
/*
#define BLOCKSIZEX 64
#define BLOCKSIZEY 16
#define BLOCKSIZE BLOCKSIZEX * BLOCKSIZEY
#define GRIDSIZEX 8
#define GRIDSIZEY 16
#define GRIDSIZE GRIDSIZEX * GRIDSIZEY
#define THREAD_NUM BLOCKSIZE * GRIDSIZE
#define MIMAX 256
#define MJMAX GRIDSIZEY * (BLOCKSIZEY - 2) + 2
#defin... |
2,167 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include<iostream>
#include<limits.h>
#define NUM_NODES 5
using namespace std;
__global__ void CUDA_SSSP_KERNEL1(int *Va, int *Ea, int *Wa, bool *Ma, int *Ca, int *Ua, bool *done)
{
int id = threadIdx.x + blockIdx.x * blockDim.x;
if(id>NUM_NODES)
{
... |
2,168 | //compile
/** nvcc -arch=sm_11 dijkstra_cuda.cu -o dijkstra_cuda **/
//reference: github.com/AlexDWong/dijkstra-CUDA/
#include <iostream>
#include <stdio.h>
#include <cstdlib>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include <limits.h>
#define VERTICES 16384 //number of vertices
#define CPU_... |
2,169 | #include "includes.h"
__global__ void transposeUnroll8Row(float *out, float *in, const int nx, const int ny)
{
unsigned int ix = blockDim.x * blockIdx.x * 8 + threadIdx.x;
unsigned int iy = blockDim.y * blockIdx.y + threadIdx.y;
unsigned int ti = iy * nx + ix; // access in rows
unsigned int to = ix * ny + iy; // acces... |
2,170 | #include<stdio.h>
#include<stdlib.h>
#include<cuda_runtime.h>
#include<iostream>
#include <iostream>
#include <math.h>
#include <stdlib.h>
#include <time.h>
#include <iomanip>
#define n 1000
__global__ void Matrix_Product (double *A, double *g, double *C)
// Each thread computes one element of C
// by accumulating res... |
2,171 | /*
* Solve-1 by SnipGhost 22.03.2017
*/
#include <stdio.h>
#include <stdlib.h>
#define INCREMENT 5
#define BLOCK_SIZE 8
#define CUDA_CHECK_RETURN(value) { \
cudaError_t _m_cudaStat = value; \
if (_m_cudaStat != cudaSuccess) { \
fprintf(stderr, "Error %s at line %d in file %s\n", ... |
2,172 | //============================================================
// File: im_cuda.cu
// Author: John Gauch
// Date: Summer 2010
//============================================================
#include <stdio.h>
#include <math.h>
#include <cuda.h>
#define PIXEL(x,y) ( (((y)+ydim)%ydim)*xdim + ((x)+xdim... |
2,173 | #include "../include/obtainDeviceInfo.cuh"
#include <iostream>
void getInfo(){
/*
purpose : This function prints out information about the available CUDA devices on
the system
*/
int count;
cudaDeviceProp prop;
cudaGetDeviceCount(&count);
std::cout << "This program has ident... |
2,174 | #include <iostream>
#include "cuda_runtime.h"
#include <cufft.h>
#include <stdio.h>
const double PI = 3.141592653589793238460;
int main() {
int N = 10;
size_t memorySize = N * sizeof(cufftComplex);
cufftComplex* A = (cufftComplex*) malloc(memorySize);
cufftComplex* B = (cufftComplex*)malloc(memorySize);
for ... |
2,175 | #include "includes.h"
__global__ void horspool_match (char* text, char* pattern, int* shift_table, unsigned int* num_matches, int chunk_size, int num_chunks, int text_size, int pat_len , unsigned int* d_output) {
extern __shared__ int s[];
int count = 0;
int myId = threadIdx.x + blockDim.x * blockIdx.x;
if(myId > num... |
2,176 | #include<stdio.h>
#include<cuda.h>
#include<stdlib.h>
__global__ void hello(int* d_in){
d_in[threadIdx.x] = (blockIdx.x + threadIdx.x) * (blockIdx.x * threadIdx.x);
printf("%d : %d\n", threadIdx.x, d_in[threadIdx.x]);
}
int main(){
int* h_array = (int*)malloc(1200*1024 * sizeof(int));
int* d_array;
cu... |
2,177 | /*
* Copyright 1993-2006 NVIDIA Corporation. All rights reserved.
*
* NOTICE TO USER:
*
* This source code is subject to NVIDIA ownership rights under U.S. and
* international Copyright laws.
*
* This software and the information contained herein is PROPRIETARY and
* CONFIDENTIAL to NVIDIA and is being provid... |
2,178 | #include <stdio.h>
#include <math.h>
void printMatrix(const int *A, int rows, int cols) {
for(int i = 0; i < rows*cols*4; i++){
printf("%d ", A[i]);
printf(" ");
if ((i+1)%9 == 0){
printf("|");
}
}
printf("\n");
};
void readInput_soa(const char *filename, int *... |
2,179 | #include <cstdio>
#include <ostream>
#include <sstream>
#include <iostream>
int main(){
cudaDeviceProp prop{};
//query device
cudaGetDeviceProperties(&prop,0);
//store device parameters as variables
std::string name = prop.name;
double clockRate = prop.clockRate;
double globalMem = prop.to... |
2,180 | #include "includes.h"
//Udacity HW 4
//Radix Sorting
__global__ void scatter(unsigned int *in,unsigned int *in_pos, unsigned int *out, unsigned int *out_pos, unsigned int n, unsigned int *d_histScan, unsigned int mask, unsigned int current_bits, unsigned int nBins)
{
if (threadIdx.x == 0)
{
unsigned int start = bl... |
2,181 | #include <stdio.h>
#include <stdlib.h>
#define BLOCKS 4
#define THREADSPERBLOCK 4
#define VECSIZE 16
__global__ void vector_add(int *a, int *b, int *c) {
int i = (blockIdx.x * THREADSPERBLOCK) + threadIdx.x;
c[i] = a[i] + b[i];
}
void random_ints(int* a, int n) {
int i;
for (i = 0; i < n; ++i) {
a[i] = rand() ... |
2,182 | #include <thrust/host_vector.h>
#include <thrust/device_vector.h>
#include <thrust/copy.h>
#include <curand_kernel.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <time.h>
__global__ void mc_pi(float *d, int seed, int n_try){
int index = blockIdx.x * blockDim.x + threadIdx.x;
curandState s;
... |
2,183 | #include <iostream>
#include <stdio.h>
#include <time.h>
#include <cuda.h>
using namespace std;
struct Address
{
int numa;
int numb;
};
__global__ void pairhmm( Address * address, int * result_d)
{
clock_t start_time=clock();
int warp_index=threadIdx.x/32;
int numa=address[warp_index]. numa;
... |
2,184 | #include "includes.h"
__global__ void set_stretch_kernel(int samps, float mean, float *d_input) {
int t = blockIdx.x * blockDim.x + threadIdx.x;
if (t >= 0 && t < samps)
d_input[t] = mean;
} |
2,185 | ////////////////////////////////////////////////////////////////////////////
// Calculate scalar products of VectorN vectors of ElementN elements on CPU.
// Straight accumulation in double precision.
////////////////////////////////////////////////////////////////////////////
#include <iostream>
#include <cmath>
using ... |
2,186 | /**
* 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 relate... |
2,187 | //#include <helper_cuda.h>
#include "kernel.cuh"
__global__ void my_first_kernel(float *x)
{
int tid = threadIdx.x + blockDim.x*blockIdx.x;
x[tid] = (float) threadIdx.x;
}
void my_first(float *x, int nblocks, int nthreads)
{
my_first_kernel<<<nblocks,nthreads>>>(x);
}
|
2,188 | #include <stdio.h>
#include <stdlib.h>
/*
Aqui se defina la funcion que se quiere integrar
*/
double funcion(double x){
return 4/(1+x*x); // mofificar con la funcion deseada
}
__global__
void aproxIntegral( double (*f)(double), double a, double b , long n, double *result ){
double suma, tiempoInicio, tiempoEje... |
2,189 |
// Modified CUDA Add Example
// This example takes 2 float arrays of size 1M and adds them together.
// Prints out Total Runtime.
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <chrono>
cudaError_t addWithCuda(float *c, const fl... |
2,190 | #include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#define N 1024*1024
#define THREADS_PER_BLOCK 512
__global__ void multiply(float *a, float *b, int n);
void random_floats(float *x, int Num);
float* CPU_big_dot(float *a, float *b, int Num);
float* GPU_big_dot(float *A, float *B, int Num);
long long start_t... |
2,191 |
#include <stdio.h>
#include <stdlib.h>
#include <cuda.h>
#include <time.h>
#include <math.h>
#define TIMER_CREATE(t) \
cudaEvent_t t##_start, t##_end; \
cudaEventCreate(&t##_start); \
cudaEventCreate(&t##_end);
#define TIMER_START(t) \
cudaEventRecord(... |
2,192 | #include <fstream>
#include <iostream>
#include <stdlib.h>
#define show(x) std::cout << #x ": " << x << std::endl;
int main()
{
const float T = 5.0f;
const float X = 1.0f;
const float c = 1.0f;
float dt = 0.010;
float dx = 0.025;
int nt = (int)(T/dt) + 1;
int nx = (int)(X/dx) + 1;
dt = T / (nt-1);
dx = X... |
2,193 | #include "includes.h"
__global__ void matmul(double *a, double *b, double *c, int n)
{
// Get global thread ID
int Col = blockIdx.x*blockDim.x+threadIdx.x;
int Row = blockIdx.y*blockDim.y+threadIdx.y;
// Not out of bounds
if((Col<n) && (Row<n)) {// Mutliply matrices
// c[Row*n + Col] = 0;
double sum = 0.0;
for(int k=0... |
2,194 | #include<iostream>
#include<vector>
#include<cstdlib>
__global__ void convolution_kernel(double *arr, double *mask, double *output, int N, int M){
auto i = blockDim.x*blockIdx.x+threadIdx.x;
auto start = i - (M/2);
auto temp = 0.0;
for(auto k = 0; k < M; k++){
if((start+k >=0) && (start+k <N)){
temp += ar... |
2,195 | #define _NTHREAD 512
#define _NBLOCK 65535
#include<cuda.h>
__global__ void _AFFINE_KERNEL(int* ,int ,int* ,int ,int ,int ,int ,int ,int ,int ,int ,int ,int );
#include<stdio.h>
#include<stdlib.h>
int main()
{
int XP1[20][20],XS3[20],i,j,k;
for(i=0;i<20;i++)
for(j=0;j<20;j++)
{
XP1[i][j]=i+j;
... |
2,196 | #include <bits/stdc++.h>
using namespace std;
// Kernel function for matrix multiplication
__global__
void GPUmatmul(int N, double *x, double *y, double *ans)
{
//calculates unique thread ID in the block
int t= (blockDim.x*blockDim.y)*threadIdx.z+(threadIdx.y*blockDim.x)+(threadIdx.x);
//calculates unique block ID ... |
2,197 | #include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <time.h>
#include <algorithm>
using namespace std;
vector< vector<double> > PointValues;
vector< vector<double> > KCentroids;
vector<int> ClusteringValues;
void printClusters();
void updateC... |
2,198 | #include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <errno.h>
#include <time.h>
#include <math.h>
#include <float.h>
#include <cuda.h>
const unsigned long WIDTH = 8192;
const unsigned long HEIGHT = 8192;
#define THREADS 32
__global__ void add(int* a, int* b, int* c)
{
int i... |
2,199 | #include <cuda_runtime_api.h>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <random>
#include <cooperative_groups.h>
/*
WRITE CUDA KERNEL FOR COUNT HERE
*/
__device__
int log_2(float x){
int count = 0;
while(x>1){
x/=2;
count++;
}
return count;
}
__global__
void parallel_... |
2,200 | __global__ void move(const int num_tracks, double distance, double* x) {
for (int tid = blockIdx.x * blockDim.x + threadIdx.x; tid < num_tracks;
tid += blockDim.x * gridDim.x) {
x[tid] += distance;
}
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.