Skip to content
Snippets Groups Projects
Commit fb864019 authored by Yifan Zhao's avatar Yifan Zhao
Browse files

Removed unused files in benchmarks

parent ec3e7deb
No related branches found
No related tags found
No related merge requests found
/***************************************************************************
*cr
*cr (C) Copyright 2010 The Board of Trustees of the
*cr University of Illinois
*cr All Rights Reserved
*cr
***************************************************************************/
/*
* Kernel of dense matrix-matrix multiplication kernel.
*/
__kernel void mysgemmNT(__global const float* A, long bytes_A, int lda, __global const float* B, long bytes_B, int ldb, __global float* C, long bytes_C,
int ldc, int k, float alpha, float beta)
{
float c = 0.0f;
int m = get_global_id(0);
int n = get_global_id(1);
for (int i = 0; i < k; ++i) {
float a = A[m + i * lda];
float b = B[n + i * ldb];
c += a * b;
}
C[m+n*ldc] = C[m+n*ldc] * beta + alpha * c;
}
/***************************************************************************
*cr
*cr (C) Copyright 2010 The Board of Trustees of the
*cr University of Illinois
*cr All Rights Reserved
*cr
***************************************************************************/
#define WARP_BITS 5
__kernel void spmv_jds(__global float *dst_vector, __global float *d_data,
__global int *d_index, __global int *d_perm,
__global float *x_vec, const int dim,
__constant int *jds_ptr_int,
__constant int *sh_zcnt_int)
{
int ix = get_global_id(0);
int warp_id=ix>>WARP_BITS;
if(ix<dim)
{
float sum=0.0f;
int bound=sh_zcnt_int[warp_id];
//prefetch 0
int j=jds_ptr_int[0]+ix;
float d = d_data[j];
int i = d_index[j];
float t = x_vec[i];
if (bound>1) //bound >=2
{
//prefetch 1
j=jds_ptr_int[1]+ix;
i = d_index[j];
int in;
float dn;
float tn;
for(int k=2;k<bound;k++ )
{
//prefetch k-1
dn = d_data[j];
//prefetch k
j=jds_ptr_int[k]+ix;
in = d_index[j];
//prefetch k-1
tn = x_vec[i];
//compute k-2
sum += d*t;
//sweep to k
i = in;
//sweep to k-1
d = dn;
t =tn;
}
//fetch last
dn = d_data[j];
tn = x_vec[i];
//compute last-1
sum += d*t;
//sweep to last
d=dn;
t=tn;
}
//compute last
sum += d*t; // 3 3
//write out data
dst_vector[d_perm[ix]]=sum;
}
}
#include <endian.h>
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#if __BYTE_ORDER != __LITTLE_ENDIAN
#error "File I/O is not implemented for this system: wrong endianness."
#endif
static int generate_vector(float *x_vector, int dim) {
srand(54321);
int i;
for (i = 0; i < dim; i++) {
x_vector[i] = (rand() / (float)RAND_MAX);
}
return 0;
}
void outputData(char *fName, float *A0, int dim) {
FILE *fid = fopen(fName, "w");
if (fid == NULL) {
fprintf(stderr, "Cannot open output file\n");
exit(-1);
}
fwrite(A0, sizeof(float), dim, fid);
fclose(fid);
}
int main(int argc, char **argv) {
int dim;
dim = atoi(argv[1]);
char *writefn = argv[2];
float *outV = (float *)malloc(dim * sizeof(float));
generate_vector(outV, dim);
outputData(writefn, outV, dim);
return 0;
}
/***************************************************************************
*cr
*cr (C) Copyright 2010 The Board of Trustees of the
*cr University of Illinois
*cr All Rights Reserved
*cr
***************************************************************************/
#include "common.h"
__kernel void naive_kernel(float c0,float c1,__global float* A0,__global float *Anext,int nx,int ny,int nz)
{
int i = get_global_id(0)+1;
int j = get_global_id(1)+1;
int k = get_global_id(2)+1;
if(i<nx-1)
{
Anext[Index3D (nx, ny, i, j, k)] = c1 *
( A0[Index3D (nx, ny, i, j, k + 1)] +
A0[Index3D (nx, ny, i, j, k - 1)] +
A0[Index3D (nx, ny, i, j + 1, k)] +
A0[Index3D (nx, ny, i, j - 1, k)] +
A0[Index3D (nx, ny, i + 1, j, k)] +
A0[Index3D (nx, ny, i - 1, j, k)] )
- A0[Index3D (nx, ny, i, j, k)] * c0;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment