Exemple #1
0
      void strided(char *dst, intptr_t dst_stride, char *const *src,
                   const intptr_t *src_stride, size_t count)
      {
        // Allocate a temporary buffer on the heap
        array buffer = empty(buffer_shape[0], buffer_tp);
        char *buffer_data = buffer.get_readwrite_originptr();
        intptr_t buffer_stride =
            reinterpret_cast<const fixed_dim_type_arrmeta *>(
                buffer.get_arrmeta())->stride;

        ckernel_prefix *first = get_child_ckernel();
        expr_strided_t first_func = first->get_function<expr_strided_t>();

        ckernel_prefix *second = get_child_ckernel(second_offset);
        expr_strided_t second_func = second->get_function<expr_strided_t>();

        char *src0 = src[0];
        intptr_t src0_stride = src_stride[0];

        size_t chunk_size =
            std::min(count, static_cast<size_t>(DYND_BUFFER_CHUNK_SIZE));
        first_func(buffer_data, buffer_stride, &src0, src_stride, chunk_size,
                   first);
        second_func(dst, dst_stride, &buffer_data, &buffer_stride, chunk_size,
                    second);
        count -= chunk_size;
        while (count) {
          src0 += chunk_size * src0_stride;
          dst += chunk_size * dst_stride;
          reset_strided_buffer_array(buffer);
          chunk_size =
              std::min(count, static_cast<size_t>(DYND_BUFFER_CHUNK_SIZE));
          first_func(buffer_data, buffer_stride, &src0, src_stride, chunk_size,
                     first);
          second_func(dst, dst_stride, &buffer_data, &buffer_stride, chunk_size,
                      second);
          count -= chunk_size;
        }
      }
Exemple #2
0
      void single(char *dst, char *const *src)
      {
        // Allocate a temporary buffer on the heap
        array buffer = empty(buffer_tp);
        char *buffer_data = buffer.get_readwrite_originptr();

        ckernel_prefix *first = get_child_ckernel();
        expr_single_t first_func = first->get_function<expr_single_t>();

        ckernel_prefix *second = get_child_ckernel(second_offset);
        expr_single_t second_func = second->get_function<expr_single_t>();

        first_func(buffer_data, src, first);
        second_func(dst, &buffer_data, second);
      }
Exemple #3
0
int main(int argc, char** argv)
{

    if(NULL == (value_outbuf = (char*)malloc(VALUE_ALLOC_SIZE))) {
        printf("Out of memory, please try running again! :(\n");
        return -1;
    }

    if(NULL == (second_outbuf = (char*)malloc(VALUE_ALLOC_SIZE))) {
        printf("Out of memory, please try running again! :(\n");
        return -2;
    }
    memset(value_outbuf, 0, VALUE_ALLOC_SIZE);
    memset(second_outbuf, 0, VALUE_ALLOC_SIZE);

    printf("Preparing to run first function (using and)\n");
    EQ((size_t)128, first_func());

    printf("Preparing to run second function (using or)\n");
    EQ((size_t)3740139503, second_func());

    printf("Preparing to run third function (Zeroing RAX)\n");
    EQ((size_t)0, third_func());

    printf("Preparing to run fourth function (Bitshift Multiplication)\n");
    EQ((size_t)64, fourth_func());

    printf("Preparing to run fifth function (Bitshift Division)\n");
    EQ((size_t)2, fifth_func());

    printf("Preparing to run sixth function (rotating bytes)\n");
    sixth_func();
    printf("Rotated output: %s\n", second_outbuf);

    printf("Preparing to run seventh function (decode value)\n");
    seventh_func();
    printf("Decoded Output: %s\n", value_outbuf);

    free(second_outbuf);
    free(value_outbuf);

    return 0;
}