예제 #1
0
int main(int argc, char **argv)
{
    vsip_scalar_f userArray[2*N];
    vsip_cblock_f *blk;
    vsip_cvview_f *vw;
    vsip_dda_cvdata_f *data;
    vsip_dda_cvdataattr_f attrib;
    vsip_cscalar_f *arrayPtr;
    vsip_scalar_f *interPtr;
    vsip_scalar_f *splitRealPtr, *splitImagPtr;
    vsip_scalar_f *data1ptr, *data2ptr;    
    vsip_init((void *)0);   
    blk = vsip_cblockbind_f(&userArray[0], 0, N, VSIP_MEM_NONE);
        /* TODO: Handle error */
    /* NOTE
     * The block bind call above implies an INTERLEAVED storage format in the
     * user array, but once admitted, the implementation may use a different
     * storage format.
     */
    vsip_cblockadmit_f(blk, 0); /* TODO: Handle error */
    vw = vsip_cvbind_f(blk, 0, 1, N); /* TODO: Handle error */
    /* NOTE
     * No layout is provided when the data object is created, so the view's own
     * layout is used.
     */             
    data = vsip_dda_cvdatacreate_f(vw, 0, VSIP_DDA_SYNC_POLICY_OUT, 0);
    /* TODO: Handle error */
    vsip_dda_cvdatagetattrib_f(data, &attrib); /* TODO: Handle error */   
    /* NOTE
     * Since the layout of the data object is not specified, the data object
     * attributes must retrieved, and the storage format checked, to determine
     * which complex pointer accessor to use.
     */    
    if(VSIP_STORAGE_FORMAT_ARRAY == attrib.layout->storage_format)
    {        
        arrayPtr = vsip_dda_cvptr_as_array_f(data); /* TODO: Handle error */
        arrayPtr[0].r = 1.0F; arrayPtr[0].i = -1.0F;
    }
    else if(VSIP_STORAGE_FORMAT_INTERLEAVED_COMPLEX
        == attrib.layout->storage_format)
    {
        interPtr = vsip_dda_cvptr_as_inter_f(data); /* TODO: Handle error */
        interPtr[0] = 1.0F; interPtr[1] = -1.0F;       
    }
    else if(VSIP_STORAGE_FORMAT_SPLIT_COMPLEX == attrib.layout->storage_format)
    {
        vsip_dda_cvptr_as_split_f(data, &splitRealPtr, &splitImagPtr);
            /* TODO: Handle error */
        splitRealPtr[0] = 1.0F; splitImagPtr[0] = -1.0F;
    }
    vsip_dda_cvdatadestroy_f(data); /* TODO: Handle error */
    /* NOTE
     * Because of the OUT synchronization policy, the proxied view will have
     * been updated with the contents of any DDA buffers.
     */
    vsip_cvdestroy_f(vw); /* TODO: Handle error */
    vsip_cblockrelease_f(blk, 1, &data1ptr, &data2ptr); /* TODO: Handle error */
    vsip_cblockdestroy_f(blk);
    vsip_finalize((void *)0);
    return 0;
}
예제 #2
0
int main(){
vsip_init((void*)0);{
    vsip_cvview_f *A = vsip_cvcreate_f(16,0);
    vsip_cvview_f *a = vsip_cvsubview_f(A,0,4);
    vsip_cvview_f *B = vsip_cvcreate_f(16,0);
    vsip_cvview_f *b = vsip_cvsubview_f(B,0,4);
    vsip_scalar_f user_data_r[16],*udr;
    vsip_scalar_f user_data_i[16],*udi;
    vsip_cblock_f *cblock = vsip_cblockbind_f(
             user_data_r,user_data_i,16,0);
    vsip_cvview_f *c = vsip_cvbind_f(cblock,1,2,4);

    /* unit stride data_even out of place */
    FILE *fptr = fopen("data_even","r");
    vsip_cblockadmit_f(cblock,VSIP_FALSE);
    printf("test cvlog\n");
    printf("unit stride data even out of place");
    VU_cvreadf_f(fptr,a);
    fclose(fptr);
    printf("input vector\n"); VU_cvprintm_f("6.4",a);
    vsip_cvlog_f(a,b);
    printf("input vector after operation\n");VU_cvprintm_f("6.4",a);
    printf("output vector\n"); VU_cvprintm_f("6.4",b);
    /* inplace */
    vsip_cvlog_f(a,a);
    printf("output of inplace\n"); VU_cvprintm_f("6.4",a);

    /* unit stride data_odd out of place */
    printf("unit stride data odd out of place\n");
    vsip_cvputlength_f(a,5);
    vsip_cvputlength_f(b,5);
    fptr = fopen("data_odd","r");
    VU_cvreadf_f(fptr,a);
    fclose(fptr);
    printf("input vector\n"); VU_cvprintm_f("6.4",a);
    vsip_cvlog_f(a,b);
    printf("input vector after operation\n");VU_cvprintm_f("6.4",a);
    printf("output vector\n"); VU_cvprintm_f("6.4",b);

    /* input stride 1 output stride 2 */
    printf("input stride 1 output stride 2\n");
    vsip_cvputstride_f(b,2);
    fptr = fopen("data_odd","r"); VU_cvreadf_f(fptr,a); fclose(fptr);
    vsip_cvlog_f(a,b);
    printf("output vector\n"); VU_cvprintm_f("6.4",b);

    /* input stride 2 output stride 3 */
    printf("input stride 2 output stride 3\n");
    vsip_cvputstride_f(a,2);
    vsip_cvputstride_f(b,3);
    fptr = fopen("data_odd","r"); VU_cvreadf_f(fptr,a); fclose(fptr);
    vsip_cvlog_f(a,b);
    printf("output vector\n"); VU_cvprintm_f("6.4",b);

    /* input stride 2 output stride 1 */
    printf("input stride 2 output stride 1\n");
    vsip_cvputstride_f(a,2);
    vsip_cvputstride_f(b,1);
    fptr = fopen("data_odd","r"); VU_cvreadf_f(fptr,a); fclose(fptr);
    vsip_cvlog_f(a,b);
    printf("output vector\n"); VU_cvprintm_f("6.4",b);

    /* in place stride 2 */
    printf("in place stride 2\n");
    fptr = fopen("data_odd","r"); VU_cvreadf_f(fptr,a); fclose(fptr);
    vsip_cvlog_f(a,a);
    printf("output vector\n"); VU_cvprintm_f("6.4",a);

    /* out of place from user block to VSIPL block */
    printf("out of place from user block to VSIPL block\n");
    printf("User block associated with split complex data array\n");
    printf("user view offset 1, stride 2\n");
    printf("vsipl view offset 0, stride 2\n");
    fptr = fopen("data_odd","r"); VU_cvreadf_f(fptr,c); fclose(fptr);
    vsip_cvlog_f(c,a);
    printf("output vector\n"); VU_cvprintm_f("6.4",a);

    /* clean up */
    vsip_cblockrelease_f(cblock,VSIP_FALSE,&udr,&udi);
    vsip_cvalldestroy_f(c);
    vsip_cvdestroy_f(a);
    vsip_cvdestroy_f(b);
    vsip_cvalldestroy_f(A);
    vsip_cvalldestroy_f(B);
    }vsip_finalize((void*)0);return 0;
}