serial_no int64 1 24.2k | cuda_source stringlengths 11 9.01M |
|---|---|
3,301 | __global__ void create_quote_index(char *file, long n, long *escape_index, long *quote_index, char *quote_carry_index, long quote_index_size) {
int index = blockIdx.x * blockDim.x + threadIdx.x;
int stride = blockDim.x * gridDim.x;
// We want to always calculate on 64-character boundaries, such that we can put
... |
3,302 | #include <iostream>
#include <cuda.h>
#include <cstdlib>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
__global__
void AsyncvecAddK(int *A, int *B, int *C, int len, int offset)
{
int i = threadIdx.x+blockDim.x*blockIdx.x+offset;
if(i<len) C[i] = A[i] - B[i];
}
__global__
void vecAddK(int *A, in... |
3,303 | #include <stdio.h>
__global__ void vecAdd(float *a, float *b, float *c, int N)
{
int i = blockDim.x * blockIdx.x + threadIdx.x;
if (i < N) {
c[i] = a[i] + b[i];
}
}
int main()
{
int N = 1024 * 1024;
size_t size = N * sizeof(float);
float *ha = (float *) malloc(size);
float *hb = (... |
3,304 | #include "includes.h"
__global__ void threshold(float *vec, int *bin, const int k_bin, const int n)
{
unsigned int xIndex = blockDim.x * blockIdx.x + threadIdx.x;
// xIndex is a value from 1 to k from the vector ind
if ( (xIndex < n) & (bin[xIndex]>k_bin) )
vec[xIndex]=0.0f;
} |
3,305 | #include "includes.h"
__global__ void matrixMul(float *M, float *N, float *P, int width)
{
int col= blockDim.x * blockIdx.x + threadIdx.x;
int row = blockDim.y * blockIdx.y + threadIdx.y;
if (row < width && col < width)
{
float pValue = 0;
for(int k=0; k<width; k++)
pValue += M[row * width + k] * N[k * width + col];
P[... |
3,306 | #include <cuda.h>
#include <stdio.h>
#include <stdlib.h>
typedef struct node {
int data;
struct node *parent;
struct node *left;
struct node *right;
int height;
int sema;
} node;
__device__ node* global_root = NULL;
__device__ volatile int MASTER_LOCK = 0;
__device__ int lock(node* n) {
int status = a... |
3,307 | #include "includes.h"
__global__ void createHistCuda (float* siftCentroids, float* siftImage, int linesCent, int linesIm, float* temp)
{
__shared__ float cosines[BLOCK_SIZE][2];
size_t idx = blockIdx.x*blockDim.x + threadIdx.x;
size_t idy = blockIdx.y;
size_t tid = threadIdx.x;
if(idx < linesCent){
int centin = idx *... |
3,308 | #include <bits/stdc++.h>
#include <unistd.h>
#include <cuda.h>
template <typename Iter>
void cooley_tukey(Iter first, Iter last) {
auto size = last - first;
if (size >= 2) {
auto temp = std::vector<std::complex<double>>(size / 2);
for (int i = 0; i < size / 2; ++i) {
temp[i] = first... |
3,309 | //#include "BLACKCAT_GPU_MATHEMATICS.cuh"
//
//__global__
//void GPU_MATHEMATICS::dot(float* store, unsigned s_LD, const float* m1, unsigned m1_r, unsigned m1_c, unsigned m1_LD,
// const float* m2, unsigned m2_r, unsigned m2_c, unsigned m2_LD)
//{
//// float* scal_one;
//// cudaMalloc(&scal_one, size... |
3,310 |
#include <iostream>
#include <numeric>
#include <cuda_runtime.h>
#include <stdlib.h>
#include <ctime>
using namespace std;
#define CUDA_CHECK_RETURN(value) CheckCudaErrorAux(__FILE__,__LINE__, #value, value)
#define random(x) (rand()%x)
/**
* Check the return value of the CUDA runtime API call and exit
* the app... |
3,311 | #include <cuda_runtime.h>
#include <device_launch_parameters.h>
#include <stdio.h>
#include <stdlib.h>
//implement one grid with 4 blocks and 256 threads in total, 8x8 threads for each block
__global__ void print_threadIds()
{
printf("blockIdx,x : %d, blockIdx.y : %d, blockIdx.z : %d, blockDim.x : %d, blockDim.y : %d... |
3,312 | // CUDA runtime
#include <cuda_runtime.h>
#include <stdio.h>
// Helper functions and utilities to work with CUDA
// #include <helper_functions.h>
/**********************************************
* Check whether we read back the same input
* The double check is just for debug purposes.
* We can comment it out when be... |
3,313 | #include <cuda.h>
#include <stdio.h>
#include <stdlib.h>
#define DataSize 1024
__global__ void Add(unsigned char *Da,int high,int width)
{
int tx = threadIdx.x;
int bx = blockIdx.x;
int bn = blockDim.x;
int gn = gridDim.x;
int id = bx*bn+tx;
for(int i=id;i<(high*width);i+=(bn*gn))
Da[i] = 255... |
3,314 | #include <math.h>
#define EPS2 0.000001
__global__ void update(float4 *pos, float3 *vel, float4 *pos_, float3 *vel_, int n, float timedelta)
{
float3 acc;
int id = threadIdx.x + blockDim.x*blockIdx.x;
for (int sub_id = 0; sub_id < n; sub_id ++)
{
float3 r;
r.x = pos_[sub_id].x - pos_[i... |
3,315 | /**
* Global Memory (Linear Array) using Unified Memory
*/
#include <stdio.h>
#include <stdlib.h>
void check_cuda_errors()
{
cudaError_t rc;
rc = cudaGetLastError();
if (rc != cudaSuccess)
{
printf("Last CUDA error %s\n", cudaGetErrorString(rc));
}
}
__global__ void incrementor(int* num... |
3,316 | #include <stdio.h>
#include <assert.h>
#include <cuda.h>
void DisplayProperties( cudaDeviceProp* pDeviceProp )
{
if( !pDeviceProp )
return;
printf( "\nDevice Name \t - %s ", pDeviceProp->name );
printf( "\n**************************************");
printf( "\nTotal Global Memory\t\t -%d KB", ... |
3,317 | #include <stdio.h>
#include <stdlib.h>
#include <assert.h>
/*
* See section "B. 19 Launch Bounds" from "CUDA C Programming Guide" for more
* information about the optimal launch bounds, which differ across the major
* architecture revisions
*/
#define THREADS_PER_BLOCK_2D 16
/* Simple utility function to check fo... |
3,318 | /*
* main.c
*
* Created on: 06/12/2017
* Author: roussian
*/
#include "HostManager.cuh"
#include <stdio.h>
int main(int argc, char *argv[])
{
// cudaSetDevice(0);
//Argumentos
if( argc < 5 ) {
printf( "\n Parametros incorretos.\n Uso: <top_K>, <blockSize>, <BlockRoundNumber>, <iGlobalNumberRound>,"
... |
3,319 | #include <cmath>
__global__ void conditional(double* __restrict__ out,
double const* __restrict__ in,
double const* __restrict__ sgn) {
int i = threadIdx.x;
double helicity = sgn[i] > 0 ? 1 : -1;
out[i] = in[i] * helicity;
}
|
3,320 | #include "NeuralNetGPUFunctions.cuh"
__device__ double activationFunctionHidden(double x)
{
// Relu
return fmax(0.0, x);
}
__device__ double activationFunctionDerivativeHidden(double x)
{
return x >= 0.0 ? 1.0 : 0.0;
}
__device__ double activationFunctionOutput(double x)
{
// Sigmoid
// As expected, exp() give... |
3,321 | /* DATA_SIZE ̕_̐ωZ CPU łȂ */
/* - rev.201905 by Yoshiki NAGATANI */
#include <stdio.h>
#include <stdlib.h>
#define DATA_SIZE 1048576
/* xr̂ߓvZ REPEAT JԂ */
#define REPEAT 10000
/*-----------------------------------------------------------*/
/* ωZ R=A*B Ȃ(PRA) */
void MultiplyOnCPU(float* h_data_A, float* h_data_... |
3,322 | #include <iostream>
#include <math.h>
// Kernel function to add the elements of two arrays
__global__
void haversine(int n, float *x, float *y)
{
//int index = threadIdx.x;
//int stride = blockDim.x;
// for (int i = index; i < n; i += stride)
int index = blockIdx.x * blockDim.x + threadIdx.x;
int stri... |
3,323 | #include <bits/stdc++.h>
#include <cuda.h>
#include <stdlib.h>
#define IFOR(v, s, e) for(int v = s; v < e; ++v)
#define UFOR(v, s, e) for(unsigned v = s; v < e; v++)
using namespace std;
class MatrixUtility
{
public:
void print1Dmat(double *arr, int m) {
IFOR(i, 0, m)
cou... |
3,324 | /*
Programming on Massively Parallel Systems
Fall 2018
Project # 3
Student: Patricia Wilthew
Compile: nvcc proj3.cu -o proj3
Usage: ./proj3 {#of_elements_in_array1} {#of_elements_in_array2}
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <sys/time.h>
#include <assert.h>
#i... |
3,325 | #include <stdio.h>
#include <cuda_runtime.h>
#include <device_launch_parameters.h>
// add() will execute on the device and will be called from the host
// as add runs on the device, we need to use pointers because a,b and c must point to device memory and we need to allocate memory on the GPU
__global__ void add(int *... |
3,326 |
/* 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,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,float ... |
3,327 | #include <iostream>
#include <stdio.h>
#include <time.h>
using namespace std;
#define PI 3.1415926535897932384
#define mu0 4*PI*1e-7
#define threadsPerBlock 1024
__global__ void init(double *rod_new, double imax, double ldr, double rlength, int rod_size){
int rem = rod_size%threadsPerBlock;
int divi = rod_size/th... |
3,328 | #include "includes.h"
__global__ void sec_mean_cuda_(int nProposal, int C, float *inp, int *offsets, float *out){
for(int p_id = blockIdx.x; p_id < nProposal; p_id += gridDim.x){
int start = offsets[p_id];
int end = offsets[p_id + 1];
float count = (float)(end - start);
for(int plane = threadIdx.x; plane < C; plane +... |
3,329 | #include "includes.h"
__global__ void hillisSteeleScanDevice(int *d_array , int numberOfElements, int *d_tmpArray,int moveIndex)
{
int index = threadIdx.x + blockDim.x * blockIdx.x;
if(index > numberOfElements)
{
return;
}
d_tmpArray[index] = d_array[index];
if(index - moveIndex >=0)
{
d_tmpArray[index] = d_tmpArray[i... |
3,330 | #include "includes.h"
__global__ void dMSECost(float* predictions, float* target, float* dY, int size) {
int index = blockIdx.x * blockDim.x + threadIdx.x;
if (index < size) {
dY[index] = 2 * (predictions[index] - target[index]);
}
} |
3,331 | #define BLOCK_SIZE_M 96
#define BLOCK_SIZE_N 64
#define ROUND_UP(n, d) (n + d - 1) / d
void setGrid(int n, dim3 &blockDim, dim3 &gridDim) {
// set your block dimensions and grid dimensions here
gridDim.x = ROUND_UP(n, BLOCK_SIZE_N);
gridDim.y = ROUND_UP(n, BLOCK_SIZE_M);
}
|
3,332 | #include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<time.h>
#include<cuda.h>
/*
__global__ void multiply(int *val, int *vec, int *result, int *cols, int *rowptr)
{
int tid=threadIdx.x+blockIdx.x*blockDim.x;
int sum=0;
int i;
for(i=0;i<cols[colidx];i++)
{
sum += vec[rowptr[tid]... |
3,333 | __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);
}
}
extern "C" v... |
3,334 | #include <iostream>
#include <math.h>
// Kernel function to add the elements of two arrays
__global__
void vecAdd(int n, float *a, float *b, float *c)
{
int index = blockIdx.x * blockDim.x + threadIdx.x;
int stride = blockDim.x * gridDim.x;
for (int i = index; i < n; i+=stride)
c[i] = a[i] + b[i];
}
int main... |
3,335 | //
// cuda_update_live.cu
// LHON-Form
//
// Created by Pooya Merat in 2016.
//
extern "C" __global__ void cuda_update_live(int n_axons, float* tox, float* rate, float* detox, float* tox_prod, float on_death_tox, float k_rate_dead_axon, float k_detox_extra, float death_tox_thres,
unsigned int * axons_cent_pix, un... |
3,336 | /*
**********************************************
* CS314 Principles of Programming Languages *
* Spring 2020 *
**********************************************
*/
#include <stdio.h>
#include <stdlib.h>
__global__ void collateSegments_gpu(int * src, int * scanResult, int * output, in... |
3,337 |
#include <sstream>
#include <iostream>
#include <cuda_runtime.h>
__global__ void kernel
(double *vec, double scalar, int num_elements)
{
unsigned int idx = blockIdx.x * blockDim.x + threadIdx.x;
if (idx < num_elements) {
vec[idx] = vec[idx] * scalar;
}
}
void run_kernel
(double *vec, double scal... |
3,338 | #include<stdio.h>
#include<math.h>
#include<cuda.h>
#define N 256
__global__ void matrix_vector_multi_gpu_1_256(float *A_d,float *B_d,float *C_d){
int i;
A_d[threadIdx.x]=0.0;
for(i=0;i<N;i++){
A_d[threadIdx.x]=A_d[threadIdx.x]+B_d[threadIdx.x*N+i]*C_d[i];
}
}
int main(){
int i,j;
float A[N],B[N*N... |
3,339 | #include <stdio.h>
__global__ void hello_from_gpu()
{
printf("Hello World from the GPU!\n");
}
int main(void)
{
hello_from_gpu<<<1, 1>>>();
cudaDeviceSynchronize();
return 0;
} |
3,340 |
__global__ void
swap_reflect(float *A, int numElements)
{
int i=blockIdx.x;
int j=threadIdx.x;
float temp;
if ((i < numElements) && (j < numElements -1) && ((j)%2==0))
{
temp = A[i*numElements + j];
A[i*numElements + j] = A[i*numElements + j + 1];
A[i*numElements + j + 1] ... |
3,341 | #include <cuda_runtime.h>
__global__ void calcPReLUKernel(const float *input, float *output, const float *weights,
int width, int height, int channels)
{
int x = threadIdx.x + blockIdx.x * blockDim.x;
int y = threadIdx.y + blockIdx.y * blockDim.y;
if (x >= width || y >= height) {
... |
3,342 | #include <stdio.h>
#define N 256
#define TPB 64
__global__ void printKernel()
{
// Get thread ID
const int i = blockIdx.x*blockDim.x + threadIdx.x;
// Print message
printf("Hello World! My threadId is %d\n\n", i);
}
int main()
{
// Launch kernel to print
printKernel<<<N/TPB, TPB>>>();
cuda... |
3,343 | /*
* simulator_cuda.cu
*
* Created on: Jul 18, 2014
* Author: bqian
*/
#include "simulator_cuda.cuh"
#include "simulator_kernel_impl.cuh"
#include "util.cuh"
|
3,344 | // #CSCS CUDA Training
//
// #Example 3.2 - transpose matrix, coalesced access
//
// #Author: Ugo Varetto
//
// #Goal: compute the transpose of a matrix with coalesced memory access
//
// #Rationale: shows how to increase speed by making use of shared (among threads in a thread block) memory
// and coales... |
3,345 | #include<cuda.h>
#include<cuda_runtime.h>
#include<stdio.h>
#include<stdlib.h>
#include<cmath>
#define TILE_SIZE 2 // Tile size and block size, both are taken as 32
__device__ void store_full_row(float*,float*,int,int, int, int);
__device__ void load_full_row(float*,float*,int,int, int, int);
__device__ void... |
3,346 | #include <stdlib.h>
#include <stdio.h>
#include <cuda_runtime.h>
#include <time.h>
//#define __DEBUG
#define element_addr(a, m, n, d) (a + ((m) * (d) + n))
#define element(a, m, n, d) (((m >= 0)&&(m < d)&&(n >= 0)&&(n < d))? (a[(m) * (d) + n]) : 0)
#define CUDA_CALL(cmd) do { \
if((err = cmd) != cudaSuccess) { \
... |
3,347 | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may ... |
3,348 | #include "bitonic.cuh"
__global__ void BitonicMergeSort(float * d_output, float * d_input, int subarray_size)
{
extern __shared__ float shared_data[];
// internal index for sorting of the subarray
int index = threadIdx.x;
int index_global = index + blockDim.x * blockIdx.x;
double portions = log2(double(subarray_... |
3,349 |
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
int main()
{
int deviceCount;
cudaDeviceProp devProp;
cudaGetDeviceCount(&deviceCount);
printf("Found %d devices\n", deviceCount);
for (int device=0; device < deviceCount; device++)
{
cudaGetDeviceProperties(&devProp, device... |
3,350 | #include <stdio.h>
#include <stdlib.h>
__global__ void kernel(int *array) {
int index = blockIdx.x * blockDim.x + threadIdx.x;
array[index] = index;
}
int main(void) {
int num_elements = 256;
int num_bytes = num_elements * sizeof(int);
// pointers to host & device arrays
int *device_array = 0;
int *h... |
3,351 | #include "includes.h"
// ERROR CHECKING MACROS //////////////////////////////////////////////////////
__global__ void buildGlobalLinReg(int noPoints, int noDims, int dimRes, int nYears, int noControls, int year, int control, float* regCoeffs, float* xmins, float* xmaxes, float* regression) {
// Global thread index
i... |
3,352 | #include <iostream>
#define CHANNELS 3
__global__
void colorToGreyscaleConversion(unsigned char *Pout, unsigned char *Pin, int width, int height) {
int Col = threadIdx.x + blockIdx.x * blockDim.x;
int Row = threadIdx.y + blockIdx.y * blockDim.y;
if (Col < width && Row < height) {
// get 1D coordi... |
3,353 | #include "includes.h"
__global__ void calcReluBackwardGPU( float *dz_next_layer, float *dz_in, float *dz, float *in, int elements )
{
int id = (blockIdx.x + blockIdx.y*gridDim.x) * blockDim.x + threadIdx.x;
if( id < elements ){
dz_in[id] += dz_next_layer[id];
dz[id] += (in[id] < 0) ? (0) : (1.0 * dz_in[id]);
}
/* orig... |
3,354 | #include "includes.h"
__global__ void gpu_totalTemp_kernel ( int N, double * partialT, double * totalT)
{
extern __shared__ double T_cache[];
int tid = threadIdx.x;
T_cache[tid] = partialT[tid];
__syncthreads();
int nTotalThreads = blockDim.x; /// Total number of active threads
/** Algoritme per calc... |
3,355 | //
// Created by caesar on 7/4/18.
//
#include "Computation.cuh"
|
3,356 | #include <iostream>
int main(void) {
cudaDeviceProp deviceProp;
cudaGetDeviceProperties(&deviceProp, 0);
std::cout << "CC: " << deviceProp.major << "." << deviceProp.minor << "\n";
return 0;
}
|
3,357 | /*
Authors: Jose Garcia Kameron Bush
Collatz code for CS 4380 / CS 5351
Copyright (c) 2019 Texas State University. All rights reserved.
Redistribution in source or binary form, with or without modification,
is *not* permitted. Use in source and binary forms, with or without
modification, is only permitted for academi... |
3,358 | //This file contains a cuda code implementing 2d convolution
//Author: Ajay Singh
#include<stdio.h>
#include<cuda.h>
#include<stdlib.h>
#define mask_width (3)
#define mat_size (5)
__constant__ float mask[mask_width];
__global__
void covolution_2d_kernel(float *Mat, float *Ans)
{
int col=threadIdx.x+blockIdx.x*block... |
3,359 | // Noop
// Device code that does nothing
#include<stdio.h>
__global__ void mykernel(void) { // this runs on device
}
int main(void) {
mykernel<<<1, 1>>>();
printf("Hello! \n");
return 0;
}
|
3,360 | /**
*
* bash版対称解除法のC言語版のGPU/CUDA移植版
*
詳しい説明はこちらをどうぞ
https://suzukiiichiro.github.io/search/?keyword=Nクイーン問題
*
*/
#include <iostream>
#include <vector>
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <sys/time.h>
#include <cuda.h>
#includ... |
3,361 | #include "includes.h"
__global__ void rearrangePopulation(float *gene, float *fit, int* metaData)
{
const int idx = threadIdx.x + blockDim.x*blockIdx.x;
int nGene = metaData[1];
int nHalf = nGene / 2;
if(idx> nHalf) return;
int j = nGene - 1 - idx;
if (fit[idx] < fit[j]) {
for(int k=0; k<6; k++) {
float t = gene[idx*... |
3,362 | #include "includes.h"
__global__ void GaussianSamplePrior(float* input, int inputCount, float* mins, float* maxes, float* randomUniform)
{
int i = blockDim.x * blockIdx.y * gridDim.x //rows preceeding current row in grid
+ blockDim.x * blockIdx.x //blocks preceeding current block
+ threadIdx.x;
if (i < inputCount)
... |
3,363 | /*
* ExTopUpdater.cpp
*
* Created on: 01 февр. 2016 г.
* Author: aleksandr
*/
#include "ExTopUpdater.h"
#include "SmartIndex.h"
/*
* indx должен пренадлежать участку от [0, sizeX-1)
*/
__device__
void ExTopUpdater::operator() (const int indx) {
int m = indx;
Ex(m, sizeY - 1) = coeff[0]*(Ex(m, sizeY - 3... |
3,364 | #include "block.cuh"
Block::Block() {
}
Block::Block(AABB3 aabb, Vec3 color) {
this->aabb = aabb;
this->color = color;
}
AABB3* Block::get_bounding_box() {
return &this->aabb;
}
|
3,365 | #include <thrust/device_vector.h>
#include <thrust/gather.h>
#include <thrust/sequence.h>
#include <stdio.h>
using namespace thrust::placeholders;
/*************************************/
/* CONVERT LINEAR INDEX TO ROW INDEX */
/*************************************/
template <typename T>
struct linear_index_to_row_in... |
3,366 | // GPU kernel for convoluting sine and cosine multiplication data with filter coefficients with hamming window ....
__global__ void conv(float *dev_op_sine, float *dev_op_cosine, float *dev_op_sine_conv, float *dev_op_cosine_conv, float *dev_lpf_hamming, int b, int windowLength){
int i,k,l;
int idx = threadIdx.x... |
3,367 | #include <cuda_runtime.h>
#include <device_launch_parameters.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <assert.h>
#include <iostream>
#define MASK_LEN 8
/*as mask is never changing we can define a constant memory on the device side so that
we do not have to copu again and again and loading... |
3,368 | #include <stdio.h>
#include <sys/time.h>
#include <stdlib.h>
#define N (1<<22)
#define BLOCK_SIZE 128
static void HandleError( cudaError_t err,
const char *file,
int line ) {
if (err != cudaSuccess) {
printf( "%s in %s at line %d\n", cudaGetErrorString( er... |
3,369 | #include <iostream>
#include <fstream>
using namespace std;
#define BLOCK_SIZE 128
__global__ void simpleKernel(
float* output )
{
output[threadIdx.x] = 0;
}
int main(int argc, char *argv[])
{
unsigned N = BLOCK_SIZE;
unsigned size = N*sizeof(float);
float* g_data;
cudaError mallocd = cu... |
3,370 | #include <iostream>
#include <iomanip>
#include <thrust/extrema.h>
#include <thrust/device_vector.h>
using namespace std;
struct comparator {
__host__ __device__ bool operator()(double a, double b)
{
return fabs(a) < fabs(b);
}
};
#define CSC(call) do { \
cudaError_t res = call; \
if (res != cudaSuccess) { \
... |
3,371 | // codigo incrementa e depois decrementa valores de um vetor.
//
// este codigo exemplifica o uso de __syncthreads() e
// o uso de memoria compartilhada criada estaticamente
// e dinamicamente.
//
// a primeira grade incrementa as posicoes de um vetor
// N vezes por thread. Usa memoria compartilhada criada estaticame... |
3,372 | #include "ZonePlanMCMC.cuh"
#include <vector>
#include <iostream>
__device__
__host__
unsigned int rand(unsigned int* randx) {
*randx = *randx * 1103515245 + 12345;
return (*randx)&2147483647;
}
__device__
__host__
float randf(unsigned int* randx) {
return rand(randx) / (float(2147483647) + 1);
}
__device_... |
3,373 | //RX^g̓O[oϐɂłȂ
//ƂƂŕʃt@CANZXłȂׁCdeprecated
#include <iostream>
#include <inttypes.h>
#include <cuda_runtime.h>
#include <device_launch_parameters.h>
#include <device_functions.h>
#include "cuda_call_checker.cuh"
#include "affine_transformer_gpu.cuh"
/*
RX^gɓ]邽߂̊ϊindexێ
affine_transform_sizen[0] = 90 ]
affine_... |
3,374 | #include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
//#include <cutil.h>
// ǥХؿ(GPU¦Ǽ¹Ԥ)
//
// GPU꤫ǡäƤ +1 GPU᤹
// ȤǤ
__global__ void function_on_GPU(float* d_idata, float* d_odata, int nword)
{
int tid = threadIdx.x;
int bid = blockIdx.x;
if((tid == 0) && (bid==0)){ // ñΤGPU1ĤΥå... |
3,375 | #include <thrust/version.h>
#include <thrust/host_vector.h>
#include <thrust/device_vector.h>
#include <thrust/transform.h>
#include <thrust/sequence.h>
#include <thrust/functional.h>
#include <iostream>
#define N 2048
struct saxpy_functor
{
const float a;
saxpy_functor(float _a) : a(_a) {}
__host__ __de... |
3,376 | #include "includes.h"
// includes, project
#define PI 3.1415926536f
int MaxThreadsPerBlock;
int MaxThreadsX;
int MaxThreadsY;
// Conversion d'un vecteur réel en vecteur complexe
// Conversion d'un vecteur complexe en vecteur réel
// Multiplie point par point un vecteur complex par un vecteur réel
// Applique... |
3,377 | #include <cuda.h>
#include <stdio.h>
#define cuda_safe_call(ans) { gpuAssert((ans), __FILE__, __LINE__); }
inline void gpuAssert(cudaError_t code,
const char *file,
int line,
bool abort=true)
{
if (code != cudaSuccess)
{
fprintf(stderr,"GPUa... |
3,378 | /* Command to compile on Windows:
nvcc .\lab5_3.cu -ccbin "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\bin\Hostx64\x64"
Output should be:
A: [
[3.00, 5.00, 2.00, 0.00],
[2.00, 4.00, 5.00, 1.00],
[0.00, 3.00, 3.00, 1.00],
[3.00, 5.00, 4.00, 4.00],
[4.00, 5.00, 5.00, 3.00],
[... |
3,379 | #include <stdio.h>
#include <stdlib.h>
#define min(a,b) (a<b?a:b)
#define threadsPerBlock 256
#define N 33 * 1024
#define blocksPerGrid min(32, (N+threadsPerBlock-1)/threadsPerBlock)
__global__ void dot(float *a, float *b, float *c) {
//calculate thread id combining the block and thread indices to get global ... |
3,380 | // From CUDA for Engineers
// Listing 5.11: sharpen/main.cpp
#include <cuda_runtime.h>
#include <iostream>
int main()
{
std::cout << "Sharpen\n";
}
|
3,381 | #include "ludcmp.cu"
#include "lubksb.cu"
__device__ void simpr(float* y, float* dydx, float* dfdx, float* dfdy,
const float xs, const float htot, const int nstep, float* yout,
void derivs(const float, float* , float*))
{
int i,j,nn;
float d,h,x;
const int n = 5;
float a[n*n];
int indx[n];
float del[n],yt... |
3,382 | #include <thrust/device_vector.h>
typedef struct
{
size_t length;
double* latitude;
double* longitude;
long* ts;
} trajectory;
typedef struct
{
double latitude;
double longitude;
long ts;
} tpoint;
typedef struct
{
size_t length;
tpoint *buffer;
} swindow;
struct slide
{
size_t num;
swindow *swin;... |
3,383 | #include <stdio.h>
#define N 1000
#define TPB 32 // Threads per block
__global__ void summationKernel(int *d_array, int n, int *d_res)
{
const int idx=threadIdx.x+blockIdx.x*blockDim.x;
const int s_idx=threadIdx.x;
__shared__ int s_array[TPB];
if(idx<n)
s_array[s_idx]=d_array[idx];
else
{
s_array[s_idx]=0... |
3,384 | /* источник https://gist.github.com/stevendborrelli/4286842 */
/* источник информации о сетке и о потоках внутри неё:
https://www.youtube.com/watch?v=kzXjRFL-gjo */
#pragma once
#include <stdio.h>
int print_info_about_GPU() {
int deviceCount;
cudaDeviceProp deviceProp;
cudaGetDeviceCount(&deviceCount); ... |
3,385 | #include "includes.h"
__global__ void dot( int *a, int *b, int *c ) {
__shared__ int prod[THREADS_PER_BLOCK]; // Shared memory
int index = blockIdx.x * blockDim.x + threadIdx.x;
prod[threadIdx.x] = a[index] * b[index];
__syncthreads(); // Threads synchronization
if( threadIdx.x == 0) {
int par_sum = 0;
for(int i=... |
3,386 | /* gpu_trunc_norm.cu
* Author: Nick Ulle
* Description:
* CUDA C functions for generating truncated normal random variables.
*
* Compile with:
* nvcc --ptx -arch=compute_20 gpu_trunc_norm.cu -o bin/gpu_trunc_norm.ptx
*/
#include <stdio.h>
#include <math.h>
#include <curand_kernel.h>
#define NUM_RNG 128
... |
3,387 | #include <stdio.h>
#include <string.h>
#include <time.h>
#include <math.h>
#include <cuda_runtime.h>
/*
#if !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 600
#else
__device__ double atomicAdd(double* address, double val)
{
unsigned long long int* address_as_ull =
(unsigned long long in... |
3,388 | #include <iostream>
#include <math.h>
#include <vector>
#include <iomanip>
#include <sstream>
#include <string>
#include <fstream>
#include <thread>
#include <ctime>
#include <stdio.h>
__device__ static inline void setSeed(int64_t *seed)
{
*seed = (*seed ^ 0x5deece66d) & ((1LL << 48) - 1);
}
__device__ static inli... |
3,389 | #include <stdio.h>
#include <cuda_runtime.h>
__global__ void add(int a, int b, int *c) {
*c = a + b;
}
__global__ void hello (void)
{
printf("Hello Wold from GPU!\n");
}
extern "C" int fun_cuda()
{
int c;
int *dev_c;
cudaMalloc((void **)&dev_c, sizeof(int));
add<<<1,1>>>(2, 7, dev_c);
cudaMemcpy(&c, dev_c, si... |
3,390 | #include "includes.h"
/*
* /usr/local/cuda/bin/nvcc -gencode arch=compute_20,code=compute_20 -o fw_kernel.ptx -ptx fw_kernel.cu
*/
extern "C" {
}
__global__ void fw(float *adj_array, int *next_array, int k, int N)
{
int i = blockDim.x * blockIdx.x + threadIdx.x;
int j = blockDim.y * blockIdx.y + threadIdx.y;
float ... |
3,391 | #include <cmath>
#include <cuda_runtime.h>
namespace computation_playground {
__global__ void transpose2d_naive_kernel(float* in, float* out, int m, int n) {
int in_row_offet = blockIdx.x * blockDim.x + threadIdx.x;
if(in_row_offet < m) {
int in_global_offset = blockIdx.y * m + in_row_offet;
int out_glob... |
3,392 | #include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <fstream>
#define INF 1000000
using namespace std;
__global__ void RoyFloyd(int* matrix, int k, int N)
{
int i = blockDim.y * blockIdx.y + threadIdx.y;
int j = blockDim.x * blockIdx.x + threadIdx.x;
if (matrix... |
3,393 | #include "includes.h"
/*
* Implementations
*/
__global__ void ca_map_forward_kernel(const float *weight, const float *g, float *out, int num, int chn, int height, int width) {
int x = blockIdx.x * blockDim.x + threadIdx.x;
int y = blockIdx.y * blockDim.y + threadIdx.y;
int sp = height * width;
int len = heigh... |
3,394 | #include <stdio.h>
#include <math.h>
#include <curand.h>
#include <curand_kernel.h>
#define PI 3.14159265358979323846 // known value of pi
//------------------CUDA ERROR HANDLING------------------//
#define gpuErrChk(e) gpuAssert(e, __FILE__, __LINE__)
// Catch GPU errors in CUDA runtime calls
inline void gpuAssert... |
3,395 | #include <cuda.h>
#include <stdio.h>
#define N (1024*1024)
__global__ void kernel(int* a, int* b, int* c){
int index = blockDim.x * blockIdx.x + threadIdx.x;
*(c + index) = *(a + index) + *(b + index);
}
int main(int argc, char** argv){
int size = N * sizeof(int);
int* host_a = (int*) malloc(size);... |
3,396 | #include <stdio.h>
#include <stdlib.h>
#include <time.h>
__global__ void VecAdd(float* A, float* B, float* C, int N){
int i = threadIdx.x + blockDim.x * blockIdx.x;
if (i < N)
C[i] = A[i] + B[i];
}
int main(int argc, char** argv){
srand(2634);
int N = atoi(argv[1]);
char* out = argv[2];
... |
3,397 | #include <stdio.h>
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <cuda.h>
using namespace std;
#define CUDA_CHECK(value) { \
cudaError_t _m_cudaStat = value; \
if (_m_cudaStat != cudaSuccess) { \
fprintf(stderr, "Error %s at line %d in file %s\n", \
c... |
3,398 | template <typename T>
__device__ void fill(T *x, size_t n, T value) {
int idx = blockIdx.x * blockDim.x + threadIdx.x;
for (int i = idx; i < n; i += gridDim.x * blockDim.x) x[i] = value;
}
template <typename T>
__device__ void axpy(T a, T *x, T *y, size_t n) {
int idx = blockIdx.x * blockDim.x + threadIdx.x;
f... |
3,399 | #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <stdio.h>
#include <math.h>
#include <cstring>
using namespace std;
__global__ void compute_z(int *NOC_device,int *NOS_device,int *SC_device,float *a_device,float *b_device,float *Z_device,float *d_device){
int id... |
3,400 | #include<stdio.h>
#include<stdlib.h>
#include<math.h>
// Function to generate random number between 1 and 2
double randd() {
return (double)rand() / (RAND_MAX) + 1.0;
}
//Serial function To multiply matrix with it's transpose
void multiply_serial(double *h_a,double *h_b, int dim)
{
int i,j,k;
float a, b, sum;
//St... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.