vsiplshorttutorial内容摘要:
public private private public public public private private VSIPL Objects, II 169。 20202020 MPI Software Technology, Inc. Public Release. Objects vs. C memory/data structures • Objects abstract memory and operations in VSIPL • For memory, blocks/views/subviews allow for simpler management and specification • In plain C, a user must use the stack or malloc/free to handle dynamic data, and use many pointers to handle plex data • VSIPL simplifies programming through objects 169。 20202020 MPI Software Technology, Inc. Public Release. User Data vs. VSIPL Data • VSIPL operations cannot be performed on data created in user address space (public data) • The user data must be first bound to a VSIPL block, this is known as binding the user data • Such a bounded block can exist in an admitted or released state 169。 20202020 MPI Software Technology, Inc. Public Release. User Data vs. VSIPL Data • If the block is in admitted state then the data is in VSIPL space (private data) whereas if the block is released state then the data is in the user space – Admission: User space VSIPL space – Release: VSIPL space User space • VSIPL operations are performed on private data (data in an admitted block only) 169。 20202020 MPI Software Technology, Inc. Public Release. VSIPL Program Initialization Initialize VSIPL library Create block(s) Create view(s) amp。 bind view(s) to block(s) Create object(s) for filter(s), FFT(s), solver(s), etc. 169。 20202020 MPI Software Technology, Inc. Public Release. VSIPL Program Body Obtain Data Bind (or rebind) blocks(s) to data Admit (or readmit) block to VSIPL data space Operate on data using views(s) Release block(s) to user data space 169。 20202020 MPI Software Technology, Inc. Public Release. VSIPL Program Finalization Destroy object(s) for filter(s), FFT(s), solver(s), etc. Destroy view(s) Release and destroy block(s) Finalize VSIPL library 169。 20202020 MPI Software Technology, Inc. Public Release. A First VSIPL Program include include define L 7 /* length */ int main(){ /* Example of Sumval */ vsip_vview_f* data。 vsip_init ((void *)0)。 data = vsip_vcreate_f(L,VSIP_MEM_NONE)。 /* Make up some data to find the sum of */ /* Compute a ramp from zero to L1 */ vsip_vramp_f(, , data)。 /* And find and print its sum */ printf(%f \n, vsip_vsumval_f(data))。 /*destroy the vector views and any associated blocks */ vsip_blockdestroy_f(vsip_vdestroy_f(data))。 vsip_finalize ((void *)0)。 return 0。 } /* output */ 169。 20202020 MPI Software Technology, Inc. Public Release. VSIPL Initialization • VSIPL main header file must be included in all programs using the VSIPL library include “” • A VSIPL program must initialize the VSIPL library with a call to vsip_init before calling any other VSIPL function, and must call vsip_finalize before terminating. 169。 20202020 MPI Software Technology, Inc. Public Release. Block and View Create • Declare a pointer to a vector view of precision float vsip_vview_f* data。 • Create a block object and a vector view of the block data = vsip_vcreate_f(vsip_length, vsip_memory_hint)。 • vsip_vcreate_f function creates a block and returns a pointer to the vector view • To make a block of type float, and length 16, and attach it to a vector view of type float, with unit stride, and length 16 vsip_vview_f * v = vsip_vcreate_f(16,VSIP_MEM_NONE)。 • How do you make the block for type double ?? 169。 20202020 MPI Software Technology, Inc. Public Release. Ramp Function • Computes a vector ramp starting from the specified start value and incrementing each element by the ramp step size. vsip_vramp_f (start, stepsize, vectorview)。 • To initialize the vector “data” we use vsip_vramp_f(, , data) • After the operation, our vector contains data = (,…) 169。 20202020 MPI Software Technology, Inc. Public Release. Vector Sum Value • Returns the sum of the elements in a vector vsip_scalar_f vsip_sumval_f (vsip_vview_f)。 • To sum the elements of the vector “data” sum = vsip_sumval_f (data)。 • After the operation the value of sum = 21 169。 20202020 MPI Software Technology, Inc. Public Release. View and Block Destroy • Destroy vector view and return a pointer to the associated block object vsip_block_f vsip_vdestroy_f(vsip_vview_f) • To destroy the vector view “data” vsip_block_f *block = vsip_vdestroy_f (data)。 • Destroy the block object and any data allocated for it vsip_blockdestroy_f (vsip_block_f)。 • To destroy the block “block” vsip_blockdestroy_f (block)。 169。 20202020 MPI Software Technology, Inc. Public Release. VSI/Pro Application – Vector add, I include include include define L 7 /* Length of ramps */ int main() { int i。 vsip_vview_f *dataLeft, *dataRight, *dataSum。 vsip_init ((void *)0)。 /* Required initialization function */ dataLeft = vsip_vcreate_f(L,VSIP_MEM_NONE)。 dataRight = vsip_vcreate_f(L,VSIP_MEM_NONE)。 dataSum = vsip_vcreate_f(L,VSIP_MEM_NONE)。 /* Make up some data to find the magnitude of */ vsip_vramp_f(, , dataLeft)。 vsip_vramp_f(, (float)(L1), dataRight)。 vsip_vadd_f(dataLeft, dataRight, dataSum)。 /* Add the vectors */ 169。 20202020 MPI Software Technology, Inc. Public Release. VSI/Pro Application – Vector add, II /* now print out the data and its sum */ for(i=0。 iL。 i++) printf(% = (%) + (%) \n, vsip_vget_f(dataSum,i), vsip_vget_f(dataLeft,i),vsip_vget_f(dataRight,i))。 /* destroy the vector views and any associated bloc。vsiplshorttutorial
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。
用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。