Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/performance/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Performance 渲染脚本GPU性能不与设备GFLPs一致?_Performance_Opencl_Gpu_Benchmarking_Renderscript - Fatal编程技术网

Performance 渲染脚本GPU性能不与设备GFLPs一致?

Performance 渲染脚本GPU性能不与设备GFLPs一致?,performance,opencl,gpu,benchmarking,renderscript,Performance,Opencl,Gpu,Benchmarking,Renderscript,作为一个测试,我正试图从GPU上尽可能多地压缩GFLOP,只是想看看我们可以通过RenderScript使用compute走多远 为此,我使用了一个GPU缓存友好内核,该内核(希望)在测试时不会限制内存访问: #pragma rs_fp_relaxed rs_allocation input; float __attribute__((kernel)) compute(float in, int x) { float sum = 0; if (x < 64) return

作为一个测试,我正试图从GPU上尽可能多地压缩GFLOP,只是想看看我们可以通过RenderScript使用compute走多远

为此,我使用了一个GPU缓存友好内核,该内核(希望)在测试时不会限制内存访问:

#pragma rs_fp_relaxed
rs_allocation input;

float __attribute__((kernel)) compute(float in, int x)
{
    float sum = 0;
    if (x < 64) return 0;
    for (int i = 0; i < 64; i++) {
        sum += rsGetElementAt_float(input, x - i);
    }
    return sum;
}
#pragma rs_fp_
rs_分配输入;
float _属性_((内核))计算(float-in,intx)
{
浮点数和=0;
如果(x<64)返回0;
对于(int i=0;i<64;i++){
sum+=rsGetElementAt_float(输入,x-i);
}
回报金额;
}
在Java方面,我只调用了内核几次:

for (int i = 0; i < 1024; i++) {
    m_script.forEach_compute(m_inAllocation, m_outAllocation);
}
for(int i=0;i<1024;i++){
m_script.forEach_compute(m_inAllocation,m_outAllocation);
}
当分配大小为1M浮动时,GPU上的最大流量约为1-2 GFLOPS,最大流量约为100 GFLOPS(Snapdragon 600,APQ8064AB),即计算性能降低50-100倍


我已经尝试过展开循环(10%的差异),使用较大或较小的总和(您使用的是什么设备?并非所有设备都附带GPU驱动程序


此外,内核将受到内存限制,因为您的算术负载比为1:1。

我已经检查了GPU缓存是否按照预期工作,在这种情况下,内核将按照您的建议受到内存限制,只需使用传递的输入变量,即sum+=in(与sum+=rsGetElementAt_float(input,x-I))即可。这造成的差异小于10%,因此缓存工作,内核没有内存限制。GetElement的内存计算很好,顺便说一句!V/RenderScript_jni﹕ RS本机模式V/RenderScript﹕ 0x75aa80b8启动线程,CPU 4 10-13 23:37:53.649 10893-I/Adreno EGL﹕ : EGL 1.4高通公司构建:_msm8960_kk_2.7_发行版_AU()OpenGL ES着色器编译器版本:20.00.01构建日期:11/07/13周四本地分支:klp远程分支:quic/hammerhead_klp本地补丁:无重建分支:无任何D/OpenGLRenderer﹕ 启用调试模式0FWIW:Java中的分配:
Type Type=new Type.Builder(m_-rs,Element.F32(m_-rs)).setX(1024.setY(1024.create();m_-inAllocation=allocation.createTyped(m_-rs,Type,allocation.USAGE_脚本)
您应该使用更难的数学来测试GFLOPS性能。简单的求和显然是内存方面的瓶颈(不管缓存如何工作,仍然是瓶颈)。对于100GFLOPS,您需要内核800GB/s的内存带宽。请参阅下面的注释,这是使用的内核:
float\u属性__((内核)饱和(float-in,int-x,int-y){float-sum=1.0;for(int-i=0;i<64;i++){sum*=in;}返回和;}
这似乎是计算边界如果你的编译器足够聪明,那么代码将简化为'sum*in*64;'不太受计算约束。请不要进行优化。此内核计算
pow(in,64)
,而不是中的
sum*64*。没错,是我的错。无论如何,希望编译器不够聪明,无法生成优化的代码。