serial_no int64 1 24.2k | cuda_source stringlengths 11 9.01M |
|---|---|
1,601 | /*!
* \brief A helper class for {@link MultiStageMeanfieldLayer} class, which is the Caffe layer that implements the
* CRF-RNN described in the paper: Conditional Random Fields as Recurrent Neural Networks. IEEE ICCV 2015.
*
* This class itself is not a proper Caffe layer although it be... |
1,602 | #include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#define BLOCK_SIZE 64
#define WA 64 * BLOCK_SIZE
#define HA 16 * BLOCK_SIZE
#define WB 16 * BLOCK_SIZE
#define HB WA
#define WC WB
#define HC HA
__global__ void
matrixMul_coalescing( float* C, float* A, float* B, int wA, int wB)
{
// Blo... |
1,603 | #include "includes.h"
__global__ void jacobiFirstLocal(float *x, const float *diagonal_values , const float *non_diagonal_values, const int *indeces ,const float *y, const int size)
{
const int index = blockIdx.x * blockDim.x + threadIdx.x;
float error = 1 ;
float current_value = 1 ;
if (index < size)
{
float local_di... |
1,604 | #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;
}
_... |
1,605 | //xfail:BOOGIE_ERROR
//--blockDim=64 --gridDim=64 --no-inline
//
#include "cuda.h"
#define N dim*dim
#define dim 2
__global__ void foo() {
__shared__ int a;
a = threadIdx.x;
}
|
1,606 | #include <cuda_runtime.h>
#include <stdio.h>
int main(void) {
int nElem = 1024;
dim3 block(1024);
dim3 grid((nElem + block.x - 1) / block.x);
printf("grid.x %d block.x %d\n", grid.x, block.x);
block.x = 512;
grid.x = (nElem + block.x - 1) / block.x;
printf("grid.x %d block.x %d\n", grid.x, block.x);
block.x... |
1,607 | #include "includes.h"
__global__ void update_accel_acoustic_kernel(float * accel, const int size, const float * rmass){
int id;
id = threadIdx.x + (blockIdx.x) * (blockDim.x) + (blockIdx.y) * ((gridDim.x) * (blockDim.x));
if (id < size) {
accel[id] = (accel[id]) * (rmass[id]);
}
} |
1,608 | #include<stdio.h>
__global__ void kernel (int *a, int dimx, int dimy)
{
// Compute the index variable
int ix = blockIdx.x*blockDim.x + threadIdx.x;
int iy = blockIdx.y*blockDim.y + threadIdx.y;
int idx = iy*dimx + ix;
//a[idx] = a[idx]+1;
a[idx] = iy*dimx + ix;
}
int main()
{
int dimx =... |
1,609 | #include <iostream>
#include <cstdio>
#define NUM_BANKS 32
#define LOG_NUM_BANKS 5
#define GET_OFFSET(idx) (idx >> LOG_NUM_BANKS)
__global__ void Scan(int* in_data, int* out_data) {
// in_data -> [1 2 3 4 5 6 7 8], block_size 4
// block_idx -> [0 0 0 0 1 1 1 1 ]
extern __shared__ int shared_data[];... |
1,610 | #include "thrust.cuh"
#include <thrust/device_ptr.h>
#include <thrust/device_malloc.h>
#include <thrust/device_free.h>
#include <thrust/sort.h>
#include <thrust/device_vector.h>
#include <thrust/host_vector.h>
#include <thrust/execution_policy.h>
#include <thrust/sequence.h>
#include <thrust/for_each.h>
#include "m... |
1,611 | #include <stdio.h>
#include <string.h>
#include <stdlib.h>
// these are just for timing measurments
#include <time.h>
// Code that reads values from a 2D grid and for each node in the grid finds the minumum
// value among all values stored in cells sharing that node, and stores the minumum
// value in that node.
// ... |
1,612 | #include <cuda.h>
#include <stdio.h>
__global__ void kernel(float *g_data, float value)
{
int idx = blockIdx.x * blockDim.x + threadIdx.x;
g_data[idx] = g_data[idx] + value;
// printf("%f+g_data[%d]=%f\n", value, idx, g_data[idx]);
}
int checkResult(float *data, const int n, const float x)
{
for (int ... |
1,613 | #include <stdio.h>
int main() {
int c;
cudaGetDeviceCount(&c);
printf("Total device %d\n",c);
int i;
cudaDeviceProp deviceProp;
for(i=0; i<c; i++){
cudaGetDeviceProperties(&deviceProp, i);
printf("Device %d has compute capability %d.%d.\n",
i, deviceProp.major, deviceProp.minor);
}
}
|
1,614 | #include "includes.h"
__global__ void cudaUpdateMostActive_kernel(unsigned int * exampleIds, unsigned int * exampleFiringRate, unsigned int * mostActiveId, unsigned int inputsDimX, unsigned int inputsDimY, unsigned int inputsDimZ)
{
const unsigned int inputSize = inputsDimZ * inputsDimX * inputsDimY;
const unsigned i... |
1,615 | #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 <semaphore.h>
#include "cs_cuda.h"
#include "cs_dbg.h"
#include "cs_helper.h"
#include "cs_buffer.h"
// #define CUDA_DBG
// #d... |
1,616 | // kompilowanie: nvcc -o executable p1.cu
#include <stdio.h>
#include <time.h>
#define N 1000000
#define BLOCK_SIZE 16 //threads per blocks
float hArray[N];
float *dArray;
int blocks;
clock_t cpu_startTime, cpu_endTime;
double cpu_elapseTime = 0;
cudaEvent_t start, stop;
float gpu_el... |
1,617 | #include "includes.h"
// CUDA kernel for vector addition
// Initialize
__global__ void MatrixMul(int* a, int* b, int* c, int n) {
// row
int row = (blockIdx.y * blockDim.y) + threadIdx.y;
//col
int col = (blockIdx.x * blockDim.x) + threadIdx.x;
int temp_sum = 0;
// boundary guard
if ((row < n) && (col < n)) {
for (in... |
1,618 | #include <cuda_runtime.h>
extern "C" void sumMatrixOnGPU1D1(float *MatA, float *MatB, float *MatC, int nx, int ny, int dimx);
// grid 1D block 1D
__global__ void sumMatrixOnGPU1D(float *MatA, float *MatB, float *MatC, int nx,
int ny)
{
unsigned int ix = threadIdx.x + blockIdx.x * b... |
1,619 | #include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <cuda.h>
#include <cuda_runtime.h>
#include <device_launch_parameters.h>
#include <device_functions.h>
#define MAIN "_MAIN_:"
#define F1LO "_ODD_:"
#define CTRL "_CRTL_:"
#define ARRAY_SIZE 100000
#define TILE_WIDTH 128
#define DEVICE 1 //device 0 o 1... |
1,620 | #define d_wavefield(z,x) d_wavefield[(x)*(nz)+(z)]
#define d_Lambda(z,x) d_Lambda[(x)*(nz)+(z)]
#define d_Cp(z,x) d_Cp[(x)*(nz)+(z)]
// #define d_data(it,iRec) d_data[(iRec)*(nSteps)+(it)]
__global__ void res_injection(float *d_wavefield, int nz, float *d_res, \
float *d_Lambda, int it, float dt, int nSteps, int n... |
1,621 | #include <cmath>
__host__ __device__
void revert_sign(float *a, size_t dim1, size_t dim2)
{
for (size_t i = 0; i < dim1 * dim2; ++i)
a[i] = -a[i];
}
__host__ __device__
void sum_vectors(
float *a,
float *b,
float *result,
size_t dim1,
size_t dim2
)
{
for (si... |
1,622 | /******************************************************************************
*cr
*cr (C) Copyright 2010 The Board of Trustees of the
*cr University of Illinois
*cr All Rights Reserved
*cr
*****************************************************************... |
1,623 | #include "includes.h"
#define TAM 2
__global__ void matrixMultDevice(float* d_A, float* d_B, float* d_C, int width) {
int Row = blockDim.y * blockIdx.y + threadIdx.y;
int Col = blockDim.x * blockIdx.x + threadIdx.x;
if(Row < width && Col < width) {
float ans = 0.0;
for(int k=0; k<width; k++) {
ans += d_A[Row*width+k... |
1,624 | #include <stdio.h>
#include <cuda_runtime_api.h>
#include <time.h>
/****************************************************************************
*
*
* Compile with:
* nvcc -o cudapass cuda_password.cu
*
* Dr Kevan Buckley, University of Wolverhampton, January 2018
*******************************************... |
1,625 |
#include <cmath>
#include <cstdlib>
#include <cstring>
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
// -------------------------------------------------------------------------------------
__global__ void FMaxPoolForward(const float* ori_data, float* pool_data, int* indice_data... |
1,626 | #include <stdio.h>
#define THREADS 64
// from http://stackoverflow.com/questions/14038589/what-is-the-canonical-way-to-check-for-errors-using-the-cuda-runtime-api
#define gpuErrchk(ans) { gpuAssert((ans), __FILE__, __LINE__); }
inline void gpuAssert(cudaError_t code, char *file, int line, bool abort=true)
{
if (code... |
1,627 | #include <stdio.h>
#include <cuda.h>
__global__ void helloKernel() {
/* ----- YOUR CODE HERE ----- */
/* -------------------------- */
}
int main() {
printf("Hello from the CPU\n");
/* ----- YOUR CODE HERE ----- */
/* -------------------------- */
cudaDeviceSynchronize();
return 0;
}
|
1,628 | #include <iostream>
#include <cassert>
#include <chrono>
using namespace std;
constexpr long WIDTH = 128;
constexpr long TILE_WIDTH = 16;
void MatmulOnCPU(double* M, double* N, double* P) {
for (int i = 0; i < WIDTH; ++i)
for (int j = 0; j < WIDTH; ++j){
double sum = 0;
for (int k = 0; k < WIDTH... |
1,629 | /*
Author : Kim, KyoungHo (rain_woo@korea.ac.kr)
Ki-Hwan Kim (wbkifun@korea.ac.kr)
Written date : 2009. 6. 11
last update :
Copyright : GNU GPL
*/
__global__ void update_src( int Nx, int Ny, int Nz, int tstep, float *F ) {
int idx, ijk;
idx = threadIdx.x;
//ijk = (idx+1)*Ny*Nz + (Ny/2)*Nz + (Nz/2)... |
1,630 | #include <iostream>
#include <cuda.h>
#include <vector>
#include <cuda_runtime.h>
// #include "../include/mycudaheader.h"
// #include "precond.h"
using namespace std;
__global__
void Jacobi_Precond_GPU(double* c, double* value, double* r, size_t num_rows)
{
int id = blockDim.x * blockIdx.x + threadIdx.x;
if ( i... |
1,631 | #include "includes.h"
__device__ __forceinline__ size_t gpu_fieldn_index(unsigned int x, unsigned int y, unsigned int z, unsigned int d)
{
return (NX*(NY*(NZ*(d-1)+z)+y)+x);
}
__global__ void gpu_stream(double *f0, double *f1, double *f2, double *h0, double *h1, double *h2, double *temp0, double *temp1, double *temp2)
... |
1,632 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
__global__ void addKernel(float *c, const float *a, const float *b,int nx,int ny)
{
int x = threadIdx.x + blockDim.x*blockIdx.x;
int y = threadIdx.y + blockDim.y*blockIdx.y;
int i = y*nx + x;
if (y < ny && x < nx)
{
c[i] = a[... |
1,633 | //optimization homework #4 cs 677 Theodore Jagodits
#include <stdio.h>
#include <stdlib.h>
#include "string.h"
#include <iostream>
#define DEFAULT_SIZE 128
#define DEFAULT_WIDTH 128
#define DEFAULT_HEIGHT 128
#define TILE_SIZE 16
__global__ void unknown_algo(float *inp1, float *inp2, float *result, int width, int he... |
1,634 | /*
Author: Su, Ming Yi
Date: 11/18/2018
Goal: use cuda to reverse matrix
How to compile it:
module load cuda
nvcc -o example_4 example_4.cu
How to run it:
./example_4
*/
#include "stdio.h"
// kernel-find linearized threadId, and set A[id] = tid
// use "__global__ void" type for base cuda kernel
__... |
1,635 | // Author: Ulises Olivares
// uolivares@unam.mx
// Oct 22, 2020
#include<iostream>
#include<stdio.h>
#include<time.h>
#include<cstdlib>
#include<math.h>
#define n 900000
#define m 10000
using namespace std;
//Global variables
long long int sizeN = n * sizeof(float);
long long int sizeM = m * sizeof(float);
float... |
1,636 | #include <stdio.h>
#include <stdlib.h>
#include <cuda.h>
typedef short WORD;
typedef int DWORD;
typedef int LONG;
static unsigned char s_box[256] = {
// 0 1 2 3 4 5 6 7 8 9 a b c d e f
0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b,... |
1,637 | /*
* fast_recommender.cu
* --------------------
* Movie recommender based in closest neighbor using Cuda.
* Computes the euclidean distance between a client and
* a group of users. Chooses the closest in resemblance
* based in the lowest Euclidean Distance in the ratings
* of movies. Once we have o... |
1,638 | #include <stdio.h>
#define N 1
int *a;
__global__ void uninit(int *a) {
/* a[0] = 42; */
printf("a[0]: %d\n", a[0]);
}
void run_uninit() {
uninit<<<1,1>>>(a);
cudaGetErrorString(cudaGetLastError());
printf("Sync: %s\n", cudaGetErrorString(cudaThreadSynchronize()));
}
int main() {
cudaMalloc... |
1,639 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<math.h>
void init_array(float *a,int n);
__global__
void sum(float* input)
{
int tid=threadIdx.x;
int no_threads=blockDim.x;
int step_size=1;
while(no_threads>0)
{
//printf("\n tid:... |
1,640 | /************************************************************************
File : lcsCollectActiveParticlesForNewRun.cu
Author : Mingcheng Chen
Last Update : January 29th, 2013
*************************************************************************/
#include <stdio.h>
#define BLOCK_SIZE 1024
__global__ void Initi... |
1,641 | #include <stdio.h>
#include <time.h>
const int M = 1024 * 1024;
const int thread_per_block = 512;
#define time_record_begin(start){ \
cudaEventCreate(&start); \
cudaEventRecord(start, 0); \
}
#define time_record_end(start, stop, time){ \
cudaEventCreate(&stop); \
cudaEventRecord(stop, 0); \
cudaEventSynchro... |
1,642 | /*
* Copyright 1993-2009 NVIDIA Corporation. All rights reserved.
*
* NOTICE TO USER:
*
* This source code is subject to NVIDIA ownership rights under U.S. and
* international Copyright laws. Users and possessors of this source code
* are hereby granted a nonexclusive, royalty-free license to use this code
* ... |
1,643 | #include <cstdio>
#include <cstdlib>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define GIG 1000000000
#define PRINT_TIME 1
#define BLOCK 32 //blockDim
#define THREAD 32
#define SM_ARR_LEN 1024 //size of the matrix
#define THREADS_PER_BLOCK 64
#define THREADS_PER_DIM 16
#define TILING_... |
1,644 | #include <stdio.h>
#include <sys/time.h>
#include <stdlib.h>
#define MARGIN 1e-6
#define ARRAY_SIZE 100000
double cpuSecond() {
struct timeval tp;
gettimeofday(&tp, NULL);
return ((double)tp.tv_sec + (double)tp.tv_usec * 1.e-6);
}
__global__ void SAXPY (double *x,double *y, double a) {
// Y = AX + Y
... |
1,645 | #include "includes.h"
__global__ void square(float * d_out, float * d_in) {
int idx = threadIdx.x;
float f = d_in[idx];
d_out[idx] = f * f;
} |
1,646 | // compile with:
//
// nvcc -gencode arch=compute_20,code=compute_20 -ptx jitlink.cu -o jitlink.ptx
//
//
extern "C"{
__device__
int bar(int* out, int a) {
*out = a * 2;
return 0;
}
}
|
1,647 | #include <iostream>
using namespace std;
#include <thrust/reduce.h>
#include <thrust/sequence.h>
#include <thrust/host_vector.h>
#include <thrust/device_vector.h>
__global__ void fillKernel(int *a, int n)
{
int tid = blockIdx.x*blockDim.x + threadIdx.x;
if (tid < n) a[tid] = tid;
}
void fill(int* d_a, int n)
{
... |
1,648 | /**
*
* Matrix Multiplication - CUDA for GPUs
*
* CS3210
*
**/
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <sys/time.h>
#include <assert.h>
#define BLOCK_SIZE 32
int size;
typedef struct
{
float **element;
} matrix;
long long wall_clock_time()
{
#ifdef __linux__
struct timespec tp;
c... |
1,649 | #include <stdio.h>
#include <time.h>
#include <cuda_runtime.h>
#include <cuda_profiler_api.h>
__global__ void initializePagerankArray(float * pagerank_d, int n_vertices) {
int i = (blockIdx.x * blockDim.x) + threadIdx.x;
if (i < n_vertices) {
pagerank_d[i] = 1.0/(float)n_vertices;
}
}
__global__ ... |
1,650 | /************************************************************************************\
* *
* Copyright � 2014 Advanced Micro Devices, Inc. *
* Copyright (c) 2015 Mark D. Hill and David A. Wood ... |
1,651 | #include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <math.h>
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#define NUM_BLOCKS 1
#define BLOCK_SIZE 256
#define NUM_MEM 32768
//stage one
__global__ void prefixOne(int *in_array, int *out_array, int unsize, int size)
{
int tid = thread... |
1,652 | ///
/// vecAddKernel00.cu
/// For CSU CS575 Spring 2011
/// Instructor: Wim Bohm
/// Based on code from the CUDA Programming Guide
/// By David Newman
/// Created: 2011-02-16
/// Last Modified: 2011-02-16 DVN
///
/// This Kernel adds two Vectors A and B in C on GPU
/// without using coalesced memory access.
///
__glo... |
1,653 |
__global__ void clock_block(clock_t* d_o, volatile long clock_count)
{
volatile long clock_offset = 0;
long temp_clock = clock_count;
while (clock_offset < temp_clock)
{
clock_offset++;
}
d_o[0] = clock_offset;
}
/*
__global__ void clock_block(clock_t* d_o, clock_t clock_count)
{
cl... |
1,654 | // REQUIRES: clang-driver
// REQUIRES: x86-registered-target
// REQUIRES: nvptx-registered-target
// REQUIRES: zlib
// RUN: %clang -### -target x86_64-linux-gnu -c %s -g -gz 2>&1 \
// RUN: | FileCheck %s --check-prefixes WARN,COMMON
// RUN: %clang -### -target x86_64-linux-gnu -c %s -gdwarf -fdebug-info-for-profiling ... |
1,655 | #include<stdio.h>
#define N 30
void add(int *X,int *Y,int *Z)
{
for(int i=0;i<N;i++)
for(int j=0;j<N;j++)
Z[i*N+j] = X[i*N+j]+Y[i*N+j];
}
__global__ void add_kernel(int *X,int *Y,int *Z)
{
int i = threadIdx.x;
int j = threadIdx.y;
Z[i*N+j] = X[i*N+j]+Y[... |
1,656 | #include "cuda_runtime.h"
#include "help_functions.cuh"
__device__ float help_functions::fisqrt(const float number)
{
long i;
float x2, y;
const float threehalfs = 1.5F;
x2 = number * 0.5F;
y = number;
i = *(long*)&y;
i = 0x5f3759df - (i >> 1);
y = *(float*)&i;
y = y * (threehalfs - (x2 * y... |
1,657 | #include <bits/stdc++.h>
#include <thrust/device_vector.h>
#include <thrust/copy.h>
#include <thrust/tabulate.h>
#include <thrust/scan.h>
#include <thrust/functional.h>
#include <thrust/execution_policy.h>
const int MAXN = 16777216;
__global__ void stage_first(int n, char *str, int32_t *pos) {
int idx = blockDim.x*bl... |
1,658 | #include <stdlib.h>
#include <stdio.h>
#include <time.h>
#define THREADS 128 // 2^7
#define BLOCKS 1024 // 2^10
#define NUM_VALS THREADS*BLOCKS
#define checkCudaErrors(func) \
{ \
cudaError_t E = ... |
1,659 | /*
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copy... |
1,660 | #include <iostream>
#include <iterator>
#include <thrust/host_vector.h>
#include <thrust/device_vector.h>
#include <thrust/sequence.h>
#include <thrust/transform.h>
#include <thrust/functional.h>
#include <algorithm>
const int size=10;
int main() {
thrust::host_vector<double> x(size), y(size);
thrust::sequen... |
1,661 | __shared__ float sha[512];
__shared__ float shb[512];
__global__ void subDiffKernel(const float * a, const float * b, float * res, const int numFloats)
{
const int index = blockIdx.x * blockDim.x + threadIdx.x;
sha[threadIdx.x] = a[index];
shb[threadIdx.x] = b[index];
__syncthreads();
float temp1 = 0.0f, temp... |
1,662 | /*В данном задании требуется представить 2 варианта программы для видеокарты: 1) максимально простой и короткий; и 2) быстрый, использующий разделяемую память.
Запрограммируйте генерацию случайных входных данных для алгоритма и автоматическую проверку корректности работы программы.
Выполните теоретическую оценку произв... |
1,663 | #include <cuda.h>
#include <stdio.h>
#include <unistd.h>
int main(){
printf("Press Ctrl+z to suspend program\n");
printf("Type bg to send program to background\n");
printf("Attach to process with cuda-gdb\n\n");
printf("cuda-gdb --pid=%d\n\n", getpid());
printf("Issue the following commands in (cuda-gdb)\n");
pr... |
1,664 | #include "includes.h"
const int Nthreads = 1024, NrankMax = 3, nt0max = 71, NchanMax = 1024;
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////... |
1,665 | //========================================================================================================================================================================================================200
//================================================================================================================... |
1,666 | // (c) Copyright 2013 Lev Barash, Landau Institute for Theoretical Physics, Russian Academy of Sciences
// This is supplement to the paper:
// L.Yu. Barash, L.N. Shchur, "PRAND: GPU accelerated parallel random number generation library: Using most reliable algorithms and applying parallelism of modern GPUs and CPUs".
/... |
1,667 | #include "includes.h"
/*
* 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
* ... |
1,668 | //pass
//--blockDim=64 --gridDim=1 --no-inline
#include "cuda.h"
__global__ void foo(int* p) {
int* q;
q = p + 1;
q[threadIdx.x] = 0;
}
|
1,669 |
/* 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) {
if (comp == floorf(-0.0f)) {
float tmp_1 = +1.3963E-6f;
comp += tmp_1 - (+1.6619E35f * var_2 - -1.5939E-42f);
fo... |
1,670 | extern "C" __device__
float atomicMaxIndex(int* address, int newCandidate, const float* image)
{
int *address_as_int =(int*)address;
int old = *address_as_int, assumed;
while (old < 0)
{
assumed = old;
old = atomicCAS(address_as_int, assumed, newCandidate);
}
// old is definit... |
1,671 |
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <iostream>
#include <stdio.h>
cudaError_t calcDotProductWithCuda(int *c, const int *a, const int *b, unsigned int size);
int main()
{
const int arraySize = 4;
const int a[arraySize] = { 2, 2, 2, 2 };
const int b[arraySize] = { ... |
1,672 | //ECGR 6090 Heterogeneous Computing Homework 1
// Problem 1 - Naive Matrix Multiplication on GPU
//Written by Aneri Sheth - 801085402
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<time.h>
#define N 100
#define M 100
#define k 100
__global__ void matrix_mul(float *a, float *b, float *c){
int row ... |
1,673 | #include "includes.h"
__global__ void add_1024(long* a, long* b, long* c, long N) { //more simple and probably faster core but works only with 1024 or less elements in vector in this example
c[threadIdx.x] = a[threadIdx.x] * b[threadIdx.x];
__syncthreads();
long step = N / 2;
while (step != 0) {
if (threadIdx.x < ste... |
1,674 | #include "includes.h"
__global__ void matmul(float* A, float* B, float* C, int ARows, int ACols, int BRows, int BCols, int CRows, int CCols) {
float CValue = 0;
int Row = blockIdx.y*16 + threadIdx.y;
int Col = blockIdx.x*16 + threadIdx.x;
for (int k = 0; k < (16 + ACols - 1)/16; k++) {
for (int n = 0; n < 16; ++n)
... |
1,675 | #include <stdio.h>
__global__ void hellogpu (void)
{
printf ("Hello world from GPU!! from %d \n", threadIdx.x);
}
int main(void)
{
printf("Hello world from CPU!! \n");
hellogpu <<<2, 10>>>();
cudaDeviceReset ();
return 0;
} |
1,676 | #include <iostream>
#include <string>
#include <cuda_runtime.h>
using namespace std;
#define RADIX 257
#define SIZE 9216
#define BLOCK_SIZE 512
#define GRID_SIZE 64
#define LOOP_NUM 100
//int HashCalc(char *text, int length);
__host__ void hHashCalc(char *text, int length, unsigned int *rehash);
__global__ void gH... |
1,677 | #include <cuda.h>
#include <cuda_runtime.h>
#include <cooperative_groups.h>
#include <stdio.h>
#define threadPerBlock 64
using namespace cooperative_groups;
__device__ int sumReduction(thread_group g, int* x, int val){
int lane = g.thread_rank();
for(int i=g.size()/2;i>0;i/=2){
x[lane] = val;
... |
1,678 | #define BLOCK_SIZE 16
typedef struct {
int width;
int height;
int stride;
float *elements;
} Matrix;
__device__ float getElement(const Matrix C, int row, int col) {
return C.elements[row * C.stride + col];
}
__device__ void setElement(Matrix C, int row, int col, float value) {
C.elements[row ... |
1,679 | extern "C"
{
__global__ void gradalex(const int n, const double *a, const double *b, double *c)
{
int i = threadIdx.x + blockIdx.x * blockDim.x;
if (i<n)
{
if (b[i]>-0.5)
{c[i] += a[i];}
else
{c[i] -= 0.5*a[i]/b[i];}
}
}
} |
1,680 | // Let's implement UDWT in CUDA now, then we will HAVE to write all the other
// pieces to go with it, for example the mid-point sorting.
// OK, this code does use convolution, on a ROTATED array, not an extended or
// padded array. In fact, it uses FOUR convolutions, all largely the same - if
// I can remember what ... |
1,681 | #include "includes.h"
__global__ void getAggregateStartIndicesKernel(int size, int *fineAggregateSort, int *aggregateRemapIndex)
{
int idx = blockIdx.x * blockDim.x + threadIdx.x;
if(idx < size)
{
if(idx == 0 || fineAggregateSort[idx] != fineAggregateSort[idx - 1])
{
aggregateRemapIndex[fineAggregateSort[idx]] = idx;
}... |
1,682 | #include <stdio.h>
#include <assert.h>
#define THREADS_PER_BLOCK 768
#define ARRAY_SIZE THREADS_PER_BLOCK * 1024
#define OPTIM 0
static void HandleError(cudaError_t error, const char *file, int line) {
if (error != cudaSuccess) {
printf("%s in %s at line %d\n", cudaGetErrorString(error), file, line);
... |
1,683 | #include <iostream>
#include <math.h>
#include <vector>
#include <iomanip>
#include <sstream>
#include <string>
#include <fstream>
#include <thread>
#include <ctime>
#include <stdio.h>
#define BLOCK_SIZE (128)
#define WORK_SIZE_BITS 16
#define SEEDS_PER_CALL ((1ULL << (WORK_SIZE_BITS)) * (BLOCK_SIZE))
#define GPU_ASS... |
1,684 | #include <thrust/host_vector.h>
#include <thrust/device_vector.h>
#include <iostream>
using namespace std;
thrust::host_vector< thrust::host_vector<double> > times;
void calculateDiffusionSerial (thrust::host_vector<double> u, double k, double rt){
times.push_back(u);
bool stop = false;
long t = 0;
thrust... |
1,685 | #include "includes.h"
__global__ void __word2vecNeg(int nrows, int ncols, int *WA, int *WB, float *A, float *B, float lrate, float vexp) {} |
1,686 | #include "includes.h"
__global__ void cudaDTargetBiasPropagate_kernel( unsigned int size, const double bias, const double* inputs, const double* diffInputs, double* outputs)
{
const unsigned int index = blockIdx.x * blockDim.x + threadIdx.x;
const unsigned int stride = blockDim.x * gridDim.x;
for (unsigned int i = ind... |
1,687 | #include<stdio.h>
#include<sys/time.h>
#include<stdlib.h>
#include<iostream>
#include<math.h>
using namespace std;
//----------------------------------- Structures and Globals---------------------------------------------
#define tileDim 32
typedef struct {
int dimension1;
int dimension2;
} ArrayMetadata2D;
// m... |
1,688 | /*
This code take the kernel and unpacks the kernel(each kernel saperatly) and
stores the position in the orignal kernel of the weights and keep the same weights
together. Now using output tiled convoltion , for each output value position
in input with similar weights are added together and multiplied similar weights ... |
1,689 | #include <iostream>
using namespace std;
__global__ void Dot(int* d_a, int* d_b, int* d_c, int size)
{
int id = blockIdx.x * blockDim.x + threadIdx.x;
if(id<size)
d_c[id]=d_a[id]*d_b[id];
}
__global__ void Add(int* d_c, int* d_out, int size)
{
int id = blockIdx.x * blockDim.x + threadIdx.x;
int t_id ... |
1,690 | /////////////////////////
// arrayXor.cu //
// Andrew Krepps //
// Module 4 Assignment //
// 2/26/2018 //
/////////////////////////
#include <chrono>
#include <stdio.h>
///////////////////////////////////////////////////////////////////////////////
/// \brief calculate the bitwise exclusive O... |
1,691 | /* Copyright 2012 by Erik Opavsky
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to ... |
1,692 | #include "includes.h"
//macro to check return value of the cuda runtime call and exits
//if call failed
__global__ void anyMethod(unsigned char* buff , unsigned char* buffer_out , int w , int h)
{
int x = blockIdx.x * blockDim.x +threadIdx.x ;
int y = blockIdx.y * blockDim.y +threadIdx.y;
int width = w , height = h;
... |
1,693 | float h_A[]= {
0.5602859338938351, 0.9244625971829773, 0.5403795491752821, 0.6848732879891641, 0.531562688776698, 0.8218523016116492, 0.6783106411067508, 0.7026255321983701, 0.9295912736817191, 0.8472516207270454, 0.9685268037452972, 0.6954214751962997, 0.6653124426786916, 0.6914652843931912, 0.7988788108504095, 0.9368... |
1,694 | #include "includes.h"
#define MAXN 8000 /* Max value of N */
int N; /* Matrix Dimension*/
int numThreads; /* Number of Threads */
/*Random*/
#define randm() 4|2[uid]&3
/*CUDA Function for calculating mean column-wise and then reducing each column's totals*/
/*This Function will be called Number of blocks times*/... |
1,695 | /*************************************************************************************************************
* FILE: lakegpu.cu
*
* AUTHORS: attiffan Aurora T. Tiffany-Davis
* ssbehera Subhendu S. Behera
* wpmoore2 Wade P. Moore
*
* DESCRIPTION: ... |
1,696 | #include <cuda.h>
#include <iostream>
using std::cout;
using std::endl;
#include<fstream>
using std::ofstream;
#include <algorithm>
using std::fill;
/***** ERROR CHECKING MACRO *****/
cudaError_t _TempErrorCode;
#define CHECK_CUDA_ERROR() _TempErrorCode = cudaGetLastError(); if(_TempErrorCode) fprintf(stderr,"!!CU... |
1,697 | /* Small CUDA exercise to detect bad (non-coalesced) memory access,
and to make it coalesced.
For NMAX=1000000, STRIDE=30, BLOCK_SIZE=128, the speedup (from
non-coalesced to coalesced versions of the code) should be ~3.8x.
Make sure that the "Result:" value printed by the code is (almost)
identical in both origina... |
1,698 | #include <iostream>
#define SIZE (10*1024*1024)
float cuda_malloc_test(int size, bool up);
int main(void) {
float elapsedTime;
float MB = (float)100 * SIZE * sizeof(int)/1024/1024;
elapsedTime = cuda_malloc_test(SIZE, true);
std::cout << "Time using cudaMalloc: " << elapsedTime << std::endl;
s... |
1,699 | #include <stdio.h>
__global__ void helloWorld(float f) {
int blockId = blockIdx.x + blockIdx.y * gridDim.x;
int threadId = blockId * blockDim.y + blockDim.x + threadIdx.x + threadIdx.y * blockDim.x;
printf("Hello block %i (x %i, y %i) running thread %i (x %i, y %i), f=%f\n", blockId, blockIdx.x, blockIdx.y, threa... |
1,700 | #include <cuda_runtime_api.h>
#include <stdint.h>
__device__ float catrom_w0_f32(float a) {
//return -0.5f*a + a*a - 0.5f*a*a*a;
return a*(-0.5f + a*(1.0f - 0.5f*a));
}
__device__ float catrom_w1_f32(float a) {
//return 1.0f - 2.5f*a*a + 1.5f*a*a*a;
return 1.0f + a*a*(-2.5f + 1.5f*a);
}
__device__ fl... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.