serial_no int64 1 24.2k | cuda_source stringlengths 11 9.01M |
|---|---|
18,601 | // CUDA-C includes
#include <cuda.h>
//#include <cutil_inline.h>
extern "C" void runCudaPart();
// Main cuda function
void runCudaPart() {
// all your cuda code here *smile*
}
|
18,602 | #include <stdlib.h>
#include <stdio.h>
#define TILE_WIDTH (16)
void fill_matrix(double *mat, unsigned numRows, unsigned numCols)
{
for(unsigned i=0; i < numRows; i++)
for(unsigned j=0; j < numCols; j++)
{
mat[i*numCols + j] = i*2.1f + j*3.2f;
}
}
void print_matrix_to_file(double *mat... |
18,603 | #include "includes.h"
__global__ void ac_kernel1 ( int *d_state_transition, unsigned int *d_state_supply, unsigned int *d_state_final, unsigned char *d_text, unsigned int *d_out, size_t pitch, int m, int n, int p_size, int alphabet, int numBlocks ) {
//int idx = blockIdx.x * blockDim.x + threadIdx.x;
int effective_pit... |
18,604 | #include <stdio.h>
__global__ void local_mem_GPU(float i) {
float f;
f = i;
printf("\nMy f value: %f", f);
}
__global__ void global_mem_GPU(float *arr) {
arr[threadIdx.x] = 2.0f * (float) threadIdx.x;
}
__global__ void shared_mem_GPU(float *arr) {
int i, idx = threadIdx.x;
float avg, sum = 0.0f;
__shared__ ... |
18,605 | #include <stdio.h>
#include <cuda.h>
#define NUM 16
__global__ void data(int *array) {
int t_id = blockDim.x * blockIdx.x + threadIdx.x;
array[t_id] = threadIdx.x + blockIdx.x;
printf("d_array[%d] = %d\n", t_id, array[t_id]);
}
int main () {
// Initialize variables
int h_array[NUM];
int *d_array;
size_... |
18,606 | #include "includes.h"
__global__ void SoftmaxLossBackprop(const int* label, int num_labels, int batch_size, float* diffData)
{
int idx = blockIdx.x * blockDim.x + threadIdx.x;
if (idx >= batch_size) return;
const int label_value = label[idx];
/* For each item in the batch, decrease the result of the label's value by 1*... |
18,607 |
// Babak Poursartip
// 09/14/2020
// Udemy Cuda
// unique index calculation
#include <cstdio>
// ===========================================
// 2d grid, 2d block
__global__ void unique_gid_calculation_2d_2d(int *input) {
int tid = blockDim.x * threadIdx.y + threadIdx.x;
int num_threads_in_a_block = blockDim.x ... |
18,608 | #include <stdio.h>
int** createMatrix(int n) {
int** matrix = (int**)malloc(sizeof(int*) * n);
for (int i = 0; i < n; ++i)
{
matrix[i] = (int*)malloc(sizeof(int) * n);
for (int j = 0; j < n; ++j)
{
matrix[i][j] = rand() % 5;
}
}
return matrix;
}
void mostrar(int** A, int n) {
for (int i = 0; i < n; ... |
18,609 | /*
Copyright 2013--2018 James E. McClure, Virginia Polytechnic & State University
This file is part of the Open Porous Media project (OPM).
OPM 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 ver... |
18,610 | #include <cuda_runtime.h>
#include <stdio.h>
#include <stdlib.h>
#define INF 10000000
#define V 10010
int vertexNum, edgeNum;
static int graphMap[V*V];
int *graphDist;
int B;
void input(char *inFileName);
void output(char *outFileName);
__global__ void cudaFW_phase1(int ith_round, int vertexNum, int *graph_dist, in... |
18,611 | __device__ const int FILTER_SIZE = 3;
extern "C"
__global__ void kernel(
unsigned int width,
unsigned int height,
unsigned int *img,
unsigned int *filter,
unsigned int *result)
{
unsigned int x = blockIdx.x*blockDim.x + threadIdx.x;
unsigned int y = blockIdx.y*blockDim.y + threadIdx.y;
... |
18,612 | #include "includes.h"
__global__ void splitNodes(int* octree, int* numNodes, int poolSize, int startNode) {
int index = blockIdx.x * blockDim.x + threadIdx.x;
//Don't do anything if its out of bounds
if (index < poolSize) {
int node = octree[2 * (index+startNode)];
//Split the node if its flagged
if (node & 0x400000... |
18,613 | // This code is copied from https://github.com/msracver/Deep-Image-Analogy
#include <stdio.h>
#include <curand_kernel.h>
#define FLT_MIN 1.175494351e-38F
__host__ __device__ int clamp(int x, int x_max, int x_min) {//assume x_max >= x_min
if (x > x_max)
{
return x_max;
}
else if (x < x_min)
{
return x_min;
... |
18,614 | #include <stdio.h>
#include <assert.h>
#define N 16
__global__ void assign(int *arr, int *r) {
__shared__ int data[N];
int tid = threadIdx.x;
if (tid < N) {
data[tid] = arr[tid];
__syncthreads();
for (int i = blockDim.x / 2; i != 0; i /= 2) {
if (tid < i) {
data[tid] += data[tid+i];
__syncthread... |
18,615 | #include <stdio.h>
#include <stdlib.h>
#include <curand.h>
#include <curand_kernel.h>
#define Nblock 1024
#define Nthread 100
#define Ngrid 1
#define maxRound 5000
__global__ void setup(curandState *state){
int index = blockIdx.x * blockDim.x + threadIdx.x;
curand_init(9999, index, 0, &state[index]);
}
__glo... |
18,616 |
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#define N 4
#define TAG 0
#define RHO 0.5 // related to pitch
#define ETA 2e-4 // related to duration of sound
#define BOUNDARY_GAIN 0.75 // clamped edge vs free edge
__global__ void process(float * u, float * u1, float * u2, int T){
//ce... |
18,617 | #include <cuda_runtime.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#define ELEMENT_MIN 0
#define ELEMENT_MAX 10
#define BLOCK_SIZE 16
#define TILE_SIZE 16
#define ZERO 1.e-6
int UI(int argc, char* argv[], int* jkl);
float randGenerate(int min, int max);
void initM... |
18,618 | #include "includes.h"
__global__ void ccc_cmp_kernaldm(const float* data1, const float* data2, const float* dm, float* device_soln, const int size, const int num_calcs, const int num_threads, const int offset)
{
float avg1 = 0.0f;
float avg2 = 0.0f;
float var1 = 0.0f;
float var2 = 0.0f;
float ccc = 0.0f;
float nnn = 0.... |
18,619 | #include "includes.h"
__global__ void PD_ZC_GPU_KERNEL(float *d_input, float *d_output, int maxTaps, int nTimesamples, int nLoops)
{
int x_r, y_r, x_w, y_w;
int Elements_per_block = PD_NTHREADS * PD_NWINDOWS;
//read
y_r = ( blockIdx.y * blockDim.y + threadIdx.y ) * nTimesamples;
x_r = ( blockIdx.x + 1 ) * Elements_per... |
18,620 | #define _NTHREAD 512
#define _NBLOCK 65535
#include<cuda.h>
__global__ void _AFFINE_KERNEL(int* ,int ,int* ,int ,int ,int ,int ,int ,int );
#include<stdio.h>
#include<stdlib.h>
int main()
{
int x[20];
int w[20],i,j,k;
for(i=0;i<20;i++)
{
x[i]=2*i;
w[i]=2*i;
}
int _SZ_w_1 = 20;
in... |
18,621 |
#include <cuda_runtime.h>
#include <device_launch_parameters.h>
#include <cuda.h>
#include <time.h>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
void fillmatrix(double** matrix, int *n);
void printmatrix(double* matrix, int n);
cudaError_t countDeter(double* matrix, int n, double * determinant);
__globa... |
18,622 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include <sys/stat.h>
int main()
{
} |
18,623 | #include "includes.h"
__global__ void profilePhaseNone_kernel() {} |
18,624 | #include <stdio.h>
#include <math.h>
#define N (16*1024)
#define THREADS_PER_BLOCK 512.0
void random_floats(float *a,int n){
int i;
float maxVal = 5.0;
for(i=0;i<n;i++){
a[i] = ((float)rand()/(float)RAND_MAX)*maxVal;
}
}
__global__ void sum(float *inp,float* blockSums)
{
__shared__ float ... |
18,625 | #include "includes.h"
__global__ void Laplace(float* d_out, float* d_in) {
int rowID = blockIdx.x + 1;
int colID = threadIdx.x + 1;
int pos = rowID * (blockDim.x + 2) + colID;
d_out[pos] = (d_in[pos - 1] + d_in[pos + 1] +
d_in[pos - blockDim.x - 2] + d_in[pos + blockDim.x + 2]) / 4.;
} |
18,626 | #include "includes.h"
__global__ void warmup(int *out, int N) {
int tid = blockIdx.x * blockDim.x + threadIdx.x;
if (tid < N)
{
out[tid] = 0;
}
} |
18,627 | /*
Single Author info:
hmajety Hari Krishna Majety
Group info:
hmajety Hari Krishna Majety
srout Sweta Rout
mreddy2 Harshavardhan Reddy Muppidi
*/
#include <stdlib.h>
#include <stdio.h>
#include <cuda_runtime.h>
#include <time.h>
#define __DEBUG
#define TSCALE 1.0
#define VSQR 0.1
#define CUDA_CALL( err ) __cud... |
18,628 | /* NiuTrans.Tensor - an open-source tensor library
* Copyright (C) 2017, Natural Language Processing Lab, Northeastern University.
* 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 o... |
18,629 | #include "layers.hh"
#include "normal-initializer.hh"
#include "zero-initializer.hh"
#include "../ops/ops-builder.hh"
#include "../ops/mat-mat-mul.hh"
#include "../ops/mat-rvect-add.hh"
#include "../ops/mat-mul-add.hh"
#include "../ops/variable.hh"
#include "../ops/vect-sigmoid.hh"
#include "../ops/conv2d.hh"
#include ... |
18,630 | #include <cstdio>
#include <cmath>
#include <complex>
#include <cstring>
#include <iostream>
#include <fstream>
using namespace std;
const int N = (1 << 30);
__global__ void multiply(int n, int m, char x[], char y[], int ans[]) {
int i = blockIdx.x * blockDim.x + threadIdx.x;
int j = blockIdx.y * blockDim.y +... |
18,631 | #include "includes.h"
__global__ void cuMultOpti( int *a, int *b, int *c, int wA, int wB, int hA)
{
#define blockTile 16
/* Blocksize is 16x16 */
/* Allocate shared memory */
__shared__ int aBlock[blockTile][blockTile];
__shared__ int bBlock[blockTile][blockTile];
/* Calculate global index X, Y*/
int gidx = blockDim.x... |
18,632 | #include "includes.h"
__global__ void cuda_deactivateTanh(double* pE, const double* pA, int n)
{
int id = blockIdx.x * blockDim.x + threadIdx.x;
if (id < n) {
pE[id] *= (1.0 - (pA[id] * pA[id]));
}
} |
18,633 | #include <cuda_runtime.h>
#include <curand.h>
__device__ float doBinomial(int n, float p,float *randomNumbers, curandGenerator_t s) {
int x = 0;
int tid = threadIdx.x + blockIdx.x * blockDim.x;
for(int i = tid; i < n; i++) {
if(randomNumbers[i] < p )
x++;
}
return x;
}
extern "C"
__global__ void b... |
18,634 | /*
Credit to https://github.com/sorazy/canny/ for these to functions.
Slight modifications were made for our use case.
*/
#include "canny_cpu.cuh"
using namespace std;
/***
* ===============================> Peaks Detection <================================
* Slope of given line = Δy/Δx. We have Δy and Δx from the ... |
18,635 | #include "includes.h"
__global__ void kernel(float * w_vect, float * train, float * partition, int rows, int cols){
int tid = threadIdx.x + blockIdx.x * blockDim.x;
int i=0;
float temp = 0;
for(i = 0; i<cols; i++){
temp += w_vect[i]*train[i*rows+tid];
}
partition[tid] = temp;
} |
18,636 | #include "includes.h"
__global__ void bgr_to_gray_kernel(unsigned char* input, unsigned char* output, int width, int height, int colorWidthStep, int grayWidthStep)
{
// 2D Index of current thread
const int xIndex = blockIdx.x * blockDim.x + threadIdx.x;
const int yIndex = blockIdx.y * blockDim.y + threadIdx.y;
// Only... |
18,637 |
#ifdef BT601
#define Ycoeff ((float4)(0.299f, 0.587f, 0.114f, 0.f))
#define Ucoeff ((float4)(-0.14713f, -0.28886f, 0.436f, 0.f))
#define Vcoeff ((float4)(0.615f, -0.51499f, -0.10001f, 0.f))
// BGR
#define YcoeffB ((float4)(0.114f, 0.587f, 0.299f, 0.f))
#define UcoeffB ((float4)(0.436f, -0.28886f, -0.14713f, 0.f))
#d... |
18,638 | /*
* Edjust NUMB_OF_EPOCHS for the iterations
*/
#include <stdio.h>
#include <time.h>
#include <cuda_runtime.h>
#include <cassert>
#include <cstdlib>
#include <functional>
#include <iostream>
#include <algorithm>
#include <vector>
using std::cout;
using std::generate;
using std::vector;
#define CUDA_CALL(x) do { ... |
18,639 | //CSCI415 - Assignment 2
//Original by: Saeed Salem, 2/25/2015
//Updated by: Otto Borchert, 2/20/2017
//To compile: make clean; make
//To run: ./assign2
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <math.h>
#include <iomanip>
#include <string>
#include <sys/time.h>
typedef std:... |
18,640 | #include <thrust/for_each.h>
#include <thrust/device_vector.h>
#include <thrust/iterator/zip_iterator.h>
#include <iostream>
struct arbitrary_functor
{
template <typename Tuple>
__host__ __device__
void operator()(Tuple t)
{
// D[i] = A[i] + B[i] * C[i];
thrust::get<3>(t) = thrust::get<... |
18,641 | #include "includes.h"
__global__ void cg_zero_start(float* a , float* x,float * b ,int size)
{
int index = blockDim.x * blockIdx.x + threadIdx.x ;
int local_index = threadIdx.x ;
int block_index = blockIdx.x ;
__shared__ float shared_r_squared[1024] ;
__shared__ float shared_p_sum[1024] ;
float local_b ;
shared_r_squ... |
18,642 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include <iostream>
using namespace std;
void check(cudaError_t e)
{
if (e != cudaSuccess)
{
printf(cudaGetErrorString(e));
}
}
// Kernel function to add the elements of two arrays
__global__
void runningSum(int n, float *x)
{
... |
18,643 | #include "includes.h"
__global__ void _rmsprop32(int n, double eps, double rho, float *dw2, float *dw) {
int i = threadIdx.x + blockIdx.x * blockDim.x;
while (i < n) {
dw2[i] = dw2[i] * rho + (1 - rho) * dw[i] * dw[i];
dw[i] /= sqrt(dw2[i] + eps);
i += blockDim.x * gridDim.x;
}
} |
18,644 | #include "includes.h"
__global__ void kExtractPatches3(float* images, float* patches, float* width_offset, float* height_offset, float* flip, int num_images, int img_width, int img_height, int patch_width, int patch_height, int num_colors) {
int dest_col = blockIdx.x * blockDim.x + threadIdx.x;
int dest_row = blockIdx... |
18,645 | //pass
//--blockDim=[17,17] --gridDim=[1,1]
#include <cuda.h>
// code example for blog: Use extent instead of grid class - Sample 2
// created by: Tamer Afify Date:1/1/2012
//This sample shows how to replace grid with extent in the
//previously illustrated image blur solution.
//For cod... |
18,646 | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* draw_mandelbrot_cuda.c :+: :+: :+: ... |
18,647 |
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include <iostream>
int main(int argc, char* argv[])
{
int dev = 0;
cudaSetDevice(dev);
unsigned int isize = 1 << 22;
unsigned int nbytes = isize * sizeof(float);
cudaDeviceProp deviceProp;
cudaGetDeviceProperties(&deviceProp, ... |
18,648 | //******************************************************************************************************************//
// Copyright (c) 2021, University of North Carolina at Charlotte
// and Lawrence Livermore National Security, LLC.
// SPDX-License-Identifier: (BSD-3-Clause)
//*****************************************... |
18,649 | #include "includes.h"
__global__ void calculateFinal(int n, int *intermediates0, double *intermediates1, double *intermediates2, int *s0, double *s1, double *s2, int k, int d){
if (blockIdx.x > 0) return;
// Only block is invoked.
// loop for every K
for (int clust = threadIdx.y; clust < k; clust+= blockDim.y){
// lo... |
18,650 | #include <stdio.h>
void print_cuda_info()
{
int nr_dev = 0;
cudaGetDeviceCount(&nr_dev);
if (nr_dev <= 0) {
printf("==========================\n");
printf("WARNING! WARNING! WARNING!\n");
printf("No CUDA device found.\n");
printf("==========================\n");
}
for (int i = 0; i < nr_dev; i++) {
cud... |
18,651 | // Program by Arthur Alves Araujo Ferreira - All rights reserved
// ITESM ID: A01022593
#include <iostream>
#include <chrono>
const bool CPU_AND_COMPARE = true;
// Function that multiplies 2 matrixes with cuda
__global__ void matrixMultiplyGPU(int *A, int *B, int *C, const int n) {
unsigned int ix = threadIdx.x ... |
18,652 | extern "C" __global__
void cu_high(float* final_img, float* edge_img, float* strong_edge_mask,
float t_high, int img_height, int img_width)
{
int idx = blockIdx.x * blockDim.x + threadIdx.x;
if (idx < (img_height * img_width)) {
// apply high threshold
if (edge_img[idx] >... |
18,653 |
/*
Compiling with nvcc:
nvcc mat_add.cu -o mat_add -std=c++11
./mat_add
Sample Output:
[Enter size of matrix]
100
[matrix addition of 100 elements]
Copy input data from the host memory to the CUDA device
CUDA kernel launch with dimension (7, 7) blocks of dimension (16, 16) threads
Time taken for addition : 21 microsec... |
18,654 | #include <iostream>
#include <device_launch_parameters.h>
#include <cuda_runtime.h>
#define N_size 256
using namespace std;
#define THREAD_NUM 16
#define BLOCK_NUM 1
// __global__ 函数 (GPU上执行) 计算立方和
__global__ static void sumOfSquares(float *num, float* result,clock_t *time)
{
//声明一块共享内存
extern __shared__ int ... |
18,655 | /*
* file name: matrix.cu
*
* matrix.cu contains the code that realize some common used matrix operations in CUDA
*
* this is a toy program for learning CUDA, some functions are reusable in other project
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#define BLOCK_SIZE 16
/*
***********... |
18,656 |
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
int main()
{
// Marco la GPU como GPU a utilizar:
cudaSetDevice(0);
// Variable de las propiedades:
cudaDeviceProp propiedades;
// Obtengo propiedades de la GPU 0:
cudaGetDeviceProperties(&propiedades,0);
printf("Nombre de ... |
18,657 | ///*
// * To change this license header, choose License Headers in Project Properties.
// * To change this template file, choose Tools | Templates
// * and open the template in the editor.
// */
//
///*
// * File: LAR_General.h
// * Author: joseph
// *
// * Created on July 23, 2017, 3:24 PM
// */
//
//#include "BLACK... |
18,658 | #include "includes.h"
__global__ void matrixMultiply2(float* A, float* C, int size)
{
float sum = 0;
int Col = blockIdx.x * TILE_WIDTH + threadIdx.x;
int Row = blockIdx.y * TILE_WIDTH + threadIdx.y;
if(Col < size && Row < size) {
for (int k = 0; k < size; k++)
sum += A[k * size + Row] * A[k * size + Col];
C[Row * siz... |
18,659 | #include "includes.h"
#define SIZ 20
#define num_inp 4
using namespace std;
typedef struct edge {
int first, second;
} edges;
__global__ void w2_kernel(double * grads_W2, double * W2, double learning_rate, int size)
{
int i = blockIdx.x;
int j = threadIdx.x;
W2[i*size + j] += (-learning_rate * grads_W2[i*size... |
18,660 | #include "includes.h"
__global__ void reduceNeighboredLess(int *g_idata, int *g_odata, unsigned int n){
// thread id
int idx = blockIdx.x * blockDim.x + threadIdx.x;
// data pointer of this block
int *idata = g_idata + blockIdx.x * blockDim.x;
// thread id out of range
if (threadIdx.x >= n) return;
for (int stride = 1;... |
18,661 | #define EMPTY 0
#define RED 1
#define BLUE 2
__global__ void init_kernel(int * domain, int domain_x)
{
// Dummy initialization
domain[blockIdx.y * domain_x + blockIdx.x * blockDim.x + threadIdx.x]
= ((blockIdx.x+threadIdx.x) == 0 ? 1 : 0);
//= (1664525ul * (blockIdx.x + threadIdx.y + threadIdx.x) + 1013904223ul)... |
18,662 | ///*
// * config_GOL2D.cu
// *
// * Created on: 13/ott/2014
// * Author: knotman
// */
//
//#ifndef CONFIG_GOL2D_CU_
//#define CONFIG_GOL2D_CU_
//
///*
// * config.h
// *
// * Created on: 20/mar/2014
// * Author: davide
// */
//
///*
// 5 | 1 | 8
// ---|---|---
// 2 | 0 | 3
// ... |
18,663 | #include "includes.h"
__global__ void create_fpr_kernel(float* tpr, const int* unique_index, float* fpr, int num_selected, int num_total) {
float pos_cnt = tpr[num_selected - 1];
float neg_cnt = num_total - pos_cnt;
int gid_base = blockIdx.x * blockDim.x + threadIdx.x;
for (int gid = gid_base; gid < num_selected; gid +... |
18,664 | #include "includes.h"
__global__ void fill(int * m, std::size_t w , std::size_t h)
{
auto idx = blockIdx.x * blockDim.x + threadIdx.x;
auto idy = blockIdx.y * blockDim.y + threadIdx.y;
if( idx < w && idy <h )
{
m [ idy * w + idx ] = idy * w + idx;
}
} |
18,665 | #include <stdio.h>
#define CHECK(call) \
{ \
cudaError_t err = call; \
if (err != cu... |
18,666 | #include <stdio.h>
__global__ void vector_add(int *d_a, int *d_b, int *d_c, int n){
int i = blockIdx.x*blockDim.x + threadIdx.x;
d_c[i] = d_a[i] + d_b[i];
}
int main(void){
printf("Hello, World - from CPU!\n");
int a[4] = {22,13,16,5};
int b[4] = {5,22,17,37};
int c[4];
int *d_a;
int *d_b;
int *d_c;
cudaMal... |
18,667 | __global__ void test_builtin_variables() {
// gridDim == { 2, 3, 4 }
// blockDim == { 5, 6, 7 }
int a1[1];
int a2[2];
int a3[3];
int a4[4];
int a5[5];
int a6[6];
int a7[7];
int a8[8];
a3[gridDim.x] = 42;
a2[gridDim.x] = 42;
a4[gridDim.y] = 42;
a3[gridDim.y] = 42;
a5[gridDim.z] = 42;
a4[gridDim.z] = 4... |
18,668 | #include <thrust/device_vector.h>
#include <stdio.h>
#include <iostream>
#include <limits.h>
#include <time.h>
#include <chrono>
#include <thrust/scan.h>
#include <thrust/execution_policy.h>
#include <thrust/functional.h>
#include <thrust/transform.h>
#include <thrust/iterator/zip_iterator.h>
/*
struct sub : public th... |
18,669 | #include "cuda.h"
#include "malloc.h"
#include "stdio.h"
#define N 4
// GPU端矩阵转置
__global__ void matrixTranspose(float *Ad, float *Bh, int rowElemNumInAd, int colElemNumInAd)
{
int cCol = threadIdx.x;
int cRow = threadIdx.y;
*(Bh+rowElemNumInAd*cCol+cRow) = *(Ad+colElemNumInAd*cRow+cCol);
}
// CPU端矩阵初始化
void mat... |
18,670 | #include <stdio.h>
#include <stdlib.h>
#include <cuda.h>
#include <math.h>
float boundary(float t) {
float fun = 0;
if (t < M_PI * 20)
{
fun = sin(t);
}
return fun;
}
__global__ void maxwell_step(float * d_out, float * d_in, float boundary)
{
int id = threadIdx.x + blockIdx.x * blockDim.x;
... |
18,671 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#ifndef __CUDACC__
#define __CUDACC__
#endif
#include "device_launch_parameters.h"
#include <cuda.h>
#include <device_functions.h>
#include <cuda_runtime_api.h>
#include<time.h>
#include <stdio.h>
#include<malloc.h>
#include <cuda.h>
#include <stdio.h>
#... |
18,672 |
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <vector>
#include <stdio.h>
using Complex = float2;
#define CUBE_SIZE 16
#define TILE_WIDTH 16
void get_last_error()
{
cudaError_t cudastatus = cudaGetLastError();
if (cudastatus != cudaSuccess)
{
printf("%s", cudaGetErrorString(cudastatus... |
18,673 | #include <stdlib.h>
#include <time.h>
#include <stdio.h>
#define N (1024 * 1024)
#define FULL_DATA_SIZE (N * 10)
int main() {
srand(time(NULL));
int *dev_a;
int *dev_a_p;
int *h_a, *h_b;
int *h_a_p, *h_b_p;
float elapsed_time;
cudaEvent_t start, stop;
cudaEventCreate(&start);
cu... |
18,674 | #include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <device_functions.h>
int cpu_reduce(int *data, unsigned int n) {
int res = 0;
for (int i = 0; i < n; ++i)
res += data[i];
return res;
}
__global__ void reduce(int *data, int *result) ... |
18,675 | #include <iostream>
void init3DHostData(float **real, float **img, int length)
{
float *funcReal = new float[length*length*length];
float *funcImg = new float[length*length*length];
for (int i = 0; i < length; i++)
{
for (int j = 0; j < length; j++)
{
for (int k = 0; k < length; k++)
{
... |
18,676 | #include "stdio.h"
int main()
{
printf("Hello, world\n");
return 0;
}
|
18,677 | #include "includes.h"
__global__ void matrix_multiplication(int *matrix_1, int *matrix_2, int *matrix_r, int m, int n, int p){
int row = threadIdx.y + blockIdx.y * blockDim.y; // Multiply this row...
int col = threadIdx.x + blockIdx.x * blockDim.x; // with this column.
// Matrix multiplication as follows:
// (m x n)... |
18,678 | //pass
//--blockDim=64 --gridDim=64 --no-inline
#include "cuda.h"
__device__ void baz (int p []){
int a;
p = &a;
}
__device__ void bar (int *p){
int a;
p = &a;
}
__global__ void foo (int* p, int* q){
__shared__ int sharedArr [100];
__shared__ int sharedArr2 [50];
bar(p);
ba... |
18,679 | #include<stdio.h>
#define N 1000
__global__ void addvec(int *a, int *b, int *c)
{
int tid=blockIdx.x; //manejar los datos a este índice
if(tid<N)
c[tid]=a[tid]+b[tid];
}
//función principal
int main(void){
int a[N], b[N], c[N];
int *dev_a, *dev_b, *dev_c;
//asignar memoria en la GPU
cudaMalloc((void**)&... |
18,680 | // Solve the Laplace equation on a 2D lattice with boundary conditions.
//
// compile with the following command:
//
// (for GTX970)
// nvcc -arch=compute_52 -code=sm_52,sm_52 -O3 -m64 -o laplace laplace.cu
//
// (for GTX1060)
// nvcc -arch=compute_61 -code=sm_61,sm_61 -O3 -m64 -o laplace laplace.cu
// Includes
#incl... |
18,681 | #include <cmath>
#include <cstdio>
#include <cuda_runtime.h>
#include <iostream>
// CUDA Kernel function to add elements of two arrays on gpu
__global__ void add(int n, float* x, float* y) {
int index = blockIdx.x * blockDim.x + threadIdx.x;
int stride = blockDim.x * gridDim.x;
printf("%d, %d, %d\n", block... |
18,682 | #include <iostream>
#include <cuda.h>
#include <thrust/host_vector.h>
#include <thrust/device_vector.h>
#include <thrust/copy.h>
#include <thrust/scan.h>
void prefix_scan(float *in, float *out, int N)
{
thrust::host_vector<float> H(N);
for (int i = 0; i < N; i++)
{
H[i] = in[i];
}
thrust::device_vector<float> D... |
18,683 | #include "calc_cpu.cuh"
#define ROWS 1024
#define COLS 1024
using namespace std;
void matrix_mul_cpu(float* M, float* N, float* P, int width)
{
for (int i = 0; i < width; i++)
for (int j = 0; j < width; j++)
{
float sum = 0.0;
for (int k = 0; k < width; k++)
{
float a = M[i*width + k];
float b = ... |
18,684 | #include<cuda.h>
#include <stdio.h>
int main()
{
cudaDeviceProp Props;
cudaGetDeviceProperties( &Props,0);
printf("shared mem: %d)\n", Props.sharedMemPerBlock);
printf("max threads/block: %d\n",Props.maxThreadsPerBlock);
printf("max blocks: %d\n",Props.maxGridSize[0]);
printf("total Const mem: %d\n"... |
18,685 | #include "includes.h"
__global__ void vecAdd(float* A, float* B, float* C) {
//threadIdx.x is a build-in variable provided by CUDA runtime
int i = threadIdx.x;
A[i] = 0;
B[i] = 0;
C[i] = A[i] + B[i];
} |
18,686 | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <sys/time.h>
#include "time.h"
using namespace std;
__global__ void parMap(float *pD, float *netD, int grid)
{
unsigned int rID= blockDim.x*blockIdx.x + threadIdx.x;
int left, right, top, bottom;
float x,y, f... |
18,687 | #define BLOCK_SIZE 512
/*int max(int x, int y)
{
int retvalue = (x > y) ? x : y;
return retvalue;
}*/
__global__ void lz77kernel(char *in_d, char *out_d, int search_buffer_size, int uncoded_buffer_size)
{
// int maximum = 0;
int i = threadIdx.x + blockIdx.x * blockDim.x;
int k;
int j;
// int l;
ch... |
18,688 | #include <stdio.h>
#include <stdlib.h>
#include <cuda.h>
#include <cuda_runtime.h>
__global__ void sum(int *x) {
int index = blockIdx.x * blockDim.x + threadIdx.x;
x[index] = blockIdx.x + threadIdx.x;
}
int main() {
const int N = 16;
int x[N];
int *dArray;
cudaMalloc((void**) &dArray, sizeof(int) * N);
sum<... |
18,689 | #include <stdio.h>
#include <iostream>
#include <iomanip>
#include <cuda_runtime.h>
using namespace std;
void MatrixPrint(float *mat, int rows, int cols) {
for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols; j++) {
cout << setw(2) << mat[i*cols+j] << " ";
}
cout << endl;
... |
18,690 | #include <unistd.h>
#include <sys/stat.h>
#include <errno.h>
#include <stdlib.h>
#define makedev(maj, min) (((maj) << 8) | (min))
int main(int argc, char **argv) {
unsigned short newmode;
unsigned short filetype;
int major, minor;
newmode = 0666 & ~umask(0);
if (argc == 5) {
switch (argv[2][0]) {
case 'b'... |
18,691 | /** Original Question : https://stackoverflow.com/questions/13301309/
I'm working on a statistical application containing approximately 10 - 30 million floating point values in an array.
Several methods performing different, but independent, calculations on the array in nested loops, for example:
Dictionary<float, i... |
18,692 | // Simple CUDA example by Ingemar Ragnemalm 2009. Simplest possible?
// Assigns every element in an array with its index.
// nvcc simple.cu -L /usr/local/cuda/lib -lcudart -o simple
#include <stdio.h>
#include <chrono>
const int N = 16384;
const int blocksize1d = 64;
__global__
void threadnumber(float *c)
{
c[... |
18,693 | //pass
//--blockDim=10 --gridDim=64 --no-inline
#include "cuda.h"
__global__ void foo() {
__shared__ int A[11];
A[threadIdx.x] = 2;
__syncthreads ();
int x = A[threadIdx.x + 1];
}
|
18,694 | /**
* classifier.cu
*
* A CUDA kernel for accelerating a fully-connected neural network layer.
*/
#include <iostream>
#include <string>
using namespace std;
#ifndef Ni
#define Ni 4096
#endif
#ifndef Nn
#define Nn 1024
#endif
#ifndef Nb
#define Nb 1
#endif
#define DEBUG false
/* The weights of the layer*/
__de... |
18,695 | #include "stdio.h"
#define N 514 //Para correr con mas threads de los posibles en un bloque
//#define N 65537
__global__ void add(int *a, int *b, int *c)
{
int tid = threadIdx.x + blockIdx.x * blockDim.x; //El id del thread es el id que tiene ese thread dentro de un bloque
c[tid]=a[tid]+b[tid]; //El id del... |
18,696 | #include "includes.h"
__global__ void dot(int *a, int *b, int *c)
{
int i = blockIdx.x * blockDim.x + threadIdx.x;
while(i < N)
{
c[i] = a[i] * b[i];
i += blockDim.x * gridDim.x;
}
} |
18,697 | #include "includes.h"
__global__ void cosineKernel(float *a, float *b, float *outN, float *outD1, float *outD2, int size) {
extern __shared__ float sdata[];
unsigned int tid = threadIdx.x;
unsigned int i = blockIdx.x*(blockDim.x * 2) + threadIdx.x;
int stride = gridDim.x * blockDim.x;
while (i < size) {
sdata[3 * tid] ... |
18,698 | //nvcc filename.cu
//
// Torbert, 17 April 2013
//
#include <stdio.h>
//
#define N 8
#define logN 3
//
__global__ void pairwise_sums(int* tree, int* kuda)
{
int rank = threadIdx.x; //flat model
//
int pcol = rank;
int prow =* kuda;
int pindex = prow*N+pcol;
//
int lcol = 2*rank+0;
int lrow =* kuda + 1;
... |
18,699 | #include <cstdio>
#include <cuda_runtime.h>
__global__ void add(int a, int b, int *sum) {
*sum = a + b;
}
int main() {
int *result;
cudaMalloc((void**)&result, sizeof(int));
add<<<1, 1>>>(100, 200, result);
cudaDeviceSynchronize();
int h_result = 0;
cudaMemcpy(&h_result, result, sizeof(int), cudaMemcpy... |
18,700 | #include "includes.h"
__global__ void matriMult(int* m, int* n, int* p, int size){
// Calculate Row and Coulmn
int row = blockIdx.y * blockDim.y + threadIdx.y;
int column = blockIdx.x * blockDim.x + threadIdx.x;
int p_sum = 0;
for(int i = 0; i < size; i++){
p_sum += m[row * size + i] * n[i * size + column];
}
p[row * ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.