/tomo/pyhst

To get this branch, use:
bzr branch http://darksoft.org/webbzr/tomo/pyhst

« back to all changes in this revision

Viewing changes to hst_opencl/hst_opencl_kernels.cl

  • Committer: Suren A. Chilingaryan
  • Date: 2012-05-10 15:06:33 UTC
  • Revision ID: csa@dside.dyndns.org-20120510150633-56gdy6t3tflz2gab
OpenCL clean-up

Show diffs side-by-side

added added

removed removed

Lines of Context:
971
971
    const int idx = bidx - sidx;
972
972
    const int idy = bidy + sidy;
973
973
 
974
 
 
975
974
    const int slice_width = 2 * get_global_size(0);
976
975
 
977
976
    float res[4] = {0.f, 0.f, 0.f, 0.f};
1017
1016
 
1018
1017
 
1019
1018
#undef subh_cache
1020
 
#define subh_cache(subh) cache[(int)(subh)]
 
1019
#define subh_cache(subh) cache[subh]
1021
1020
__kernel void hst_backproject_amd_direct_oversample4(const int num_proj, 
1022
1021
    const int num_bins, 
1023
1022
    const float off_x, 
1027
1026
    __constant float4 *c_all, 
1028
1027
    __local float *shared
1029
1028
    ) {
1030
 
 
1031
 
    __local float *cache = shared;                                              // cache[BLOCK_SIZE_Y][12 * BLOCK_SIZE_X + 1];
 
1029
    __local float *mcache = shared;
 
1030
    __local float *cache = shared + BLOCK_SIZE * BLOCK_SIZE;                                            // cache[BLOCK_SIZE_Y][12 * BLOCK_SIZE_X + 1];
1032
1031
 
1033
1032
    const int tidx = get_local_id(0);
1034
1033
    const int tidy = get_local_id(1);
1035
1034
 
1036
1035
    const int bidx = 2 * get_group_id(0) * BLOCK_SIZE;
1037
 
//    const int bidy = 2 * get_group_id(1) * BLOCK_SIZE;
1038
1036
    const int bidy = 2 * (get_global_id(1) - get_local_id(1));
1039
1037
 
1040
1038
    const float bx = bidx + off_x;
1047
1045
    const int stidx = tidx % 8;
1048
1046
    const int stidy = tidx / 8;
1049
1047
    
1050
 
    const int sidx = - (sbidx * 8 + stidx);
 
1048
    const int sidx = (sbidx * 8 + stidx);
1051
1049
    const int sidy = sbidy * 8 + 4 * stidy;
1052
1050
 
1053
 
    const int idx = bidx - sidx;
 
1051
    const int idx = bidx + sidx;
1054
1052
    const int idy = bidy + sidy;
1055
1053
 
1056
 
 
 
1054
    const float x = idx + off_x;
 
1055
    const float y = idy + off_y;
1057
1056
    
1058
1057
    const int slice_width = 2 * get_global_size(0);
1059
1058
 
1060
1059
    float4 res = {0.f, 0.f, 0.f, 0.f};
1061
1060
    
1062
 
    for (int proje=0; proje<num_proj; proje += BLOCK_SIZE) {
1063
 
        int proj = proje + tidy;
1064
 
        float4 all = c_all[proj];
1065
 
        float minh = all.z + bx * all.x - by * all.y + all.w;
 
1061
    const int num_blocks = (num_proj / BLOCK_SIZE) +  ((num_proj % BLOCK_SIZE)?1:0);
 
1062
    
 
1063
    for (int proj_block = 0; proj_block < num_blocks; proj_block += BLOCK_SIZE) {
 
1064
        const int proj_offset = proj_block * BLOCK_SIZE;
 
1065
        float4 all = c_all[proj_offset + BLOCK_SIZE * tidy + tidx];
 
1066
 
 
1067
        float minh = floor(all.z + bx * all.x - by * all.y + all.w);
 
1068
        mcache[BLOCK_SIZE * tidy + tidx] = 193.f * tidx - 4 * minh;
 
1069
 
 
1070
        barrier(CLK_LOCAL_MEM_FENCE);
 
1071
 
 
1072
        const int sub_blocks = min(BLOCK_SIZE, num_blocks - proj_block);
 
1073
        
 
1074
        for (int p = 0; p < sub_blocks; p++) {
 
1075
            const int proje = proj_offset + p * BLOCK_SIZE;
 
1076
            const int proj = proje + tidy;
 
1077
            
 
1078
            float minh = 193.f * tidy - mcache[p * BLOCK_SIZE + tidy];
1066
1079
 
1067
1080
#pragma unroll 12
1068
 
        for (int i = 0; i < 12; i++) {
1069
 
            int pos = i * BLOCK_SIZE + tidx;
1070
 
            cache[tidy * (12 * BLOCK_SIZE + 1) + pos] = read_imagef(sinogram, volumeSampler, (float2)(minh + 0.25f*pos, proj + 0.5f)).x;
1071
 
        }
1072
 
 
1073
 
        barrier(CLK_LOCAL_MEM_FENCE);
1074
 
 
1075
 
 
 
1081
            for (int i = 0; i < 12; i++) {
 
1082
                int pos = i * BLOCK_SIZE + tidx;
 
1083
                cache[tidy * (12 * BLOCK_SIZE + 1) + pos] = read_imagef(sinogram, volumeSampler, (float2)(0.25f * (minh + pos), proj + 0.5f)).x;
 
1084
            }
 
1085
 
 
1086
            barrier(CLK_LOCAL_MEM_FENCE);
 
1087
            
1076
1088
#pragma unroll 16
1077
 
        for (int i = 0; i < BLOCK_SIZE; i++) {
1078
 
            float4 all = -4 * c_all[proje + i];
1079
 
 
1080
 
            //float subh = (-sidx * all.x - sidy * all.y) - all.w;
1081
 
            float subh = mad(193.f, i, mad(sidx, all.x, mad(sidy, all.y, all.w)));
1082
 
            
1083
 
            res.x += subh_cache(subh);
1084
 
            res.y += subh_cache(mad(1.f, all.y, subh));
1085
 
            res.z += subh_cache(mad(2.f, all.y, subh));
1086
 
            res.w += subh_cache(mad(3.f, all.y, subh));
1087
 
        }
1088
 
 
1089
 
        barrier(CLK_LOCAL_MEM_FENCE);
 
1089
            for (int i = 0; i < BLOCK_SIZE; i++) {
 
1090
//            float4 all = -4 * c_all[proje + i];
 
1091
//            float subh = mad(193.f, i, mad(sidx, all.x, mad(sidy, all.y, all.w)));
 
1092
              float4 all = c_all[proje + i]; all.y = -all.y;
 
1093
//              float minh = 193 * i - 4 * floor(all.z + bx * all.x + by * all.y + all.w);
 
1094
 
 
1095
                float minh = mcache[p * BLOCK_SIZE + i];
 
1096
 
 
1097
                float subh = mad(4,  mad(x, all.x, mad(y, all.y, all.z)),  minh);
 
1098
                res.x += subh_cache((int)subh);
 
1099
                res.y += subh_cache((int)mad(4.f, all.y, subh));
 
1100
                res.z += subh_cache((int)mad(8.f, all.y, subh));
 
1101
                res.w += subh_cache((int)mad(12.f, all.y, subh));
 
1102
            }
 
1103
 
 
1104
            barrier(CLK_LOCAL_MEM_FENCE);
 
1105
        }
1090
1106
    }
1091
1107
 
1092
1108
    slice[slice_width * (idy    ) + idx] = res.x;
1126
1142
    const int stidx = tidx % 4;
1127
1143
    const int stidy = tidx / 4;
1128
1144
    
1129
 
    const int sidx = - (sbidx * 8 + 2 * stidx);
 
1145
    const int sidx = (sbidx * 8 + 2 * stidx);
1130
1146
    const int sidy = sbidy * 8 + 2 * stidy;
1131
1147
 
1132
 
    const int idx = bidx - sidx;
 
1148
    const int idx = bidx + sidx;
1133
1149
    const int idy = bidy + sidy;
1134
1150
 
1135
 
 
 
1151
    const float x = idx + off_x;
 
1152
    const float y = idy + off_y;
1136
1153
    
1137
1154
    const int slice_width = 2 * get_global_size(0);
1138
1155
 
1141
1158
    for (int proje=0; proje<num_proj; proje += BLOCK_SIZE) {
1142
1159
        int proj = proje + tidy;
1143
1160
        float4 all = c_all[proj];
1144
 
        float minh = all.z + bx * all.x - by * all.y + all.w;
 
1161
        float minh = floor(all.z + bx * all.x - by * all.y + all.w);
1145
1162
 
1146
1163
#pragma unroll 12
1147
1164
        for (int i = 0; i < 3; i++) {
1163
1180
        for (int i = 0; i < BLOCK_SIZE; i++) {
1164
1181
            float2 v;
1165
1182
            float4 v1, v2;
1166
 
            float4 all = - c_all[proje + i];
 
1183
            float4 all = c_all[proje + i]; all.y = - all.y;
1167
1184
            float4 h;
 
1185
//          float minh = all.z + bx * all.x - by * all.y + all.w;
1168
1186
 
1169
 
            //float subh = (-sidx * all.x - sidy * all.y) - all.w;
1170
 
            h.x = mad(49.f, i, mad(sidx, all.x, mad(sidy, all.y, all.w)));
1171
 
            h.y = h.x - all.x;
 
1187
            float minh = floor(all.z + bx * all.x + by * all.y + all.w);
 
1188
            h.x = mad(49.f, i, mad(x, all.x, mad(y, all.y, all.z))) - minh;
 
1189
            
 
1190
//            h.x = mad(49.f, i, mad(sidx, all.x, mad(sidy, all.y, all.w)));
 
1191
            h.y = h.x + all.x;
1172
1192
            h.z = h.x + all.y;
1173
1193
            h.w = h.y + all.y;
1174
1194
            
1192
1212
    slice[slice_width * (idy + 1) + idx + 1] = res.w;
1193
1213
}
1194
1214
 
 
1215
/*
1195
1216
#undef subh_cache
1196
1217
#define subh_cache(subh) cache[(int)(subh)]
1197
1218
__kernel void hst_backproject_dma_oversample4(const int num_proj, 
1306
1327
    }
1307
1328
 
1308
1329
}
 
1330
*/
 
1331
 
 
1332
 
 
1333
#undef subh_cache
 
1334
#define subh_cache(subh) cache[(int)(subh)]
 
1335
 
 
1336
#define PPT 6
 
1337
__kernel void hst_backproject_6ppt_oversample4(const int num_proj, 
 
1338
    const int num_bins, 
 
1339
    const float off_x, 
 
1340
    const float off_y, 
 
1341
    __read_only image2d_t sinogram,
 
1342
    __global float *slice,
 
1343
    __constant float4 *c_all, 
 
1344
    __local float *cache
 
1345
    ) {
 
1346
    const int tidx = get_local_id(0);
 
1347
    const int tidy = get_local_id(1);
 
1348
 
 
1349
    const int bidx = PPT * get_group_id(0) * get_local_size(0);
 
1350
    const int bidy = PPT * (get_global_id(1) - get_local_id(1));
 
1351
 
 
1352
    const float bx = bidx + off_x;
 
1353
    const float by = bidy + off_y;
 
1354
 
 
1355
/*
 
1356
    const int sbidx = tidy % 4;
 
1357
    const int sbidy = tidy / 4;
 
1358
    
 
1359
    const int stidx = tidx % 4;
 
1360
    const int stidy = tidx / 4;
 
1361
 
 
1362
    const int sidx = (sbidx * 4 + stidx);
 
1363
    const int sidy = (sbidy * 4 + stidy);
 
1364
*/
 
1365
 
 
1366
    const int sidx = tidx;
 
1367
    const int sidy = tidy;
 
1368
 
 
1369
 
 
1370
    const float sx = sidx;
 
1371
    const float sy = sidy;
 
1372
 
 
1373
    const int idx = bidx + sidx;
 
1374
    const int idy = bidy + sidy;
 
1375
 
 
1376
    const float x = idx + off_x;
 
1377
    const float y = idy + off_y;
 
1378
 
 
1379
    const int slice_width = PPT * get_global_size(0);
 
1380
 
 
1381
    float res[PPT][PPT] = {0};
 
1382
    for (int proj = 0; proj < num_proj; proj++) {
 
1383
        float4 all = c_all[proj]; all.y = -all.y;
 
1384
        float minh = floor(all.z + bx * all.x + by * all.y + all.w);
 
1385
 
 
1386
#pragma unroll 5
 
1387
        for (int i = 0; i < 5; i++) {
 
1388
            int pos = i * get_local_size(0) * get_local_size(0) + tidy * get_local_size(0) + tidx;
 
1389
            cache[pos] = read_imagef(sinogram, volumeSampler, (float2)(minh + 0.25f*pos, proj + .5f)).x;
 
1390
        }
 
1391
 
 
1392
        barrier(CLK_LOCAL_MEM_FENCE);
 
1393
 
 
1394
 
 
1395
        all *= 4;
 
1396
        float h = mad(x, all.x, mad(y, all.y, all.z)) - 4 * minh;
 
1397
 
 
1398
#pragma unroll 6
 
1399
        for (int i = 0; i < PPT; i++) {
 
1400
#pragma unroll 6
 
1401
            for (int j = 0; j < PPT; j++) {
 
1402
                res[i][j] += subh_cache(h + (i * get_local_size(0)) * all.y + (j * get_local_size(0)) * all.x);
 
1403
            }
 
1404
        }
 
1405
 
 
1406
        barrier(CLK_LOCAL_MEM_FENCE);
 
1407
    }
 
1408
 
 
1409
#pragma unroll 6
 
1410
    for (int i = 0; i < PPT; i++) {
 
1411
#pragma unroll 6
 
1412
        for (int j = 0; j < PPT; j++) {
 
1413
            slice[(idy + get_local_size(1) * i) * slice_width +  idx + get_local_size(0) * j] = res[i][j];
 
1414
        }
 
1415
    }
 
1416
}
 
1417
 
 
1418
 
 
1419
__kernel void hst_backproject_6ppt_tex(const int num_proj, 
 
1420
    const int num_bins, 
 
1421
    const float off_x, 
 
1422
    const float off_y, 
 
1423
    __read_only image2d_t sinogram,
 
1424
    __global float *slice,
 
1425
    __constant float4 *c_all/*, 
 
1426
    __local float *shared*/
 
1427
    ) {
 
1428
 
 
1429
    const int tidx = get_local_id(0);
 
1430
    const int tidy = get_local_id(1);
 
1431
 
 
1432
    const int sidx = tidx;
 
1433
    const int sidy = tidy;
 
1434
 
 
1435
    const int idx = PPT * get_group_id(0) * get_local_size(0) + sidx;
 
1436
    const int idy = PPT * (get_global_id(1) - get_local_id(1)) + sidy;
 
1437
 
 
1438
    const float x = idx + off_x;
 
1439
    const float y = idy + off_y;
 
1440
 
 
1441
    const int slice_width = PPT * get_global_size(0);
 
1442
 
 
1443
    float res[PPT][PPT] = {0};
 
1444
 
 
1445
    for (int proj = 0; proj < num_proj; proj++) {
 
1446
        float4 all = c_all[proj];
 
1447
        all.y = - all.y;
 
1448
        float subh = mad(x, all.x, mad(y, all.y, all.z));
 
1449
 
 
1450
#pragma unroll 6
 
1451
        for (int i = 0; i < PPT; i++) {
 
1452
#pragma unroll 6
 
1453
            for (int j = 0; j < PPT; j++) {
 
1454
                res[i][j] += read_imagef(sinogram, volumeSampler, (float2)(subh + i * get_local_size(1) * all.y + j * get_local_size(0) * all.x, proj + .5f)).x;
 
1455
            }
 
1456
        }
 
1457
    }
 
1458
 
 
1459
 
 
1460
#pragma unroll 6
 
1461
    for (int i = 0; i < PPT; i++) {
 
1462
#pragma unroll 6
 
1463
        for (int j = 0; j < PPT; j++) {
 
1464
            slice[(idy + get_local_size(1) * i) * slice_width +  idx + get_local_size(0) * j] = res[i][j];
 
1465
        }
 
1466
    }
 
1467
}
 
1468
 
 
1469
 
 
1470
/*
 
1471
__kernel void hst_backproject_6ppt(const int num_proj, 
 
1472
    const int num_bins, 
 
1473
    const float off_x, 
 
1474
    const float off_y, 
 
1475
    __read_only image2d_t sinogram,
 
1476
    __global float *slice,
 
1477
    __constant float4 *c_all, 
 
1478
    __local float *cache) {
 
1479
 
 
1480
 
 
1481
    const int mode = (get_group_id(1) * get_num_groups(0) + get_group_id(0)) % 5;
 
1482
    if (mode < 2) {
 
1483
        hst_backproject_test_oversample4_2(num_proj, num_bins, off_x, off_y, sinogram, slice, c_all, cache);
 
1484
    } else {
 
1485
        hst_backproject_test_oversample4_1(num_proj, num_bins, off_x, off_y, sinogram, slice, c_all, cache);
 
1486
    }
 
1487
}
 
1488
*/
 
1489
 
 
1490
 
 
1491
#undef PPT
 
1492
#define PPT 8
 
1493
/*
 
1494
__kernel void hst_backproject_8ppt_vliw_oversample4(const int num_proj, 
 
1495
    const int num_bins, 
 
1496
    const float off_x, 
 
1497
    const float off_y, 
 
1498
    __read_only image2d_t sinogram,
 
1499
    __global float *slice,
 
1500
    __constant float4 *c_all, 
 
1501
    __local float *cache
 
1502
    ) {
 
1503
    const int tidx = get_local_id(0);
 
1504
    const int tidy = get_local_id(1);
 
1505
 
 
1506
    const int bidx = PPT * get_group_id(0) * get_local_size(0);
 
1507
    const int bidy = PPT * (get_global_id(1) - get_local_id(1));
 
1508
 
 
1509
    const float bx = bidx + off_x;
 
1510
    const float by = bidy + off_y;
 
1511
 
 
1512
    const int sidx = tidx;
 
1513
    const int sidy = tidy;
 
1514
 
 
1515
    const int idx = bidx + sidx;
 
1516
    const int idy = bidy + sidy;
 
1517
 
 
1518
    const float x = idx + off_x;
 
1519
    const float y = idy + off_y;
 
1520
 
 
1521
    const int slice_width = PPT * get_global_size(0);
 
1522
 
 
1523
    float res[PPT][PPT] = {0};
 
1524
    for (int proj = 0; proj < num_proj; proj++) {
 
1525
        float4 all = c_all[proj]; all.y = -all.y;
 
1526
        float minh = floor(all.z + bx * all.x + by * all.y + all.w);
 
1527
 
 
1528
#pragma unroll 6
 
1529
        for (int i = 0; i < 6; i++) {
 
1530
            int pos = i * get_local_size(0) * get_local_size(0) + tidy * get_local_size(0) + tidx;
 
1531
            cache[pos] = read_imagef(sinogram, volumeSampler, (float2)(minh + 0.25f*pos, proj + .5f)).x;
 
1532
        }
 
1533
 
 
1534
        barrier(CLK_LOCAL_MEM_FENCE);
 
1535
 
 
1536
 
 
1537
        all *= 4;
 
1538
        float h = mad(x, all.x, mad(y, all.y, all.z)) - 4 * minh;
 
1539
 
 
1540
#pragma unroll 8
 
1541
        for (int i = 0; i < PPT; i++) {
 
1542
#pragma unroll 8
 
1543
            for (int j = 0; j < PPT; j++) {
 
1544
                res[i][j] += subh_cache(h + (i * get_local_size(0)) * all.y + (j * get_local_size(0)) * all.x);
 
1545
            }
 
1546
        }
 
1547
 
 
1548
        barrier(CLK_LOCAL_MEM_FENCE);
 
1549
    }
 
1550
 
 
1551
#pragma unroll 8
 
1552
    for (int i = 0; i < PPT; i++) {
 
1553
#pragma unroll 8
 
1554
        for (int j = 0; j < PPT; j++) {
 
1555
            slice[(idy + get_local_size(1) * i) * slice_width +  idx + get_local_size(0) * j] = res[i][j];
 
1556
        }
 
1557
    }
 
1558
}
 
1559
*/
 
1560
 
 
1561
__kernel void hst_backproject_8ppt_vliw_oversample4(const int num_proj, 
 
1562
    const int num_bins, 
 
1563
    const float off_x, 
 
1564
    const float off_y, 
 
1565
    __read_only image2d_t sinogram,
 
1566
    __global float *slice,
 
1567
    __constant float4 *c_all, 
 
1568
    __local float *cache
 
1569
    ) {
 
1570
    const int tidx = get_local_id(0);
 
1571
    const int tidy = get_local_id(1);
 
1572
 
 
1573
    const int bidx = PPT * get_group_id(0) * get_local_size(0);
 
1574
    const int bidy = PPT * (get_global_id(1) - get_local_id(1));
 
1575
 
 
1576
    const float bx = bidx + off_x;
 
1577
    const float by = bidy + off_y;
 
1578
 
 
1579
    const int sidx = tidx;
 
1580
    const int sidy = tidy;
 
1581
 
 
1582
    const int idx = bidx + sidx;
 
1583
    const int idy = bidy + sidy;
 
1584
 
 
1585
    const float x = idx + off_x;
 
1586
    const float y = idy + off_y;
 
1587
 
 
1588
    const int slice_width = PPT * get_global_size(0);
 
1589
 
 
1590
float res_0_0 = 0;
 
1591
float res_0_1 = 0;
 
1592
float res_0_2 = 0;
 
1593
float res_0_3 = 0;
 
1594
float res_0_4 = 0;
 
1595
float res_0_5 = 0;
 
1596
float res_0_6 = 0;
 
1597
float res_0_7 = 0;
 
1598
float res_1_0 = 0;
 
1599
float res_1_1 = 0;
 
1600
float res_1_2 = 0;
 
1601
float res_1_3 = 0;
 
1602
float res_1_4 = 0;
 
1603
float res_1_5 = 0;
 
1604
float res_1_6 = 0;
 
1605
float res_1_7 = 0;
 
1606
float res_2_0 = 0;
 
1607
float res_2_1 = 0;
 
1608
float res_2_2 = 0;
 
1609
float res_2_3 = 0;
 
1610
float res_2_4 = 0;
 
1611
float res_2_5 = 0;
 
1612
float res_2_6 = 0;
 
1613
float res_2_7 = 0;
 
1614
float res_3_0 = 0;
 
1615
float res_3_1 = 0;
 
1616
float res_3_2 = 0;
 
1617
float res_3_3 = 0;
 
1618
float res_3_4 = 0;
 
1619
float res_3_5 = 0;
 
1620
float res_3_6 = 0;
 
1621
float res_3_7 = 0;
 
1622
float res_4_0 = 0;
 
1623
float res_4_1 = 0;
 
1624
float res_4_2 = 0;
 
1625
float res_4_3 = 0;
 
1626
float res_4_4 = 0;
 
1627
float res_4_5 = 0;
 
1628
float res_4_6 = 0;
 
1629
float res_4_7 = 0;
 
1630
float res_5_0 = 0;
 
1631
float res_5_1 = 0;
 
1632
float res_5_2 = 0;
 
1633
float res_5_3 = 0;
 
1634
float res_5_4 = 0;
 
1635
float res_5_5 = 0;
 
1636
float res_5_6 = 0;
 
1637
float res_5_7 = 0;
 
1638
float res_6_0 = 0;
 
1639
float res_6_1 = 0;
 
1640
float res_6_2 = 0;
 
1641
float res_6_3 = 0;
 
1642
float res_6_4 = 0;
 
1643
float res_6_5 = 0;
 
1644
float res_6_6 = 0;
 
1645
float res_6_7 = 0;
 
1646
float res_7_0 = 0;
 
1647
float res_7_1 = 0;
 
1648
float res_7_2 = 0;
 
1649
float res_7_3 = 0;
 
1650
float res_7_4 = 0;
 
1651
float res_7_5 = 0;
 
1652
float res_7_6 = 0;
 
1653
float res_7_7 = 0;
 
1654
 
 
1655
    for (int proj = 0; proj < num_proj; proj++) {
 
1656
        float4 all = c_all[proj]; all.y = -all.y;
 
1657
        float minh = floor(all.z + bx * all.x + by * all.y + all.w);
 
1658
 
 
1659
#pragma unroll 6
 
1660
        for (int i = 0; i < 6; i++) {
 
1661
            int pos = i * get_local_size(0) * get_local_size(0) + tidy * get_local_size(0) + tidx;
 
1662
            cache[pos] = read_imagef(sinogram, volumeSampler, (float2)(minh + 0.25f*pos, proj + .5f)).x;
 
1663
        }
 
1664
 
 
1665
        barrier(CLK_LOCAL_MEM_FENCE);
 
1666
 
 
1667
 
 
1668
        all *= 4;
 
1669
        float h = mad(x, all.x, mad(y, all.y, all.z)) - 4 * minh;
 
1670
 
 
1671
res_0_0 += subh_cache(h + (0 * get_local_size(0)) * all.y + (0 * get_local_size(0)) * all.x);
 
1672
res_0_1 += subh_cache(h + (0 * get_local_size(0)) * all.y + (1 * get_local_size(0)) * all.x);
 
1673
res_0_2 += subh_cache(h + (0 * get_local_size(0)) * all.y + (2 * get_local_size(0)) * all.x);
 
1674
res_0_3 += subh_cache(h + (0 * get_local_size(0)) * all.y + (3 * get_local_size(0)) * all.x);
 
1675
res_0_4 += subh_cache(h + (0 * get_local_size(0)) * all.y + (4 * get_local_size(0)) * all.x);
 
1676
res_0_5 += subh_cache(h + (0 * get_local_size(0)) * all.y + (5 * get_local_size(0)) * all.x);
 
1677
res_0_6 += subh_cache(h + (0 * get_local_size(0)) * all.y + (6 * get_local_size(0)) * all.x);
 
1678
res_0_7 += subh_cache(h + (0 * get_local_size(0)) * all.y + (7 * get_local_size(0)) * all.x);
 
1679
res_1_0 += subh_cache(h + (1 * get_local_size(0)) * all.y + (0 * get_local_size(0)) * all.x);
 
1680
res_1_1 += subh_cache(h + (1 * get_local_size(0)) * all.y + (1 * get_local_size(0)) * all.x);
 
1681
res_1_2 += subh_cache(h + (1 * get_local_size(0)) * all.y + (2 * get_local_size(0)) * all.x);
 
1682
res_1_3 += subh_cache(h + (1 * get_local_size(0)) * all.y + (3 * get_local_size(0)) * all.x);
 
1683
res_1_4 += subh_cache(h + (1 * get_local_size(0)) * all.y + (4 * get_local_size(0)) * all.x);
 
1684
res_1_5 += subh_cache(h + (1 * get_local_size(0)) * all.y + (5 * get_local_size(0)) * all.x);
 
1685
res_1_6 += subh_cache(h + (1 * get_local_size(0)) * all.y + (6 * get_local_size(0)) * all.x);
 
1686
res_1_7 += subh_cache(h + (1 * get_local_size(0)) * all.y + (7 * get_local_size(0)) * all.x);
 
1687
res_2_0 += subh_cache(h + (2 * get_local_size(0)) * all.y + (0 * get_local_size(0)) * all.x);
 
1688
res_2_1 += subh_cache(h + (2 * get_local_size(0)) * all.y + (1 * get_local_size(0)) * all.x);
 
1689
res_2_2 += subh_cache(h + (2 * get_local_size(0)) * all.y + (2 * get_local_size(0)) * all.x);
 
1690
res_2_3 += subh_cache(h + (2 * get_local_size(0)) * all.y + (3 * get_local_size(0)) * all.x);
 
1691
res_2_4 += subh_cache(h + (2 * get_local_size(0)) * all.y + (4 * get_local_size(0)) * all.x);
 
1692
res_2_5 += subh_cache(h + (2 * get_local_size(0)) * all.y + (5 * get_local_size(0)) * all.x);
 
1693
res_2_6 += subh_cache(h + (2 * get_local_size(0)) * all.y + (6 * get_local_size(0)) * all.x);
 
1694
res_2_7 += subh_cache(h + (2 * get_local_size(0)) * all.y + (7 * get_local_size(0)) * all.x);
 
1695
res_3_0 += subh_cache(h + (3 * get_local_size(0)) * all.y + (0 * get_local_size(0)) * all.x);
 
1696
res_3_1 += subh_cache(h + (3 * get_local_size(0)) * all.y + (1 * get_local_size(0)) * all.x);
 
1697
res_3_2 += subh_cache(h + (3 * get_local_size(0)) * all.y + (2 * get_local_size(0)) * all.x);
 
1698
res_3_3 += subh_cache(h + (3 * get_local_size(0)) * all.y + (3 * get_local_size(0)) * all.x);
 
1699
res_3_4 += subh_cache(h + (3 * get_local_size(0)) * all.y + (4 * get_local_size(0)) * all.x);
 
1700
res_3_5 += subh_cache(h + (3 * get_local_size(0)) * all.y + (5 * get_local_size(0)) * all.x);
 
1701
res_3_6 += subh_cache(h + (3 * get_local_size(0)) * all.y + (6 * get_local_size(0)) * all.x);
 
1702
res_3_7 += subh_cache(h + (3 * get_local_size(0)) * all.y + (7 * get_local_size(0)) * all.x);
 
1703
res_4_0 += subh_cache(h + (4 * get_local_size(0)) * all.y + (0 * get_local_size(0)) * all.x);
 
1704
res_4_1 += subh_cache(h + (4 * get_local_size(0)) * all.y + (1 * get_local_size(0)) * all.x);
 
1705
res_4_2 += subh_cache(h + (4 * get_local_size(0)) * all.y + (2 * get_local_size(0)) * all.x);
 
1706
res_4_3 += subh_cache(h + (4 * get_local_size(0)) * all.y + (3 * get_local_size(0)) * all.x);
 
1707
res_4_4 += subh_cache(h + (4 * get_local_size(0)) * all.y + (4 * get_local_size(0)) * all.x);
 
1708
res_4_5 += subh_cache(h + (4 * get_local_size(0)) * all.y + (5 * get_local_size(0)) * all.x);
 
1709
res_4_6 += subh_cache(h + (4 * get_local_size(0)) * all.y + (6 * get_local_size(0)) * all.x);
 
1710
res_4_7 += subh_cache(h + (4 * get_local_size(0)) * all.y + (7 * get_local_size(0)) * all.x);
 
1711
res_5_0 += subh_cache(h + (5 * get_local_size(0)) * all.y + (0 * get_local_size(0)) * all.x);
 
1712
res_5_1 += subh_cache(h + (5 * get_local_size(0)) * all.y + (1 * get_local_size(0)) * all.x);
 
1713
res_5_2 += subh_cache(h + (5 * get_local_size(0)) * all.y + (2 * get_local_size(0)) * all.x);
 
1714
res_5_3 += subh_cache(h + (5 * get_local_size(0)) * all.y + (3 * get_local_size(0)) * all.x);
 
1715
res_5_4 += subh_cache(h + (5 * get_local_size(0)) * all.y + (4 * get_local_size(0)) * all.x);
 
1716
res_5_5 += subh_cache(h + (5 * get_local_size(0)) * all.y + (5 * get_local_size(0)) * all.x);
 
1717
res_5_6 += subh_cache(h + (5 * get_local_size(0)) * all.y + (6 * get_local_size(0)) * all.x);
 
1718
res_5_7 += subh_cache(h + (5 * get_local_size(0)) * all.y + (7 * get_local_size(0)) * all.x);
 
1719
res_6_0 += subh_cache(h + (6 * get_local_size(0)) * all.y + (0 * get_local_size(0)) * all.x);
 
1720
res_6_1 += subh_cache(h + (6 * get_local_size(0)) * all.y + (1 * get_local_size(0)) * all.x);
 
1721
res_6_2 += subh_cache(h + (6 * get_local_size(0)) * all.y + (2 * get_local_size(0)) * all.x);
 
1722
res_6_3 += subh_cache(h + (6 * get_local_size(0)) * all.y + (3 * get_local_size(0)) * all.x);
 
1723
res_6_4 += subh_cache(h + (6 * get_local_size(0)) * all.y + (4 * get_local_size(0)) * all.x);
 
1724
res_6_5 += subh_cache(h + (6 * get_local_size(0)) * all.y + (5 * get_local_size(0)) * all.x);
 
1725
res_6_6 += subh_cache(h + (6 * get_local_size(0)) * all.y + (6 * get_local_size(0)) * all.x);
 
1726
res_6_7 += subh_cache(h + (6 * get_local_size(0)) * all.y + (7 * get_local_size(0)) * all.x);
 
1727
res_7_0 += subh_cache(h + (7 * get_local_size(0)) * all.y + (0 * get_local_size(0)) * all.x);
 
1728
res_7_1 += subh_cache(h + (7 * get_local_size(0)) * all.y + (1 * get_local_size(0)) * all.x);
 
1729
res_7_2 += subh_cache(h + (7 * get_local_size(0)) * all.y + (2 * get_local_size(0)) * all.x);
 
1730
res_7_3 += subh_cache(h + (7 * get_local_size(0)) * all.y + (3 * get_local_size(0)) * all.x);
 
1731
res_7_4 += subh_cache(h + (7 * get_local_size(0)) * all.y + (4 * get_local_size(0)) * all.x);
 
1732
res_7_5 += subh_cache(h + (7 * get_local_size(0)) * all.y + (5 * get_local_size(0)) * all.x);
 
1733
res_7_6 += subh_cache(h + (7 * get_local_size(0)) * all.y + (6 * get_local_size(0)) * all.x);
 
1734
res_7_7 += subh_cache(h + (7 * get_local_size(0)) * all.y + (7 * get_local_size(0)) * all.x);
 
1735
 
 
1736
        barrier(CLK_LOCAL_MEM_FENCE);
 
1737
    }
 
1738
 
 
1739
slice[(idy + get_local_size(1) * 0) * slice_width +  idx + get_local_size(0) * 0] = res_0_0;
 
1740
slice[(idy + get_local_size(1) * 0) * slice_width +  idx + get_local_size(0) * 1] = res_0_1;
 
1741
slice[(idy + get_local_size(1) * 0) * slice_width +  idx + get_local_size(0) * 2] = res_0_2;
 
1742
slice[(idy + get_local_size(1) * 0) * slice_width +  idx + get_local_size(0) * 3] = res_0_3;
 
1743
slice[(idy + get_local_size(1) * 0) * slice_width +  idx + get_local_size(0) * 4] = res_0_4;
 
1744
slice[(idy + get_local_size(1) * 0) * slice_width +  idx + get_local_size(0) * 5] = res_0_5;
 
1745
slice[(idy + get_local_size(1) * 0) * slice_width +  idx + get_local_size(0) * 6] = res_0_6;
 
1746
slice[(idy + get_local_size(1) * 0) * slice_width +  idx + get_local_size(0) * 7] = res_0_7;
 
1747
slice[(idy + get_local_size(1) * 1) * slice_width +  idx + get_local_size(0) * 0] = res_1_0;
 
1748
slice[(idy + get_local_size(1) * 1) * slice_width +  idx + get_local_size(0) * 1] = res_1_1;
 
1749
slice[(idy + get_local_size(1) * 1) * slice_width +  idx + get_local_size(0) * 2] = res_1_2;
 
1750
slice[(idy + get_local_size(1) * 1) * slice_width +  idx + get_local_size(0) * 3] = res_1_3;
 
1751
slice[(idy + get_local_size(1) * 1) * slice_width +  idx + get_local_size(0) * 4] = res_1_4;
 
1752
slice[(idy + get_local_size(1) * 1) * slice_width +  idx + get_local_size(0) * 5] = res_1_5;
 
1753
slice[(idy + get_local_size(1) * 1) * slice_width +  idx + get_local_size(0) * 6] = res_1_6;
 
1754
slice[(idy + get_local_size(1) * 1) * slice_width +  idx + get_local_size(0) * 7] = res_1_7;
 
1755
slice[(idy + get_local_size(1) * 2) * slice_width +  idx + get_local_size(0) * 0] = res_2_0;
 
1756
slice[(idy + get_local_size(1) * 2) * slice_width +  idx + get_local_size(0) * 1] = res_2_1;
 
1757
slice[(idy + get_local_size(1) * 2) * slice_width +  idx + get_local_size(0) * 2] = res_2_2;
 
1758
slice[(idy + get_local_size(1) * 2) * slice_width +  idx + get_local_size(0) * 3] = res_2_3;
 
1759
slice[(idy + get_local_size(1) * 2) * slice_width +  idx + get_local_size(0) * 4] = res_2_4;
 
1760
slice[(idy + get_local_size(1) * 2) * slice_width +  idx + get_local_size(0) * 5] = res_2_5;
 
1761
slice[(idy + get_local_size(1) * 2) * slice_width +  idx + get_local_size(0) * 6] = res_2_6;
 
1762
slice[(idy + get_local_size(1) * 2) * slice_width +  idx + get_local_size(0) * 7] = res_2_7;
 
1763
slice[(idy + get_local_size(1) * 3) * slice_width +  idx + get_local_size(0) * 0] = res_3_0;
 
1764
slice[(idy + get_local_size(1) * 3) * slice_width +  idx + get_local_size(0) * 1] = res_3_1;
 
1765
slice[(idy + get_local_size(1) * 3) * slice_width +  idx + get_local_size(0) * 2] = res_3_2;
 
1766
slice[(idy + get_local_size(1) * 3) * slice_width +  idx + get_local_size(0) * 3] = res_3_3;
 
1767
slice[(idy + get_local_size(1) * 3) * slice_width +  idx + get_local_size(0) * 4] = res_3_4;
 
1768
slice[(idy + get_local_size(1) * 3) * slice_width +  idx + get_local_size(0) * 5] = res_3_5;
 
1769
slice[(idy + get_local_size(1) * 3) * slice_width +  idx + get_local_size(0) * 6] = res_3_6;
 
1770
slice[(idy + get_local_size(1) * 3) * slice_width +  idx + get_local_size(0) * 7] = res_3_7;
 
1771
slice[(idy + get_local_size(1) * 4) * slice_width +  idx + get_local_size(0) * 0] = res_4_0;
 
1772
slice[(idy + get_local_size(1) * 4) * slice_width +  idx + get_local_size(0) * 1] = res_4_1;
 
1773
slice[(idy + get_local_size(1) * 4) * slice_width +  idx + get_local_size(0) * 2] = res_4_2;
 
1774
slice[(idy + get_local_size(1) * 4) * slice_width +  idx + get_local_size(0) * 3] = res_4_3;
 
1775
slice[(idy + get_local_size(1) * 4) * slice_width +  idx + get_local_size(0) * 4] = res_4_4;
 
1776
slice[(idy + get_local_size(1) * 4) * slice_width +  idx + get_local_size(0) * 5] = res_4_5;
 
1777
slice[(idy + get_local_size(1) * 4) * slice_width +  idx + get_local_size(0) * 6] = res_4_6;
 
1778
slice[(idy + get_local_size(1) * 4) * slice_width +  idx + get_local_size(0) * 7] = res_4_7;
 
1779
slice[(idy + get_local_size(1) * 5) * slice_width +  idx + get_local_size(0) * 0] = res_5_0;
 
1780
slice[(idy + get_local_size(1) * 5) * slice_width +  idx + get_local_size(0) * 1] = res_5_1;
 
1781
slice[(idy + get_local_size(1) * 5) * slice_width +  idx + get_local_size(0) * 2] = res_5_2;
 
1782
slice[(idy + get_local_size(1) * 5) * slice_width +  idx + get_local_size(0) * 3] = res_5_3;
 
1783
slice[(idy + get_local_size(1) * 5) * slice_width +  idx + get_local_size(0) * 4] = res_5_4;
 
1784
slice[(idy + get_local_size(1) * 5) * slice_width +  idx + get_local_size(0) * 5] = res_5_5;
 
1785
slice[(idy + get_local_size(1) * 5) * slice_width +  idx + get_local_size(0) * 6] = res_5_6;
 
1786
slice[(idy + get_local_size(1) * 5) * slice_width +  idx + get_local_size(0) * 7] = res_5_7;
 
1787
slice[(idy + get_local_size(1) * 6) * slice_width +  idx + get_local_size(0) * 0] = res_6_0;
 
1788
slice[(idy + get_local_size(1) * 6) * slice_width +  idx + get_local_size(0) * 1] = res_6_1;
 
1789
slice[(idy + get_local_size(1) * 6) * slice_width +  idx + get_local_size(0) * 2] = res_6_2;
 
1790
slice[(idy + get_local_size(1) * 6) * slice_width +  idx + get_local_size(0) * 3] = res_6_3;
 
1791
slice[(idy + get_local_size(1) * 6) * slice_width +  idx + get_local_size(0) * 4] = res_6_4;
 
1792
slice[(idy + get_local_size(1) * 6) * slice_width +  idx + get_local_size(0) * 5] = res_6_5;
 
1793
slice[(idy + get_local_size(1) * 6) * slice_width +  idx + get_local_size(0) * 6] = res_6_6;
 
1794
slice[(idy + get_local_size(1) * 6) * slice_width +  idx + get_local_size(0) * 7] = res_6_7;
 
1795
slice[(idy + get_local_size(1) * 7) * slice_width +  idx + get_local_size(0) * 0] = res_7_0;
 
1796
slice[(idy + get_local_size(1) * 7) * slice_width +  idx + get_local_size(0) * 1] = res_7_1;
 
1797
slice[(idy + get_local_size(1) * 7) * slice_width +  idx + get_local_size(0) * 2] = res_7_2;
 
1798
slice[(idy + get_local_size(1) * 7) * slice_width +  idx + get_local_size(0) * 3] = res_7_3;
 
1799
slice[(idy + get_local_size(1) * 7) * slice_width +  idx + get_local_size(0) * 4] = res_7_4;
 
1800
slice[(idy + get_local_size(1) * 7) * slice_width +  idx + get_local_size(0) * 5] = res_7_5;
 
1801
slice[(idy + get_local_size(1) * 7) * slice_width +  idx + get_local_size(0) * 6] = res_7_6;
 
1802
slice[(idy + get_local_size(1) * 7) * slice_width +  idx + get_local_size(0) * 7] = res_7_7;
 
1803
}
 
1804
 
 
1805
/*
 
1806
__kernel void hst_backproject_8ppt_vliw_linear(const int num_proj, 
 
1807
    const int num_bins, 
 
1808
    const float off_x, 
 
1809
    const float off_y, 
 
1810
    __read_only image2d_t sinogram,
 
1811
    __global float *slice,
 
1812
    __constant float4 *c_all, 
 
1813
    __local float *share
 
1814
    ) {
 
1815
    __local float2 *cache = (__local float2*)share;
 
1816
    const int tidx = get_local_id(0);
 
1817
    const int tidy = get_local_id(1);
 
1818
 
 
1819
    const int bidx = PPT * get_group_id(0) * get_local_size(0);
 
1820
    const int bidy = PPT * (get_global_id(1) - get_local_id(1));
 
1821
 
 
1822
    const float bx = bidx + off_x;
 
1823
    const float by = bidy + off_y;
 
1824
 
 
1825
    const int sidx = tidx;
 
1826
    const int sidy = tidy;
 
1827
 
 
1828
    const int idx = bidx + sidx;
 
1829
    const int idy = bidy + sidy;
 
1830
 
 
1831
    const float x = idx + off_x;
 
1832
    const float y = idy + off_y;
 
1833
 
 
1834
    const int slice_width = PPT * get_global_size(0);
 
1835
 
 
1836
    float res[PPT][PPT] = {0};
 
1837
    for (int proj = 0; proj < num_proj; proj++) {
 
1838
        float4 all = c_all[proj]; all.y = -all.y;
 
1839
        float minh = floor(all.z + bx * all.x + by * all.y + all.w);
 
1840
 
 
1841
#pragma unroll 2
 
1842
        for (int i = 0; i < 2; i++) {
 
1843
            int pos = i * get_local_size(0) * get_local_size(0) + tidy * get_local_size(0) + tidx;
 
1844
            cache[pos].x = read_imagef(sinogram, volumeSampler, (float2)(minh + pos, proj + .5f)).x;
 
1845
        }
 
1846
 
 
1847
        barrier(CLK_LOCAL_MEM_FENCE);
 
1848
 
 
1849
        for (int i = 0; i < 2; i++) {
 
1850
            int pos = i * get_local_size(0) * get_local_size(0) + tidy * get_local_size(0) + tidx;
 
1851
            cache[pos].y = cache[pos + 1].x - cache[pos].x;
 
1852
        }
 
1853
 
 
1854
        barrier(CLK_LOCAL_MEM_FENCE);
 
1855
 
 
1856
        float h = mad(x, all.x, mad(y, all.y, all.z)) - minh;
 
1857
        float2 v;
 
1858
        float subh, isubh;
 
1859
        
 
1860
#pragma unroll 8
 
1861
        for (int i = 0; i < PPT; i++) {
 
1862
#pragma unroll 8
 
1863
            for (int j = 0; j < PPT; j++) {
 
1864
                subh = h + (i * get_local_size(0)) * all.y + (j * get_local_size(0)) * all.x;
 
1865
                isubh = floor(subh);
 
1866
                v = subh_cache(isubh);
 
1867
                res[i][j] += v.x + (subh - isubh)*v.y;
 
1868
            }
 
1869
        }
 
1870
 
 
1871
        barrier(CLK_LOCAL_MEM_FENCE);
 
1872
    }
 
1873
 
 
1874
#pragma unroll 8
 
1875
    for (int i = 0; i < PPT; i++) {
 
1876
#pragma unroll 8
 
1877
        for (int j = 0; j < PPT; j++) {
 
1878
            slice[(idy + get_local_size(1) * i) * slice_width +  idx + get_local_size(0) * j] = res[i][j];
 
1879
        }
 
1880
    }
 
1881
}
 
1882
*/
 
1883
 
 
1884
/*
 
1885
__kernel void hst_backproject_8ppt_vliw_linear(const int num_proj, 
 
1886
    const int num_bins, 
 
1887
    const float off_x, 
 
1888
    const float off_y, 
 
1889
    __read_only image2d_t sinogram,
 
1890
    __global float *slice,
 
1891
    __constant float4 *c_all, 
 
1892
    __local float *share
 
1893
    ) {
 
1894
    __local float2 *cache = (__local float2*)share;
 
1895
    const int tidx = get_local_id(0);
 
1896
    const int tidy = get_local_id(1);
 
1897
 
 
1898
    const int bidx = PPT * get_group_id(0) * get_local_size(0);
 
1899
    const int bidy = PPT * (get_global_id(1) - get_local_id(1));
 
1900
 
 
1901
    const float bx = bidx + off_x;
 
1902
    const float by = bidy + off_y;
 
1903
 
 
1904
    const int sidx = tidx;
 
1905
    const int sidy = tidy;
 
1906
 
 
1907
    const int idx = bidx + sidx;
 
1908
    const int idy = bidy + sidy;
 
1909
 
 
1910
    const float x = idx + off_x;
 
1911
    const float y = idy + off_y;
 
1912
 
 
1913
    const int slice_width = PPT * get_global_size(0);
 
1914
 
 
1915
float res_0_0 = 0;
 
1916
float res_0_1 = 0;
 
1917
float res_0_2 = 0;
 
1918
float res_0_3 = 0;
 
1919
float res_0_4 = 0;
 
1920
float res_0_5 = 0;
 
1921
float res_0_6 = 0;
 
1922
float res_0_7 = 0;
 
1923
float res_1_0 = 0;
 
1924
float res_1_1 = 0;
 
1925
float res_1_2 = 0;
 
1926
float res_1_3 = 0;
 
1927
float res_1_4 = 0;
 
1928
float res_1_5 = 0;
 
1929
float res_1_6 = 0;
 
1930
float res_1_7 = 0;
 
1931
float res_2_0 = 0;
 
1932
float res_2_1 = 0;
 
1933
float res_2_2 = 0;
 
1934
float res_2_3 = 0;
 
1935
float res_2_4 = 0;
 
1936
float res_2_5 = 0;
 
1937
float res_2_6 = 0;
 
1938
float res_2_7 = 0;
 
1939
float res_3_0 = 0;
 
1940
float res_3_1 = 0;
 
1941
float res_3_2 = 0;
 
1942
float res_3_3 = 0;
 
1943
float res_3_4 = 0;
 
1944
float res_3_5 = 0;
 
1945
float res_3_6 = 0;
 
1946
float res_3_7 = 0;
 
1947
float res_4_0 = 0;
 
1948
float res_4_1 = 0;
 
1949
float res_4_2 = 0;
 
1950
float res_4_3 = 0;
 
1951
float res_4_4 = 0;
 
1952
float res_4_5 = 0;
 
1953
float res_4_6 = 0;
 
1954
float res_4_7 = 0;
 
1955
float res_5_0 = 0;
 
1956
float res_5_1 = 0;
 
1957
float res_5_2 = 0;
 
1958
float res_5_3 = 0;
 
1959
float res_5_4 = 0;
 
1960
float res_5_5 = 0;
 
1961
float res_5_6 = 0;
 
1962
float res_5_7 = 0;
 
1963
float res_6_0 = 0;
 
1964
float res_6_1 = 0;
 
1965
float res_6_2 = 0;
 
1966
float res_6_3 = 0;
 
1967
float res_6_4 = 0;
 
1968
float res_6_5 = 0;
 
1969
float res_6_6 = 0;
 
1970
float res_6_7 = 0;
 
1971
float res_7_0 = 0;
 
1972
float res_7_1 = 0;
 
1973
float res_7_2 = 0;
 
1974
float res_7_3 = 0;
 
1975
float res_7_4 = 0;
 
1976
float res_7_5 = 0;
 
1977
float res_7_6 = 0;
 
1978
float res_7_7 = 0;
 
1979
 
 
1980
 
 
1981
 
 
1982
    for (int proj = 0; proj < num_proj; proj++) {
 
1983
        float4 all = c_all[proj]; all.y = -all.y;
 
1984
        float minh = floor(all.z + bx * all.x + by * all.y + all.w);
 
1985
 
 
1986
#pragma unroll 2
 
1987
        for (int i = 0; i < 2; i++) {
 
1988
            int pos = i * get_local_size(0) * get_local_size(0) + tidy * get_local_size(0) + tidx;
 
1989
            cache[pos].x = read_imagef(sinogram, volumeSampler, (float2)(minh + pos, proj + .5f)).x;
 
1990
        }
 
1991
 
 
1992
        barrier(CLK_LOCAL_MEM_FENCE);
 
1993
 
 
1994
        for (int i = 0; i < 2; i++) {
 
1995
            int pos = i * get_local_size(0) * get_local_size(0) + tidy * get_local_size(0) + tidx;
 
1996
            cache[pos].y = cache[pos + 1].x - cache[pos].x;
 
1997
        }
 
1998
 
 
1999
        barrier(CLK_LOCAL_MEM_FENCE);
 
2000
 
 
2001
        float h = mad(x, all.x, mad(y, all.y, all.z)) - minh;
 
2002
        float2 v;
 
2003
        float subh, isubh;
 
2004
 
 
2005
subh = h + (0 * get_local_size(0)) * all.y + (0 * get_local_size(0)) * all.x; isubh = floor(subh); v = subh_cache(isubh); res_0_0 += v.x + (subh - isubh) * v.y;
 
2006
subh = h + (0 * get_local_size(0)) * all.y + (1 * get_local_size(0)) * all.x; isubh = floor(subh); v = subh_cache(isubh); res_0_1 += v.x + (subh - isubh) * v.y;
 
2007
subh = h + (0 * get_local_size(0)) * all.y + (2 * get_local_size(0)) * all.x; isubh = floor(subh); v = subh_cache(isubh); res_0_2 += v.x + (subh - isubh) * v.y;
 
2008
subh = h + (0 * get_local_size(0)) * all.y + (3 * get_local_size(0)) * all.x; isubh = floor(subh); v = subh_cache(isubh); res_0_3 += v.x + (subh - isubh) * v.y;
 
2009
subh = h + (0 * get_local_size(0)) * all.y + (4 * get_local_size(0)) * all.x; isubh = floor(subh); v = subh_cache(isubh); res_0_4 += v.x + (subh - isubh) * v.y;
 
2010
subh = h + (0 * get_local_size(0)) * all.y + (5 * get_local_size(0)) * all.x; isubh = floor(subh); v = subh_cache(isubh); res_0_5 += v.x + (subh - isubh) * v.y;
 
2011
subh = h + (0 * get_local_size(0)) * all.y + (6 * get_local_size(0)) * all.x; isubh = floor(subh); v = subh_cache(isubh); res_0_6 += v.x + (subh - isubh) * v.y;
 
2012
subh = h + (0 * get_local_size(0)) * all.y + (7 * get_local_size(0)) * all.x; isubh = floor(subh); v = subh_cache(isubh); res_0_7 += v.x + (subh - isubh) * v.y;
 
2013
subh = h + (1 * get_local_size(0)) * all.y + (0 * get_local_size(0)) * all.x; isubh = floor(subh); v = subh_cache(isubh); res_1_0 += v.x + (subh - isubh) * v.y;
 
2014
subh = h + (1 * get_local_size(0)) * all.y + (1 * get_local_size(0)) * all.x; isubh = floor(subh); v = subh_cache(isubh); res_1_1 += v.x + (subh - isubh) * v.y;
 
2015
subh = h + (1 * get_local_size(0)) * all.y + (2 * get_local_size(0)) * all.x; isubh = floor(subh); v = subh_cache(isubh); res_1_2 += v.x + (subh - isubh) * v.y;
 
2016
subh = h + (1 * get_local_size(0)) * all.y + (3 * get_local_size(0)) * all.x; isubh = floor(subh); v = subh_cache(isubh); res_1_3 += v.x + (subh - isubh) * v.y;
 
2017
subh = h + (1 * get_local_size(0)) * all.y + (4 * get_local_size(0)) * all.x; isubh = floor(subh); v = subh_cache(isubh); res_1_4 += v.x + (subh - isubh) * v.y;
 
2018
subh = h + (1 * get_local_size(0)) * all.y + (5 * get_local_size(0)) * all.x; isubh = floor(subh); v = subh_cache(isubh); res_1_5 += v.x + (subh - isubh) * v.y;
 
2019
subh = h + (1 * get_local_size(0)) * all.y + (6 * get_local_size(0)) * all.x; isubh = floor(subh); v = subh_cache(isubh); res_1_6 += v.x + (subh - isubh) * v.y;
 
2020
subh = h + (1 * get_local_size(0)) * all.y + (7 * get_local_size(0)) * all.x; isubh = floor(subh); v = subh_cache(isubh); res_1_7 += v.x + (subh - isubh) * v.y;
 
2021
subh = h + (2 * get_local_size(0)) * all.y + (0 * get_local_size(0)) * all.x; isubh = floor(subh); v = subh_cache(isubh); res_2_0 += v.x + (subh - isubh) * v.y;
 
2022
subh = h + (2 * get_local_size(0)) * all.y + (1 * get_local_size(0)) * all.x; isubh = floor(subh); v = subh_cache(isubh); res_2_1 += v.x + (subh - isubh) * v.y;
 
2023
subh = h + (2 * get_local_size(0)) * all.y + (2 * get_local_size(0)) * all.x; isubh = floor(subh); v = subh_cache(isubh); res_2_2 += v.x + (subh - isubh) * v.y;
 
2024
subh = h + (2 * get_local_size(0)) * all.y + (3 * get_local_size(0)) * all.x; isubh = floor(subh); v = subh_cache(isubh); res_2_3 += v.x + (subh - isubh) * v.y;
 
2025
subh = h + (2 * get_local_size(0)) * all.y + (4 * get_local_size(0)) * all.x; isubh = floor(subh); v = subh_cache(isubh); res_2_4 += v.x + (subh - isubh) * v.y;
 
2026
subh = h + (2 * get_local_size(0)) * all.y + (5 * get_local_size(0)) * all.x; isubh = floor(subh); v = subh_cache(isubh); res_2_5 += v.x + (subh - isubh) * v.y;
 
2027
subh = h + (2 * get_local_size(0)) * all.y + (6 * get_local_size(0)) * all.x; isubh = floor(subh); v = subh_cache(isubh); res_2_6 += v.x + (subh - isubh) * v.y;
 
2028
subh = h + (2 * get_local_size(0)) * all.y + (7 * get_local_size(0)) * all.x; isubh = floor(subh); v = subh_cache(isubh); res_2_7 += v.x + (subh - isubh) * v.y;
 
2029
subh = h + (3 * get_local_size(0)) * all.y + (0 * get_local_size(0)) * all.x; isubh = floor(subh); v = subh_cache(isubh); res_3_0 += v.x + (subh - isubh) * v.y;
 
2030
subh = h + (3 * get_local_size(0)) * all.y + (1 * get_local_size(0)) * all.x; isubh = floor(subh); v = subh_cache(isubh); res_3_1 += v.x + (subh - isubh) * v.y;
 
2031
subh = h + (3 * get_local_size(0)) * all.y + (2 * get_local_size(0)) * all.x; isubh = floor(subh); v = subh_cache(isubh); res_3_2 += v.x + (subh - isubh) * v.y;
 
2032
subh = h + (3 * get_local_size(0)) * all.y + (3 * get_local_size(0)) * all.x; isubh = floor(subh); v = subh_cache(isubh); res_3_3 += v.x + (subh - isubh) * v.y;
 
2033
subh = h + (3 * get_local_size(0)) * all.y + (4 * get_local_size(0)) * all.x; isubh = floor(subh); v = subh_cache(isubh); res_3_4 += v.x + (subh - isubh) * v.y;
 
2034
subh = h + (3 * get_local_size(0)) * all.y + (5 * get_local_size(0)) * all.x; isubh = floor(subh); v = subh_cache(isubh); res_3_5 += v.x + (subh - isubh) * v.y;
 
2035
subh = h + (3 * get_local_size(0)) * all.y + (6 * get_local_size(0)) * all.x; isubh = floor(subh); v = subh_cache(isubh); res_3_6 += v.x + (subh - isubh) * v.y;
 
2036
subh = h + (3 * get_local_size(0)) * all.y + (7 * get_local_size(0)) * all.x; isubh = floor(subh); v = subh_cache(isubh); res_3_7 += v.x + (subh - isubh) * v.y;
 
2037
subh = h + (4 * get_local_size(0)) * all.y + (0 * get_local_size(0)) * all.x; isubh = floor(subh); v = subh_cache(isubh); res_4_0 += v.x + (subh - isubh) * v.y;
 
2038
subh = h + (4 * get_local_size(0)) * all.y + (1 * get_local_size(0)) * all.x; isubh = floor(subh); v = subh_cache(isubh); res_4_1 += v.x + (subh - isubh) * v.y;
 
2039
subh = h + (4 * get_local_size(0)) * all.y + (2 * get_local_size(0)) * all.x; isubh = floor(subh); v = subh_cache(isubh); res_4_2 += v.x + (subh - isubh) * v.y;
 
2040
subh = h + (4 * get_local_size(0)) * all.y + (3 * get_local_size(0)) * all.x; isubh = floor(subh); v = subh_cache(isubh); res_4_3 += v.x + (subh - isubh) * v.y;
 
2041
subh = h + (4 * get_local_size(0)) * all.y + (4 * get_local_size(0)) * all.x; isubh = floor(subh); v = subh_cache(isubh); res_4_4 += v.x + (subh - isubh) * v.y;
 
2042
subh = h + (4 * get_local_size(0)) * all.y + (5 * get_local_size(0)) * all.x; isubh = floor(subh); v = subh_cache(isubh); res_4_5 += v.x + (subh - isubh) * v.y;
 
2043
subh = h + (4 * get_local_size(0)) * all.y + (6 * get_local_size(0)) * all.x; isubh = floor(subh); v = subh_cache(isubh); res_4_6 += v.x + (subh - isubh) * v.y;
 
2044
subh = h + (4 * get_local_size(0)) * all.y + (7 * get_local_size(0)) * all.x; isubh = floor(subh); v = subh_cache(isubh); res_4_7 += v.x + (subh - isubh) * v.y;
 
2045
subh = h + (5 * get_local_size(0)) * all.y + (0 * get_local_size(0)) * all.x; isubh = floor(subh); v = subh_cache(isubh); res_5_0 += v.x + (subh - isubh) * v.y;
 
2046
subh = h + (5 * get_local_size(0)) * all.y + (1 * get_local_size(0)) * all.x; isubh = floor(subh); v = subh_cache(isubh); res_5_1 += v.x + (subh - isubh) * v.y;
 
2047
subh = h + (5 * get_local_size(0)) * all.y + (2 * get_local_size(0)) * all.x; isubh = floor(subh); v = subh_cache(isubh); res_5_2 += v.x + (subh - isubh) * v.y;
 
2048
subh = h + (5 * get_local_size(0)) * all.y + (3 * get_local_size(0)) * all.x; isubh = floor(subh); v = subh_cache(isubh); res_5_3 += v.x + (subh - isubh) * v.y;
 
2049
subh = h + (5 * get_local_size(0)) * all.y + (4 * get_local_size(0)) * all.x; isubh = floor(subh); v = subh_cache(isubh); res_5_4 += v.x + (subh - isubh) * v.y;
 
2050
subh = h + (5 * get_local_size(0)) * all.y + (5 * get_local_size(0)) * all.x; isubh = floor(subh); v = subh_cache(isubh); res_5_5 += v.x + (subh - isubh) * v.y;
 
2051
subh = h + (5 * get_local_size(0)) * all.y + (6 * get_local_size(0)) * all.x; isubh = floor(subh); v = subh_cache(isubh); res_5_6 += v.x + (subh - isubh) * v.y;
 
2052
subh = h + (5 * get_local_size(0)) * all.y + (7 * get_local_size(0)) * all.x; isubh = floor(subh); v = subh_cache(isubh); res_5_7 += v.x + (subh - isubh) * v.y;
 
2053
subh = h + (6 * get_local_size(0)) * all.y + (0 * get_local_size(0)) * all.x; isubh = floor(subh); v = subh_cache(isubh); res_6_0 += v.x + (subh - isubh) * v.y;
 
2054
subh = h + (6 * get_local_size(0)) * all.y + (1 * get_local_size(0)) * all.x; isubh = floor(subh); v = subh_cache(isubh); res_6_1 += v.x + (subh - isubh) * v.y;
 
2055
subh = h + (6 * get_local_size(0)) * all.y + (2 * get_local_size(0)) * all.x; isubh = floor(subh); v = subh_cache(isubh); res_6_2 += v.x + (subh - isubh) * v.y;
 
2056
subh = h + (6 * get_local_size(0)) * all.y + (3 * get_local_size(0)) * all.x; isubh = floor(subh); v = subh_cache(isubh); res_6_3 += v.x + (subh - isubh) * v.y;
 
2057
subh = h + (6 * get_local_size(0)) * all.y + (4 * get_local_size(0)) * all.x; isubh = floor(subh); v = subh_cache(isubh); res_6_4 += v.x + (subh - isubh) * v.y;
 
2058
subh = h + (6 * get_local_size(0)) * all.y + (5 * get_local_size(0)) * all.x; isubh = floor(subh); v = subh_cache(isubh); res_6_5 += v.x + (subh - isubh) * v.y;
 
2059
subh = h + (6 * get_local_size(0)) * all.y + (6 * get_local_size(0)) * all.x; isubh = floor(subh); v = subh_cache(isubh); res_6_6 += v.x + (subh - isubh) * v.y;
 
2060
subh = h + (6 * get_local_size(0)) * all.y + (7 * get_local_size(0)) * all.x; isubh = floor(subh); v = subh_cache(isubh); res_6_7 += v.x + (subh - isubh) * v.y;
 
2061
subh = h + (7 * get_local_size(0)) * all.y + (0 * get_local_size(0)) * all.x; isubh = floor(subh); v = subh_cache(isubh); res_7_0 += v.x + (subh - isubh) * v.y;
 
2062
subh = h + (7 * get_local_size(0)) * all.y + (1 * get_local_size(0)) * all.x; isubh = floor(subh); v = subh_cache(isubh); res_7_1 += v.x + (subh - isubh) * v.y;
 
2063
subh = h + (7 * get_local_size(0)) * all.y + (2 * get_local_size(0)) * all.x; isubh = floor(subh); v = subh_cache(isubh); res_7_2 += v.x + (subh - isubh) * v.y;
 
2064
subh = h + (7 * get_local_size(0)) * all.y + (3 * get_local_size(0)) * all.x; isubh = floor(subh); v = subh_cache(isubh); res_7_3 += v.x + (subh - isubh) * v.y;
 
2065
subh = h + (7 * get_local_size(0)) * all.y + (4 * get_local_size(0)) * all.x; isubh = floor(subh); v = subh_cache(isubh); res_7_4 += v.x + (subh - isubh) * v.y;
 
2066
subh = h + (7 * get_local_size(0)) * all.y + (5 * get_local_size(0)) * all.x; isubh = floor(subh); v = subh_cache(isubh); res_7_5 += v.x + (subh - isubh) * v.y;
 
2067
subh = h + (7 * get_local_size(0)) * all.y + (6 * get_local_size(0)) * all.x; isubh = floor(subh); v = subh_cache(isubh); res_7_6 += v.x + (subh - isubh) * v.y;
 
2068
subh = h + (7 * get_local_size(0)) * all.y + (7 * get_local_size(0)) * all.x; isubh = floor(subh); v = subh_cache(isubh); res_7_7 += v.x + (subh - isubh) * v.y;
 
2069
 
 
2070
        barrier(CLK_LOCAL_MEM_FENCE);
 
2071
    }
 
2072
 
 
2073
slice[(idy + get_local_size(1) * 0) * slice_width +  idx + get_local_size(0) * 0] = res_0_0;
 
2074
slice[(idy + get_local_size(1) * 0) * slice_width +  idx + get_local_size(0) * 1] = res_0_1;
 
2075
slice[(idy + get_local_size(1) * 0) * slice_width +  idx + get_local_size(0) * 2] = res_0_2;
 
2076
slice[(idy + get_local_size(1) * 0) * slice_width +  idx + get_local_size(0) * 3] = res_0_3;
 
2077
slice[(idy + get_local_size(1) * 0) * slice_width +  idx + get_local_size(0) * 4] = res_0_4;
 
2078
slice[(idy + get_local_size(1) * 0) * slice_width +  idx + get_local_size(0) * 5] = res_0_5;
 
2079
slice[(idy + get_local_size(1) * 0) * slice_width +  idx + get_local_size(0) * 6] = res_0_6;
 
2080
slice[(idy + get_local_size(1) * 0) * slice_width +  idx + get_local_size(0) * 7] = res_0_7;
 
2081
slice[(idy + get_local_size(1) * 1) * slice_width +  idx + get_local_size(0) * 0] = res_1_0;
 
2082
slice[(idy + get_local_size(1) * 1) * slice_width +  idx + get_local_size(0) * 1] = res_1_1;
 
2083
slice[(idy + get_local_size(1) * 1) * slice_width +  idx + get_local_size(0) * 2] = res_1_2;
 
2084
slice[(idy + get_local_size(1) * 1) * slice_width +  idx + get_local_size(0) * 3] = res_1_3;
 
2085
slice[(idy + get_local_size(1) * 1) * slice_width +  idx + get_local_size(0) * 4] = res_1_4;
 
2086
slice[(idy + get_local_size(1) * 1) * slice_width +  idx + get_local_size(0) * 5] = res_1_5;
 
2087
slice[(idy + get_local_size(1) * 1) * slice_width +  idx + get_local_size(0) * 6] = res_1_6;
 
2088
slice[(idy + get_local_size(1) * 1) * slice_width +  idx + get_local_size(0) * 7] = res_1_7;
 
2089
slice[(idy + get_local_size(1) * 2) * slice_width +  idx + get_local_size(0) * 0] = res_2_0;
 
2090
slice[(idy + get_local_size(1) * 2) * slice_width +  idx + get_local_size(0) * 1] = res_2_1;
 
2091
slice[(idy + get_local_size(1) * 2) * slice_width +  idx + get_local_size(0) * 2] = res_2_2;
 
2092
slice[(idy + get_local_size(1) * 2) * slice_width +  idx + get_local_size(0) * 3] = res_2_3;
 
2093
slice[(idy + get_local_size(1) * 2) * slice_width +  idx + get_local_size(0) * 4] = res_2_4;
 
2094
slice[(idy + get_local_size(1) * 2) * slice_width +  idx + get_local_size(0) * 5] = res_2_5;
 
2095
slice[(idy + get_local_size(1) * 2) * slice_width +  idx + get_local_size(0) * 6] = res_2_6;
 
2096
slice[(idy + get_local_size(1) * 2) * slice_width +  idx + get_local_size(0) * 7] = res_2_7;
 
2097
slice[(idy + get_local_size(1) * 3) * slice_width +  idx + get_local_size(0) * 0] = res_3_0;
 
2098
slice[(idy + get_local_size(1) * 3) * slice_width +  idx + get_local_size(0) * 1] = res_3_1;
 
2099
slice[(idy + get_local_size(1) * 3) * slice_width +  idx + get_local_size(0) * 2] = res_3_2;
 
2100
slice[(idy + get_local_size(1) * 3) * slice_width +  idx + get_local_size(0) * 3] = res_3_3;
 
2101
slice[(idy + get_local_size(1) * 3) * slice_width +  idx + get_local_size(0) * 4] = res_3_4;
 
2102
slice[(idy + get_local_size(1) * 3) * slice_width +  idx + get_local_size(0) * 5] = res_3_5;
 
2103
slice[(idy + get_local_size(1) * 3) * slice_width +  idx + get_local_size(0) * 6] = res_3_6;
 
2104
slice[(idy + get_local_size(1) * 3) * slice_width +  idx + get_local_size(0) * 7] = res_3_7;
 
2105
slice[(idy + get_local_size(1) * 4) * slice_width +  idx + get_local_size(0) * 0] = res_4_0;
 
2106
slice[(idy + get_local_size(1) * 4) * slice_width +  idx + get_local_size(0) * 1] = res_4_1;
 
2107
slice[(idy + get_local_size(1) * 4) * slice_width +  idx + get_local_size(0) * 2] = res_4_2;
 
2108
slice[(idy + get_local_size(1) * 4) * slice_width +  idx + get_local_size(0) * 3] = res_4_3;
 
2109
slice[(idy + get_local_size(1) * 4) * slice_width +  idx + get_local_size(0) * 4] = res_4_4;
 
2110
slice[(idy + get_local_size(1) * 4) * slice_width +  idx + get_local_size(0) * 5] = res_4_5;
 
2111
slice[(idy + get_local_size(1) * 4) * slice_width +  idx + get_local_size(0) * 6] = res_4_6;
 
2112
slice[(idy + get_local_size(1) * 4) * slice_width +  idx + get_local_size(0) * 7] = res_4_7;
 
2113
slice[(idy + get_local_size(1) * 5) * slice_width +  idx + get_local_size(0) * 0] = res_5_0;
 
2114
slice[(idy + get_local_size(1) * 5) * slice_width +  idx + get_local_size(0) * 1] = res_5_1;
 
2115
slice[(idy + get_local_size(1) * 5) * slice_width +  idx + get_local_size(0) * 2] = res_5_2;
 
2116
slice[(idy + get_local_size(1) * 5) * slice_width +  idx + get_local_size(0) * 3] = res_5_3;
 
2117
slice[(idy + get_local_size(1) * 5) * slice_width +  idx + get_local_size(0) * 4] = res_5_4;
 
2118
slice[(idy + get_local_size(1) * 5) * slice_width +  idx + get_local_size(0) * 5] = res_5_5;
 
2119
slice[(idy + get_local_size(1) * 5) * slice_width +  idx + get_local_size(0) * 6] = res_5_6;
 
2120
slice[(idy + get_local_size(1) * 5) * slice_width +  idx + get_local_size(0) * 7] = res_5_7;
 
2121
slice[(idy + get_local_size(1) * 6) * slice_width +  idx + get_local_size(0) * 0] = res_6_0;
 
2122
slice[(idy + get_local_size(1) * 6) * slice_width +  idx + get_local_size(0) * 1] = res_6_1;
 
2123
slice[(idy + get_local_size(1) * 6) * slice_width +  idx + get_local_size(0) * 2] = res_6_2;
 
2124
slice[(idy + get_local_size(1) * 6) * slice_width +  idx + get_local_size(0) * 3] = res_6_3;
 
2125
slice[(idy + get_local_size(1) * 6) * slice_width +  idx + get_local_size(0) * 4] = res_6_4;
 
2126
slice[(idy + get_local_size(1) * 6) * slice_width +  idx + get_local_size(0) * 5] = res_6_5;
 
2127
slice[(idy + get_local_size(1) * 6) * slice_width +  idx + get_local_size(0) * 6] = res_6_6;
 
2128
slice[(idy + get_local_size(1) * 6) * slice_width +  idx + get_local_size(0) * 7] = res_6_7;
 
2129
slice[(idy + get_local_size(1) * 7) * slice_width +  idx + get_local_size(0) * 0] = res_7_0;
 
2130
slice[(idy + get_local_size(1) * 7) * slice_width +  idx + get_local_size(0) * 1] = res_7_1;
 
2131
slice[(idy + get_local_size(1) * 7) * slice_width +  idx + get_local_size(0) * 2] = res_7_2;
 
2132
slice[(idy + get_local_size(1) * 7) * slice_width +  idx + get_local_size(0) * 3] = res_7_3;
 
2133
slice[(idy + get_local_size(1) * 7) * slice_width +  idx + get_local_size(0) * 4] = res_7_4;
 
2134
slice[(idy + get_local_size(1) * 7) * slice_width +  idx + get_local_size(0) * 5] = res_7_5;
 
2135
slice[(idy + get_local_size(1) * 7) * slice_width +  idx + get_local_size(0) * 6] = res_7_6;
 
2136
slice[(idy + get_local_size(1) * 7) * slice_width +  idx + get_local_size(0) * 7] = res_7_7;
 
2137
}
 
2138
*/
 
2139
 
 
2140
__kernel void hst_backproject_6ppt_vliw_tex(const int num_proj, 
 
2141
    const int num_bins, 
 
2142
    const float off_x, 
 
2143
    const float off_y, 
 
2144
    __read_only image2d_t sinogram,
 
2145
    __global float *slice,
 
2146
    __constant float4 *c_all/*, 
 
2147
    __local float *shared*/
 
2148
    ) {
 
2149
 
 
2150
    const int tidx = get_local_id(0);
 
2151
    const int tidy = get_local_id(1);
 
2152
 
 
2153
    const int sidx = tidx;
 
2154
    const int sidy = tidy;
 
2155
 
 
2156
    const int idx = PPT * get_group_id(0) * get_local_size(0) + sidx;
 
2157
    const int idy = PPT * (get_global_id(1) - get_local_id(1)) + sidy;
 
2158
 
 
2159
    const float x = idx + off_x;
 
2160
    const float y = idy + off_y;
 
2161
 
 
2162
    const int slice_width = PPT * get_global_size(0);
 
2163
 
 
2164
float res_0_0 = 0;
 
2165
float res_0_1 = 0;
 
2166
float res_0_2 = 0;
 
2167
float res_0_3 = 0;
 
2168
float res_0_4 = 0;
 
2169
float res_0_5 = 0;
 
2170
float res_1_0 = 0;
 
2171
float res_1_1 = 0;
 
2172
float res_1_2 = 0;
 
2173
float res_1_3 = 0;
 
2174
float res_1_4 = 0;
 
2175
float res_1_5 = 0;
 
2176
float res_2_0 = 0;
 
2177
float res_2_1 = 0;
 
2178
float res_2_2 = 0;
 
2179
float res_2_3 = 0;
 
2180
float res_2_4 = 0;
 
2181
float res_2_5 = 0;
 
2182
float res_3_0 = 0;
 
2183
float res_3_1 = 0;
 
2184
float res_3_2 = 0;
 
2185
float res_3_3 = 0;
 
2186
float res_3_4 = 0;
 
2187
float res_3_5 = 0;
 
2188
float res_4_0 = 0;
 
2189
float res_4_1 = 0;
 
2190
float res_4_2 = 0;
 
2191
float res_4_3 = 0;
 
2192
float res_4_4 = 0;
 
2193
float res_4_5 = 0;
 
2194
float res_5_0 = 0;
 
2195
float res_5_1 = 0;
 
2196
float res_5_2 = 0;
 
2197
float res_5_3 = 0;
 
2198
float res_5_4 = 0;
 
2199
float res_5_5 = 0;
 
2200
 
 
2201
    for (int proj = 0; proj < num_proj; proj++) {
 
2202
        float4 all = c_all[proj];
 
2203
        all.y = - all.y;
 
2204
        float subh = mad(x, all.x, mad(y, all.y, all.z));
 
2205
 
 
2206
res_0_0 += read_imagef(sinogram, volumeSampler, (float2)(subh + 0 * BLOCK_SIZE * all.y + 0 * BLOCK_SIZE * all.x, proj + .5f)).x;
 
2207
res_0_1 += read_imagef(sinogram, volumeSampler, (float2)(subh + 0 * BLOCK_SIZE * all.y + 1 * BLOCK_SIZE * all.x, proj + .5f)).x;
 
2208
res_0_2 += read_imagef(sinogram, volumeSampler, (float2)(subh + 0 * BLOCK_SIZE * all.y + 2 * BLOCK_SIZE * all.x, proj + .5f)).x;
 
2209
res_0_3 += read_imagef(sinogram, volumeSampler, (float2)(subh + 0 * BLOCK_SIZE * all.y + 3 * BLOCK_SIZE * all.x, proj + .5f)).x;
 
2210
res_0_4 += read_imagef(sinogram, volumeSampler, (float2)(subh + 0 * BLOCK_SIZE * all.y + 4 * BLOCK_SIZE * all.x, proj + .5f)).x;
 
2211
res_0_5 += read_imagef(sinogram, volumeSampler, (float2)(subh + 0 * BLOCK_SIZE * all.y + 5 * BLOCK_SIZE * all.x, proj + .5f)).x;
 
2212
res_1_0 += read_imagef(sinogram, volumeSampler, (float2)(subh + 1 * BLOCK_SIZE * all.y + 0 * BLOCK_SIZE * all.x, proj + .5f)).x;
 
2213
res_1_1 += read_imagef(sinogram, volumeSampler, (float2)(subh + 1 * BLOCK_SIZE * all.y + 1 * BLOCK_SIZE * all.x, proj + .5f)).x;
 
2214
res_1_2 += read_imagef(sinogram, volumeSampler, (float2)(subh + 1 * BLOCK_SIZE * all.y + 2 * BLOCK_SIZE * all.x, proj + .5f)).x;
 
2215
res_1_3 += read_imagef(sinogram, volumeSampler, (float2)(subh + 1 * BLOCK_SIZE * all.y + 3 * BLOCK_SIZE * all.x, proj + .5f)).x;
 
2216
res_1_4 += read_imagef(sinogram, volumeSampler, (float2)(subh + 1 * BLOCK_SIZE * all.y + 4 * BLOCK_SIZE * all.x, proj + .5f)).x;
 
2217
res_1_5 += read_imagef(sinogram, volumeSampler, (float2)(subh + 1 * BLOCK_SIZE * all.y + 5 * BLOCK_SIZE * all.x, proj + .5f)).x;
 
2218
res_2_0 += read_imagef(sinogram, volumeSampler, (float2)(subh + 2 * BLOCK_SIZE * all.y + 0 * BLOCK_SIZE * all.x, proj + .5f)).x;
 
2219
res_2_1 += read_imagef(sinogram, volumeSampler, (float2)(subh + 2 * BLOCK_SIZE * all.y + 1 * BLOCK_SIZE * all.x, proj + .5f)).x;
 
2220
res_2_2 += read_imagef(sinogram, volumeSampler, (float2)(subh + 2 * BLOCK_SIZE * all.y + 2 * BLOCK_SIZE * all.x, proj + .5f)).x;
 
2221
res_2_3 += read_imagef(sinogram, volumeSampler, (float2)(subh + 2 * BLOCK_SIZE * all.y + 3 * BLOCK_SIZE * all.x, proj + .5f)).x;
 
2222
res_2_4 += read_imagef(sinogram, volumeSampler, (float2)(subh + 2 * BLOCK_SIZE * all.y + 4 * BLOCK_SIZE * all.x, proj + .5f)).x;
 
2223
res_2_5 += read_imagef(sinogram, volumeSampler, (float2)(subh + 2 * BLOCK_SIZE * all.y + 5 * BLOCK_SIZE * all.x, proj + .5f)).x;
 
2224
res_3_0 += read_imagef(sinogram, volumeSampler, (float2)(subh + 3 * BLOCK_SIZE * all.y + 0 * BLOCK_SIZE * all.x, proj + .5f)).x;
 
2225
res_3_1 += read_imagef(sinogram, volumeSampler, (float2)(subh + 3 * BLOCK_SIZE * all.y + 1 * BLOCK_SIZE * all.x, proj + .5f)).x;
 
2226
res_3_2 += read_imagef(sinogram, volumeSampler, (float2)(subh + 3 * BLOCK_SIZE * all.y + 2 * BLOCK_SIZE * all.x, proj + .5f)).x;
 
2227
res_3_3 += read_imagef(sinogram, volumeSampler, (float2)(subh + 3 * BLOCK_SIZE * all.y + 3 * BLOCK_SIZE * all.x, proj + .5f)).x;
 
2228
res_3_4 += read_imagef(sinogram, volumeSampler, (float2)(subh + 3 * BLOCK_SIZE * all.y + 4 * BLOCK_SIZE * all.x, proj + .5f)).x;
 
2229
res_3_5 += read_imagef(sinogram, volumeSampler, (float2)(subh + 3 * BLOCK_SIZE * all.y + 5 * BLOCK_SIZE * all.x, proj + .5f)).x;
 
2230
res_4_0 += read_imagef(sinogram, volumeSampler, (float2)(subh + 4 * BLOCK_SIZE * all.y + 0 * BLOCK_SIZE * all.x, proj + .5f)).x;
 
2231
res_4_1 += read_imagef(sinogram, volumeSampler, (float2)(subh + 4 * BLOCK_SIZE * all.y + 1 * BLOCK_SIZE * all.x, proj + .5f)).x;
 
2232
res_4_2 += read_imagef(sinogram, volumeSampler, (float2)(subh + 4 * BLOCK_SIZE * all.y + 2 * BLOCK_SIZE * all.x, proj + .5f)).x;
 
2233
res_4_3 += read_imagef(sinogram, volumeSampler, (float2)(subh + 4 * BLOCK_SIZE * all.y + 3 * BLOCK_SIZE * all.x, proj + .5f)).x;
 
2234
res_4_4 += read_imagef(sinogram, volumeSampler, (float2)(subh + 4 * BLOCK_SIZE * all.y + 4 * BLOCK_SIZE * all.x, proj + .5f)).x;
 
2235
res_4_5 += read_imagef(sinogram, volumeSampler, (float2)(subh + 4 * BLOCK_SIZE * all.y + 5 * BLOCK_SIZE * all.x, proj + .5f)).x;
 
2236
res_5_0 += read_imagef(sinogram, volumeSampler, (float2)(subh + 5 * BLOCK_SIZE * all.y + 0 * BLOCK_SIZE * all.x, proj + .5f)).x;
 
2237
res_5_1 += read_imagef(sinogram, volumeSampler, (float2)(subh + 5 * BLOCK_SIZE * all.y + 1 * BLOCK_SIZE * all.x, proj + .5f)).x;
 
2238
res_5_2 += read_imagef(sinogram, volumeSampler, (float2)(subh + 5 * BLOCK_SIZE * all.y + 2 * BLOCK_SIZE * all.x, proj + .5f)).x;
 
2239
res_5_3 += read_imagef(sinogram, volumeSampler, (float2)(subh + 5 * BLOCK_SIZE * all.y + 3 * BLOCK_SIZE * all.x, proj + .5f)).x;
 
2240
res_5_4 += read_imagef(sinogram, volumeSampler, (float2)(subh + 5 * BLOCK_SIZE * all.y + 4 * BLOCK_SIZE * all.x, proj + .5f)).x;
 
2241
res_5_5 += read_imagef(sinogram, volumeSampler, (float2)(subh + 5 * BLOCK_SIZE * all.y + 5 * BLOCK_SIZE * all.x, proj + .5f)).x;
 
2242
 
 
2243
    }
 
2244
 
 
2245
 
 
2246
slice[(idy + BLOCK_SIZE * 0) * slice_width + idx + BLOCK_SIZE * 0] = res_0_0;
 
2247
slice[(idy + BLOCK_SIZE * 0) * slice_width + idx + BLOCK_SIZE * 1] = res_0_1;
 
2248
slice[(idy + BLOCK_SIZE * 0) * slice_width + idx + BLOCK_SIZE * 2] = res_0_2;
 
2249
slice[(idy + BLOCK_SIZE * 0) * slice_width + idx + BLOCK_SIZE * 3] = res_0_3;
 
2250
slice[(idy + BLOCK_SIZE * 0) * slice_width + idx + BLOCK_SIZE * 4] = res_0_4;
 
2251
slice[(idy + BLOCK_SIZE * 0) * slice_width + idx + BLOCK_SIZE * 5] = res_0_5;
 
2252
slice[(idy + BLOCK_SIZE * 1) * slice_width + idx + BLOCK_SIZE * 0] = res_1_0;
 
2253
slice[(idy + BLOCK_SIZE * 1) * slice_width + idx + BLOCK_SIZE * 1] = res_1_1;
 
2254
slice[(idy + BLOCK_SIZE * 1) * slice_width + idx + BLOCK_SIZE * 2] = res_1_2;
 
2255
slice[(idy + BLOCK_SIZE * 1) * slice_width + idx + BLOCK_SIZE * 3] = res_1_3;
 
2256
slice[(idy + BLOCK_SIZE * 1) * slice_width + idx + BLOCK_SIZE * 4] = res_1_4;
 
2257
slice[(idy + BLOCK_SIZE * 1) * slice_width + idx + BLOCK_SIZE * 5] = res_1_5;
 
2258
slice[(idy + BLOCK_SIZE * 2) * slice_width + idx + BLOCK_SIZE * 0] = res_2_0;
 
2259
slice[(idy + BLOCK_SIZE * 2) * slice_width + idx + BLOCK_SIZE * 1] = res_2_1;
 
2260
slice[(idy + BLOCK_SIZE * 2) * slice_width + idx + BLOCK_SIZE * 2] = res_2_2;
 
2261
slice[(idy + BLOCK_SIZE * 2) * slice_width + idx + BLOCK_SIZE * 3] = res_2_3;
 
2262
slice[(idy + BLOCK_SIZE * 2) * slice_width + idx + BLOCK_SIZE * 4] = res_2_4;
 
2263
slice[(idy + BLOCK_SIZE * 2) * slice_width + idx + BLOCK_SIZE * 5] = res_2_5;
 
2264
slice[(idy + BLOCK_SIZE * 3) * slice_width + idx + BLOCK_SIZE * 0] = res_3_0;
 
2265
slice[(idy + BLOCK_SIZE * 3) * slice_width + idx + BLOCK_SIZE * 1] = res_3_1;
 
2266
slice[(idy + BLOCK_SIZE * 3) * slice_width + idx + BLOCK_SIZE * 2] = res_3_2;
 
2267
slice[(idy + BLOCK_SIZE * 3) * slice_width + idx + BLOCK_SIZE * 3] = res_3_3;
 
2268
slice[(idy + BLOCK_SIZE * 3) * slice_width + idx + BLOCK_SIZE * 4] = res_3_4;
 
2269
slice[(idy + BLOCK_SIZE * 3) * slice_width + idx + BLOCK_SIZE * 5] = res_3_5;
 
2270
slice[(idy + BLOCK_SIZE * 4) * slice_width + idx + BLOCK_SIZE * 0] = res_4_0;
 
2271
slice[(idy + BLOCK_SIZE * 4) * slice_width + idx + BLOCK_SIZE * 1] = res_4_1;
 
2272
slice[(idy + BLOCK_SIZE * 4) * slice_width + idx + BLOCK_SIZE * 2] = res_4_2;
 
2273
slice[(idy + BLOCK_SIZE * 4) * slice_width + idx + BLOCK_SIZE * 3] = res_4_3;
 
2274
slice[(idy + BLOCK_SIZE * 4) * slice_width + idx + BLOCK_SIZE * 4] = res_4_4;
 
2275
slice[(idy + BLOCK_SIZE * 4) * slice_width + idx + BLOCK_SIZE * 5] = res_4_5;
 
2276
slice[(idy + BLOCK_SIZE * 5) * slice_width + idx + BLOCK_SIZE * 0] = res_5_0;
 
2277
slice[(idy + BLOCK_SIZE * 5) * slice_width + idx + BLOCK_SIZE * 1] = res_5_1;
 
2278
slice[(idy + BLOCK_SIZE * 5) * slice_width + idx + BLOCK_SIZE * 2] = res_5_2;
 
2279
slice[(idy + BLOCK_SIZE * 5) * slice_width + idx + BLOCK_SIZE * 3] = res_5_3;
 
2280
slice[(idy + BLOCK_SIZE * 5) * slice_width + idx + BLOCK_SIZE * 4] = res_5_4;
 
2281
slice[(idy + BLOCK_SIZE * 5) * slice_width + idx + BLOCK_SIZE * 5] = res_5_5;
 
2282
}