用于GPU通用计算的编程语言BrookGPU 0.4

源代码在线查看: indexof.br

软件大小: 951 K
上传用户: zjf646
关键词: BrookGPU GPU 0.4 计算
下载地址: 免注册下载 普通下载 VIP

相关代码

				// indexof.br				//				// Tests the built-in operator 'indexof.' It confirms the invariant that				// when a stream is passed as both a stream argument and a gather argument				// to a kernel, fetching from the gather argument with the index of the				// stream argument should produce the same value as the stream argument.								#include 								extern void printf();				extern void streamRead();				extern void streamWrite();								kernel void				bar(float d_prime, float d[10][10], out float4 e, float4 indexofe)				{				  /* this test should make a matrix of 1 and a diagonal of 0's*/				  e = float4(d[indexof(d_prime)],				             d[indexof(d_prime).xy],				             d[indexof(d_prime).xy],				             d[1?(indexofe).xy:indexofe.zz]);				}												kernel void				foo(float d_prime, float d[10][10],out float4 e)				{				   bar(d_prime,d,e,indexof(e));				}								kernel void				test(float a, out float b)				{				   b = (indexof(a)).x;				}												int main(void)				{				  float data_d[10][10];				  float d;				  float c;				  float4 e;				  float4 data_e[10][10];				  float data_c[10][10];				  int i,j;								  for (i=0; i				    for (j=0; j				      data_d[i][j] = ((float) i*10+j);				    }				  }								  streamRead(d, data_d);				  test(d,c);				  streamWrite(c, data_c);								  printf("Here are the results from the simple indexof test:\n");				  for (i=0; i				    for (j=0; j				      printf ("%3.2f  ", (float)(int)data_c[i][j]);				    }				    printf ("\n");				  }				  printf ("\n");								  foo(d,d,e);				  streamWrite(e, data_e);								  printf("Here are the results from the advanced indexof test:\n");				  for (i=0; i				    for (j=0; j				      if (!(j%2))				        printf ("\n");								      printf ("%3.2f %3.2f %3.2f %3.2f\t", 				              data_e[i][j].x, data_e[i][j].y,				              data_e[i][j].z, data_e[i][j].w);				    }				  }				  printf("\n");								  return 0;				}							

相关资源