Changeset ff7119b in sasmodels for sasmodels/alignment.py


Ignore:
Timestamp:
Aug 26, 2014 10:27:06 PM (10 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, core_shell_microgels, costrafo411, magnetic_model, release_v0.94, release_v0.95, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
5d4777d
Parents:
a7684e5
Message:

docu update

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/alignment.py

    r14de349 rff7119b  
    33 
    44Some web sites say that maximizing performance for OpenCL code requires 
    5 aligning data on certain memory boundaries. 
     5aligning data on certain memory boundaries.  The following functions 
     6provide this service: 
    67 
    7 :func:`data_alignment` queries all devices in the OpenCL context, returning 
    8 the most restrictive alignment. 
     8:func:`align_data` aligns an existing array, returning a new array of the 
     9correct alignment. 
    910 
    10 :func:`align_data` aligns an existing array. 
     11:func:`align_empty` to create an empty array of the correct alignment. 
    1112 
    12 :func:`align_empty` to create a new array of the correct alignment. 
     13Set alignment to :func:`gpu.environment()` attribute *boundary*. 
    1314 
    1415Note:  This code is unused. So far, tests have not demonstrated any 
     
    1718to decide whether it is really required. 
    1819""" 
    19  
    2020import numpy as np 
    21 import pyopencl as cl 
    22  
    23 def data_alignment(context): 
    24     """ 
    25     Return the desired byte alignment across all devices. 
    26     """ 
    27     # Note: rely on the fact that alignment will be 2^k 
    28     return max(d.min_data_type_align_size for d in context.devices) 
    2921 
    3022def align_empty(shape, dtype, alignment=128): 
     23    """ 
     24    Return an empty array aligned on the alignment boundary. 
     25    """ 
    3126    size = np.prod(shape) 
    3227    dtype = np.dtype(dtype) 
     
    4035 
    4136def align_data(v, dtype, alignment=128): 
     37    """ 
     38    Return a copy of an array on the alignment boundary. 
     39    """ 
    4240    # if v is contiguous, aligned, and of the correct type then just return v 
    4341    view = align_empty(v.shape, dtype, alignment=alignment) 
     
    4543    return view 
    4644 
    47 def work_group_size(context, kernel): 
    48     """ 
    49     Return the desired work group size for the context. 
    50     """ 
    51     max(kernel.get_work_group_info(cl.kernel_work_group_info.PREFERRED_WORK_GROUP_SIZE_MULTIPLE, d) 
    52         for d in context.devices) 
    53  
    54  
Note: See TracChangeset for help on using the changeset viewer.