/ani/mrses

To get this branch, use:
bzr branch http://darksoft.org/webbzr/ani/mrses

« back to all changes in this revision

Viewing changes to cell/mrses_spe.c

  • Committer: Suren A. Chilingaryan
  • Date: 2010-04-30 15:00:46 UTC
  • Revision ID: csa@dside.dyndns.org-20100430150046-1x5cwqqelzx420vf
Fix SPE crashes on big (above 4096) and non-power-of-2 number of properties

Show diffs side-by-side

added added

removed removed

Lines of Context:
308
308
    short int width;
309
309
    short int walloc, walloc2, dalloc, ralloc;
310
310
    short int index_segment_size; 
311
 
    int pos = 0, size;
 
311
    int i, pos = 0, size;
312
312
    int extra_rows = 0;
313
313
 
314
314
    MRSESTemporaryData data;
359
359
    allocation = (unsigned char*)memalign(HW_ALIGN, size);
360
360
    if (!allocation) return NULL;
361
361
 
362
 
    memset(allocation, 0, properties * sizeof(uint32_t));
 
362
//    memset(allocation, 0, properties * sizeof(uint32_t));
363
363
    
364
364
    data = (MRSESTemporaryData)(allocation + pos);
365
365
    pos += calc_alloc(sizeof(MRSESTemporaryDataS), HW_ALIGN);
399
399
 
400
400
    data->Mfull = (MRSESDataType*)(allocation + pos);
401
401
 
402
 
    spu_mfcdma32((void *)(data->Mfull), (unsigned int)(mrses->mean), calc_alloc(properties * sizeof(MRSESDataType), HW_ALIGN), rdch, MFC_GET_CMD);
 
402
    size = calc_alloc(properties * sizeof(MRSESDataType), HW_ALIGN);
 
403
    for (i = 0; i < size; i += SPE_MAX_TRANSFER_SIZE) {
 
404
        spu_mfcdma32((void*)(((char *)(data->Mfull)) + i), (unsigned int)(((char*)mrses->mean) + i), min(size - i, SPE_MAX_TRANSFER_SIZE), rdch, MFC_GET_CMD);
 
405
    }
403
406
 
404
407
    local_data = (void*)allocation;
405
408
 
434
437
    MRSESDistance dist = mrses->dist;
435
438
 
436
439
    MRSESIntType properties = mrses->properties;
 
440
    MRSESIntType palloc = mrses->palloc;
437
441
    int i, iterations = mrses->iterations;
438
442
 
439
443
    short int iterate_size = mrses->iterate_size;
501
505
    for (l = 0; l < iterate_size; l += pack * at_once) {
502
506
 
503
507
        for (j = 0; j < spe_real_block; j++) {
504
 
            spu_mfcdma32((void *)(index + j * walloc), (unsigned int)(mrses_index + (j + l + block_group * iterate_size) * properties), walloc * sizeof(MRSESIntType), rdch, MFC_GET_CMD);
 
508
            spu_mfcdma32((void *)(index + j * walloc), (unsigned int)(mrses_index + (j + l + block_group * iterate_size) * palloc), walloc * sizeof(MRSESIntType), rdch, MFC_GET_CMD);
505
509
        }
506
510
 
507
511
        (void)spu_mfcstat(MFC_TAG_UPDATE_ALL);
571
575
 
572
576
//                      printf("%i, getting part of index %i, index segment %i\n", k + l, rpl_gen_k, rpl_gen_segment);
573
577
 
574
 
                        spu_mfcdma32((void*)(index_storage_k), (unsigned int)(mrses_index + (l + k + block_group * iterate_size) * properties + rpl_gen_segment), HW_ALIGN, rdch, MFC_GET_CMD);
 
578
                        spu_mfcdma32((void*)(index_storage_k), (unsigned int)(mrses_index + (l + k + block_group * iterate_size) * palloc + rpl_gen_segment), HW_ALIGN, rdch, MFC_GET_CMD);
575
579
                        (void)spu_mfcstat(MFC_TAG_UPDATE_ALL);
576
580
                        
577
581
                        idx = index_storage_k[rpl_gen_k - rpl_gen_segment];
625
629
                            
626
630
                            //printf("%i, write back\n", k);
627
631
                                // write back segment
628
 
                            spu_mfcdma32((void*)(index_storage_k), (unsigned int)(mrses_index + (l + k + block_group * iterate_size) * properties + rpl_gen_segment), HW_ALIGN, rdch, MFC_PUT_CMD);
 
632
                            spu_mfcdma32((void*)(index_storage_k), (unsigned int)(mrses_index + (l + k + block_group * iterate_size) * palloc + rpl_gen_segment), HW_ALIGN, rdch, MFC_PUT_CMD);
629
633
                            //(void)spu_mfcstat(MFC_TAG_UPDATE_ALL);
630
634
                            
631
635
                            //puts("done");
640
644
 
641
645
            // We can write back initial part of index, but we don't really need to
642
646
        for (j = 0; j < spe_real_block; j++) {
643
 
            spu_mfcdma32((void *)(index + j * walloc), (unsigned int)(mrses_index + (j + l + block_group * iterate_size) * properties), walloc * sizeof(MRSESIntType), rdch, MFC_PUT_CMD);
 
647
            spu_mfcdma32((void *)(index + j * walloc), (unsigned int)(mrses_index + (j + l + block_group * iterate_size) * palloc), walloc * sizeof(MRSESIntType), rdch, MFC_PUT_CMD);
644
648
        }
645
649
        (void)spu_mfcstat(MFC_TAG_UPDATE_ALL);
646
650
/*