Code Monkey home page Code Monkey logo

copperhead's People

Contributors

bryancatanzaro avatar serge-sans-paille avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

copperhead's Issues

Short circuit binary operators

Short circuit binary operators are currently not short-circuiting.

This deviates from Python's conditional evaluation semantics and should be fixed.

Array cannot be safely cast to required type.

Under Ubuntu 11.10, Copperhead runs into issues with Numpy v1.6.1. The following traceback occurs when trying to run the axpy.py sample:

Traceback (most recent call last):
 File "samples/axpy.py", line 57, in<module>
   (x, y, z, zPython, error) = test_saxpy(length)
 File "samples/axpy.py", line 41, in test_saxpy
   z = axpy(a, x, y)
 File "/home/adamm/.virtualenvs/copper/local/lib/python2.7/site-packages/copperhead-0.2a2-py2.7.egg/copperhead/runtime/cufunction.py", line 58, in __call__
   return P.execute(self, args, kwargs)
 File "/home/adamm/.virtualenvs/copper/local/lib/python2.7/site-packages/copperhead-0.2a2-py2.7.egg/copperhead/runtime/driver.py", line 47, in execute
   return execute(self.tag(), cufn, *args, **kwargs)
 File "/home/adamm/.virtualenvs/copper/local/lib/python2.7/site-packages/copperhead-0.2a2-py2.7.egg/copperhead/runtime/driver.py", line 107, in execute
   cu_types, cu_inputs = zip(*map(induct, v))
 File "/home/adamm/.virtualenvs/copper/local/lib/python2.7/site-packages/copperhead-0.2a2-py2.7.egg/copperhead/runtime/driver.py", line 76, in induct
   induced = cudata.cuarray(x)
TypeError: array cannot be safely cast to required type

A similar error occurs for 78 of the tests as well. Reverting to Numpy v1.5.1 corrects the issue.

``setup.py build`` tries to modify the site-packages

I was trying to build copperhead as part of an AUR package build. The packages are first compiled with normal privileges and after the package got assemble it is installed to the system with superuser privileges.

Here is my problem. It seems to me like the setup script tries to modify the site-packages of the global python installation. This obviously fails because it would require higher privileges.

[jakob@manj copperhead]$ python2 setup.py build
Scanning installed packages
Setuptools installation detected at /usr/lib/python2.7/site-packages
Non-egg installation
Removing elements out of the way...
Renaming /usr/lib/python2.7/site-packages/setuptools-15.0-py2.7.egg-info into /usr/lib/python2.7/site-packages/setuptools-15.0-py2.7.egg-info.OLD.1429037986.46
Creating /tmp/copperhead/setuptools-0.6c9-py2.7.egg-info
Creating /tmp/copperhead/setuptools.pth
Traceback (most recent call last):
  File "setup.py", line 21, in <module>
    use_setuptools()
  File "/tmp/copperhead/distribute_setup.py", line 136, in use_setuptools
    fake_setuptools()
  File "/tmp/copperhead/distribute_setup.py", line 365, in fake_setuptools
    res = _remove_flat_installation(setuptools_location)
  File "/tmp/copperhead/distribute_setup.py", line 248, in _remove_flat_installation
    patched = _patch_egg_dir(pkg_info)
  File "/tmp/copperhead/distribute_setup.py", line 303, in _patch_egg_dir
    _rename_path(path)
  File "/tmp/copperhead/distribute_setup.py", line 228, in _rename_path
    os.rename(path, new_name)
OSError: [Errno 13] Permission denied

I talked to the packages maintainer here:
https://aur.archlinux.org/packages/copperhead-hg/

The maintainer is migrating to the new github repo here:
https://aur.archlinux.org/packages/python2-copperhead-git/

installation: "scons: *** [stage/copperhead/compiler/backendcompiler.os] Error 1"

Hi guys,

I've spent several hours trying to install copperhead on my iMac - I've fixed about 5 issues by finding answers on websites but I got to this point and I'm stumped... can anyone help?

Thanks in advance!

Greg

ECSMacAugust1:copperhead-master user$ python setup.py install
Extracting in /var/folders/bm/l_yhcr911wv7_tf_ywk2h2mh0000gn/T/tmpvYVBP5
Now working in /var/folders/bm/l_yhcr911wv7_tf_ywk2h2mh0000gn/T/tmpvYVBP5/distribute-0.6.4
Building a Distribute egg in /Users/user/Downloads/copperhead-master
/Users/user/Downloads/copperhead-master/setuptools-0.6c9-py2.7.egg-info already exists
scons: Reading SConscript files ...
Vendor: Continuum Analytics, Inc.
Package: mkl
Message: trial mode expires in 29 days
Vendor: Continuum Analytics, Inc.
Package: mkl
Message: trial mode expires in 29 days
Checking /usr/local/bin/g++-5 version... (cached) 5.1.0
Checking nvcc version... (cached) 7.0
Checking for C++ library cudart... (cached) yes
Checking for C++ library python2.7... (cached) yes
Checking for C++ library boost_python... (cached) yes
Checking for C++ header file thrust/host_vector.h... (cached) yes
Checking Thrust version...(cached) 1.8.1
Checking for C++ header file tbb/tbb.h... (cached) yes
Checking for C++ library tbb... (cached) yes
********************* BACKEND SUPPORT *********************
CUDA backend: True
OpenMP backend: True
TBB backend: True


scons: warning: Ignoring missing SConscript 'backend/build/SConscript'
File "/Users/user/Downloads/copperhead-master/SConstruct", line 291, in
scons: done reading SConscript files.
scons: Building targets ...
/usr/local/bin/g++-5 -o stage/copperhead/compiler/backendcompiler.os -c -O2 -Wall -O3 -std=c++0x -Wall -fPIC -DCUDA_SUPPORT -DOMP_SUPPORT -DTBB_SUPPORT -I/usr/local/Cellar/boost/1.58.0/include/boost/numeric/odeint/external -I/usr/local/cuda/include -I/usr/local/Cellar/boost/1.58.0/include -I/usr/local/Cellar/tbb/4.3-20150611/include -Ibackend/inc -I/Users/user/anaconda/include/python2.7 -I/usr/local/Cellar/boost/1.58.0/include src/copperhead/compiler/backendcompiler.cpp
src/copperhead/compiler/backendcompiler.cpp:3:24: fatal error: compiler.hpp: No such file or directory
compilation terminated.
scons: *** [stage/copperhead/compiler/backendcompiler.os] Error 1
scons: building terminated because of errors.
Traceback (most recent call last):
File "setup.py", line 40, in
raise CompileError("Error while building Python Extensions")
distutils.errors.CompileError: Error while building Python Extensions

[FIXED] copperhead/compiler/rewrites.py seems not to handle nested argument lists

Hi

trying the samples/of_cg.py demo I have noticed that the rewriter is not able to correctly associate nested argument names to variables

The culprit seems to be lines 724-725 of file copperhead/compiler/rewrites.py

    for (internal, external) in zip(functionArguments, instantiatedArguments):
         env[internal.id] = external

which expect the argument list to be a flat list, while in of_gc.py there are 2 functions using nested argument lists

def of_spmv((du, dv), width, (m1, m2, m3, m4, m5, m6, m7)):
     <body>
def precondition(u, v, (p1, p2, p3)):
     <body>

By rewriting the initial part of the functions as follow all works fine

def precondition(u, v, p1_p3):
    (p1, p2, p3) = p1_p3       
    <body>

def of_spmv(du_dv, width, m1_m7):
    (du, dv) = du_dv                            
    (m1, m2, m3, m4, m5, m6, m7) = m1_m7        
    <body>

[FIX]: I think I fixed the problem by moving the name_tuples step before the inline one in copperhead/compiler/passes.py

diff --git a/copperhead/compiler/passes.py b/copperhead/compiler/passes.py
index 6d5fa29..672e5bd 100644
--- a/copperhead/compiler/passes.py
+++ b/copperhead/compiler/passes.py
@@ -243,6 +243,7 @@ frontend = Pipeline('frontend', [gather_source,
                                  procedure_flatten,
                                  expression_flatten,
                                  syntax_check,
+                                 name_tuples,  # FIX: moved here to avoid inline errors with nested argument lists
                                  inline,
                                  cast_literals,

Timing copperhead from benchmark from within python + Compiling the C++ src generated to profile using nv profiler

Hi,

I have been using copperhead for quiet some time now and I don't see a way where users may communicate and get some support, so I will post my questions here so that anyone faces similar issues can refer to this (hope this is ok).

So, as the subject line says:
1- I am using copperhead blackscholes sample as a benchmark. I am trying to time both "memory transfers to and from GPU" + kernel launch and execution time. Source for the what I am doing it follows, am I doing this right according to below source?

SRC

from copperhead import *
import numpy as np
import time

@cu
def cnd(d):
    A1 = 0.31938153
    A2 = -0.356563782
    A3 = 1.781477937
    A4 = -1.821255978
    A5 = 1.330274429
    RSQRT2PI = 0.39894228040143267793994605993438

    K = 1.0 / (1.0 + 0.2316419 * abs(d))

    cnd = RSQRT2PI * exp(- 0.5 * d * d) * \
        (K * (A1 + K * (A2 + K * (A3 + K * (A4 + K * A5)))))

    if d > 0:
        return 1.0 - cnd
    else:
        return cnd


@cu
def black_scholes(S, X, T, R, V):
    def black_scholes_el(si, xi, ti):
        sqrt_ti = sqrt(ti)
        d1 = (log(si/xi) + (R + .5 * V * V) * ti) / (V * sqrt_ti)
        d2 = d1 - V * sqrt_ti
        cnd_d1 = cnd(d1)
        cnd_d2 = cnd(d2)
        exp_Rti = exp(-R * ti)
        call_result = si * cnd_d1 - xi * exp_Rti * cnd_d2;
        put_result = xi * exp_Rti * (1.0 - cnd_d2) - si * (1.0 - cnd_d1)
        return call_result, put_result
    return map(black_scholes_el, S, X, T)

def rand_floats(n, min, max):
    diff = np.float32(max) - np.float32(min)
    rands = np.array(np.random.random(n), dtype=np.float32)
    rands = rands * diff
    rands = rands + np.float32(min)
    return cuarray(rands)

n1 = 16
n2 = 4096 #4k
n3 = 16384 #16k
n4 = 32768 #32k
n5 = 65536 #64k
n6 = 131072 #128k
n7 = 262144 #256k
n8 = 524288 #512k
n9 = 1048576 #1M
n9 = 1048576 #1M
n10 = 2097192 #2M
n11 = n10*2 #4M
n12 = n11*2 #8M
n13 = n12*2 #16M
n14 = n13*2 #32M

n = n14


S = rand_floats(n, 5, 30)
X = rand_floats(n, 1, 100)
T = rand_floats(n, .25, 10)
R = np.float32(.02)
V = np.float32(.3)

start = time.time()
with places.gpu0:
    r = black_scholes(S, X, T, R, V)
end = time.time()



print 'Computed: ', n , ' Options'
print 'Computation Time: ', (end-start)*1000 ,' Milliseconds'

2- the CPP source generated in the pycache after compiling the above, I need to compile it to a regular binary file (just like nvcc xxx.cu -o my_bin) and then run it using nvidia profiler to investigate some more according to timing obtained from "1" above. How exactly can I do that? this is a crucial thing in my benchmarking report so I need to do it or else I may conclude that it can't be done.

Thanks a lot in advance for all the help and time spent to educate me.

Entry point model

The compiler currently assumes there is one entry point function, and this entry point is the only one which receives and returns containers. All other non-nested functions are inlined. This is problematic for several reasons:

  1. Conditional expressions aren't handled correctly. x if b else y
  2. Short circuit binary operations aren't handled correctly if x or y:

We need to change from an "entry point" model in the compiler to a parallelism nesting level, and outermost functions can all receive and return containers.

Installing without siteconf.py leads to error.

Despite have boost_python installed in the default location, I am unable to compile any Copperhead code after installation. During installation, it seems to find the boost libraries. I do get:

Checking g++ version... (cached) 4.5.4
Checking nvcc version... (cached) 4.1

*************** siteconf.py not found ***************
We will try building anyway, but may not succeed.
Read the README for more details.

Checking for C++ library python2.7... (cached) yes
Checking for C++ library boost_python... (cached) yes

Which leads me to believe that it knows where to look to find the boost_python libraries. However, if I try to run the axpy.py sample I get:

#define BOOST_PYTHON_MAX_ARITY 10
#include <boost/python.hpp>
#include <cunp.hpp>
#include <make_cuarray.hpp>
#include <make_cuarray_impl.hpp>
#include <make_sequence.hpp>
#include <make_sequence_impl.hpp>
#include <cuda.h>
namespace _axpyFnTupleFloat32SeqFloat32SeqFloat32SeqFloat32 {
sp_cuarray wrap_axpy(PyObject* _a, sp_cuarray ary_x, sp_cuarray ary_y);
}
using namespace _axpyFnTupleFloat32SeqFloat32SeqFloat32SeqFloat32;
template sequence<float> make_sequence<sequence<float> >(sp_cuarray&, bool, bool);
template sp_cuarray make_cuarray<float>(size_t);


BOOST_PYTHON_MODULE(module)
{
  boost::python::def("_axpy", &wrap_axpy);
}
#include <cunp.hpp>
#include <make_cuarray.hpp>
#include <make_sequence.hpp>
#include <cuda/prelude.h>

#include "cuda/thrust_wrappers/map.h"

namespace _axpyFnTupleFloat32SeqFloat32SeqFloat32SeqFloat32 {
template<typename a>
__device__ a _triad(a _xi, a _yi, a _K0) {
    typedef a T_xi;
    typedef a T_yi;
    typedef a T_K0;
    typedef a Te0;
    Te0 e0 = op_mul(_K0, _xi);
    typedef a Tresult;
    Tresult result = op_add(e0, _yi);
    return result;
}

template<typename a>
struct fn_triad {
    typedef a result_type;
    __device__ a operator()(a _xi, a _yi, a _K0) {
        typedef a T_xi;
        typedef a T_yi;
        typedef a T_K0;
        return _triad(_xi, _yi, _K0);
    }

};

sp_cuarray _axpy(float _a, stored_sequence<float> _x, stored_sequence<float> _y) {
    typedef float T_a;
    typedef stored_sequence<float> T_x;
    typedef stored_sequence<float> T_y;
    typedef transformed_sequence<closure1<float, fn_triad<float> >, thrust::tuple<T_x, T_y> > Tresult;
    Tresult result = map2(closure1<float, fn_triad<float > >(_a, fn_triad<float >()), _x, _y);
    typedef sp_cuarray Tarycompresult;
    Tarycompresult arycompresult = phase_boundary(result);
    typedef stored_sequence<float> Tcompresult;
    Tcompresult compresult = make_sequence<sequence<float> >(arycompresult, false, true);
    return arycompresult;
}

sp_cuarray wrap_axpy(PyObject* _a, sp_cuarray ary_x, sp_cuarray ary_y) {
    sp_cuarray result = _axpy(unpack_scalar_float(_a), make_sequence<sequence<float> >(ary_x, false, false), make_sequence<sequence<float> >(ary_y, false, false));
    return result;
}

}

ERROR during compilation in make_binary


ERROR during compilation in binarize

Traceback (most recent call last):
  File "axpy.py", line 57, in <module>
    (x, y, z, zPython, error) = test_saxpy(length)
  File "axpy.py", line 41, in test_saxpy
    z = axpy(a, x, y)
  File "/home/adamm/.virtualenvs/au/local/lib/python2.7/site-packages/copperhead-0.2a1-py2.7-linux-x86_64.egg/copperhead/runtime/cufunction.py", line 58, in __call__
    return P.execute(self, args, kwargs)
  File "/home/adamm/.virtualenvs/au/local/lib/python2.7/site-packages/copperhead-0.2a1-py2.7-linux-x86_64.egg/copperhead/runtime/driver.py", line 28, in execute
    return execute(cufn, *args, **kwargs)
  File "/home/adamm/.virtualenvs/au/local/lib/python2.7/site-packages/copperhead-0.2a1-py2.7-linux-x86_64.egg/copperhead/runtime/driver.py", line 71, in execute
    **k)
  File "/home/adamm/.virtualenvs/au/local/lib/python2.7/site-packages/copperhead-0.2a1-py2.7-linux-x86_64.egg/copperhead/compiler/passes.py", line 247, in compile
    return run_compilation(target, source, M)
  File "/home/adamm/.virtualenvs/au/local/lib/python2.7/site-packages/copperhead-0.2a1-py2.7-linux-x86_64.egg/copperhead/compiler/passes.py", line 232, in run_compilation
    return target(suite, M)
  File "/home/adamm/.virtualenvs/au/local/lib/python2.7/site-packages/copperhead-0.2a1-py2.7-linux-x86_64.egg/copperhead/compiler/passes.py", line 90, in __call__
    ast = P(ast, M)
  File "/home/adamm/.virtualenvs/au/local/lib/python2.7/site-packages/copperhead-0.2a1-py2.7-linux-x86_64.egg/copperhead/compiler/passes.py", line 90, in __call__
    ast = P(ast, M)
  File "/home/adamm/.virtualenvs/au/local/lib/python2.7/site-packages/copperhead-0.2a1-py2.7-linux-x86_64.egg/copperhead/compiler/passes.py", line 197, in make_binary
    return Binary.make_binary(M)
  File "/home/adamm/.virtualenvs/au/local/lib/python2.7/site-packages/copperhead-0.2a1-py2.7-linux-x86_64.egg/copperhead/compiler/binarygenerator.py", line 85, in make_binary
    raise e
ImportError: /tmp/codepy-compiler-cache-v5-uid1000/d0009f81104ade7d9a86f51a465339ba/codepy.temp.d0009f81104ade7d9a86f51a465339ba.module.so: undefined symbol: _ZNK5boost6python7objects21py_function_impl_base9max_arityEv

The compiler appears to have difficult locating the correct boost libraries. Installing with a siteconf.py containing:

#!/usr/bin/python
BOOST_INC_DIR = "/usr/include"
BOOST_LIB_DIR = "/usr/lib"
BOOST_PYTHON_LIBNAME = "boost_python"

solves the issue. For comparison, the generated siteconf.py looks like this:

NP_INC_PATH = "/home/adamm/.virtualenvs/au/local/lib/python2.7/site-packages/numpy/core/include"
BOOST_INC_DIR = None
BOOST_LIB_DIR = None
BOOST_PYTHON_LIBNAME = None

Perhaps having the generated siteconf.py fill in the default locations instead would work.

compile errors in test_zip.py

Hi
I get a compile error on the tests/test_zip.py test

/usr/lib/python2.7/site-packages/copperhead-0.2a2-py2.7.egg/copperhead/inc/prelude/basic/apply_from_tuple.h(44): error: function "_shift_zip_5092476690532980926::fn_shift_el<a>::operator() [with a=thrust::tuple<long, long, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type>]" cannot be called with the given argument list
            argument types are: (const long, const thrust::tuple<long, long, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type>, const long, const copperhead::zipped_sequence<thrust::tuple<copperhead::sequence<copperhead::cuda_tag, long, 0>, copperhead::sequence<copperhead::cuda_tag, long, 0>, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type>>)
            object type is: _shift_zip_5092476690532980926::fn_shift_el<thrust::tuple<long, long, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type>>

This happens at the second phase_boundary of the generated Cuda code:

#include <prelude/prelude.h>
#include <prelude/runtime/cunp.hpp>
#include <prelude/runtime/make_cuarray.hpp>
#include <prelude/runtime/make_sequence.hpp>
#include <prelude/runtime/tuple_utilities.hpp>
using namespace copperhead;

#include "prelude/primitives/indices.h"

#include "prelude/primitives/map.h"

#include "prelude/primitives/zip.h"

namespace _shift_zip_5092476690532980926 {
template<typename a>
__device__ a _shift_el(long _i, a _K0, long _K1, sequence<cuda_tag, a> _K2) {
    typedef long T_i;
    typedef a T_K0;
    typedef long T_K1;
    typedef sequence<cuda_tag, a> T_K2;
    typedef long T_i_1;
    T_i_1 _i_1 = op_add(_i, _K1);
    typedef long Te4;
    Te4 e4 = cast_to((long)0, _i_1);
    typedef bool Te0;
    Te0 e0 = cmp_lt(_i_1, e4);
    typedef long Te1;
    Te1 e1 = len(_K2);
    typedef bool Te2;
    Te2 e2 = cmp_ge(_i_1, e1);
    if (op_bor(e0, e2)) {
        return _K0;
    } else {
        typedef a Tresult;
        Tresult result = _K2[_i_1];
        return result;
    }

}

template<typename a>
struct fn_shift_el {
    typedef a result_type;
    __device__ a operator()(long _i, a _K0, long _K1, sequence<cuda_tag, a> _K2) {
        typedef long T_i;
        typedef a T_K0;
        typedef long T_K1;
        typedef sequence<cuda_tag, a> T_K2;
        return _shift_el(_i, _K0, _K1, _K2);
    }

};

sp_cuarray _shift_zip(sp_cuarray ary_x, sp_cuarray ary_y, PyObject* arg0, PyObject* arg1) {
    thrust::tuple<long, long> _z = unpack_tuple<thrust::tuple<long, long> >(arg0);
    long _d = unpack_scalar_long(arg1);
    typedef sp_cuarray Tary_x;
    typedef sp_cuarray Tary_y;
    typedef thrust::tuple<long, long> T_z;
    typedef long T_d;
    typedef sequence<cuda_tag, long> T_x;
    T_x _x = make_sequence<sequence<cuda_tag, long> >(ary_x, cuda_tag(), false);
    typedef sequence<cuda_tag, long> T_y;
    T_y _y = make_sequence<sequence<cuda_tag, long> >(ary_y, cuda_tag(), false);
    typedef zipped_sequence<thrust::tuple<T_x, T_y> > T_a_2;
    T_a_2 _a_2 = zip2(_x, _y);
    typedef index_sequence<cuda_tag> Te3_4;
    Te3_4 e3_4 = indices(_a_2);
    typedef sp_cuarray Tarycomp_a_2;
    Tarycomp_a_2 arycomp_a_2 = phase_boundary(_a_2);
    typedef zipped_sequence<thrust::tuple<sequence<cuda_tag, long>, sequence<cuda_tag, long> > > Tcomp_a_2;
    Tcomp_a_2 comp_a_2 = make_sequence<zipped_sequence<thrust::tuple<sequence<cuda_tag, long>, sequence<cuda_tag, long> > > >(arycomp_a_2, cuda_tag(), true);
    typedef transformed_sequence<closure<fn_shift_el<thrust::tuple<long, long> > , thrust::tuple<T_z, T_d, Tcomp_a_2> >, thrust::tuple<Te3_4> > T_b_3;
    T_b_3 _b_3 = map1(closure<fn_shift_el<thrust::tuple<long, long> >, thrust::tuple<T_z, T_d, Tcomp_a_2> >(fn_shift_el<thrust::tuple<long, long> >(), thrust::make_tuple(_z, _d, comp_a_2)), e3_4);
    typedef sp_cuarray Tarycomp_b_3;
    Tarycomp_b_3 arycomp_b_3 = phase_boundary(_b_3); // HERE
    typedef zipped_sequence<thrust::tuple<sequence<cuda_tag, long>, sequence<cuda_tag, long> > > Tcomp_b_3;
    return arycomp_b_3;
}

}

As I am not very fluent with C++ templates and thrust, could somebody help me to interpret and fix the error?

Thanks
Andrea

error: no suitable user-defined conversion from "Tresult" to "copperhead::sequence<copperhead::cuda_tag, long, 0>" exists

I get this error from trying to execute the following program. Calling sobol directly works fine, but when mapping in sobol1D something goes wrong.

from math import sqrt, trunc
from copperhead import *
import numpy as np

dirvs0 = cuarray(np.array([2147483648,1073741824,2684354560,1342177280,
                           2281701376,603979776,301989888,754974720,
                           1988100096,2654994432,136314880,1678770176,
                           2988965888,2098462720,4272029696,3125346304,
                           438599680,1226522624,3300237312,3816001536,
                           4135585792,3728737280,2820672000,873465088,
                           975702144,1494483520,3970040096,2538144464,
                           1822721896,3613084132,3432358018,2271450689]
                          ,dtype=np.int64))

@cu
def normalise(x):
    twoPow32 = 4294967296
    return float32(x) / twoPow32 # pow(2.0, 32)

@cu
def bitVector(e):
    n_directions = 32
    def isbitset(i):
        if (e & (1 << i)) > 0:
            return 1
        else:
            return 0
    return map(isbitset, range(n_directions))

@cu
def sobol(v,i):
    return normalise(reduce(op_xor,(map(op_mul, v, bitVector(i))),0))

@cu
def sobol1D(v,m):
    def f(i):
        return sobol(v,i)
    return map(f, range(m+1))

print(sobol1D(dirvs0,10))

I can attach the complete error message if you are not able to reproduce it

Sementation Violation on Samples

I am having some trouble with getting copperhead up and running. I don't see a mailing list or some other method, so I am submitting the issue here. Here is the output of a backtrace on the python process that gives me the segmentation violation:

(gdb) run black_scholes.py
Starting program: /usr/bin/python black_scholes.py
warning: Could not load shared library symbols for linux-vdso.so.1.
Do you need "set solib-search-path" or "set sysroot"?
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff5ec1074 in backend::type_t::ptr() const ()
   from /usr/lib64/python2.7/site-packages/copperhead-0.2a2-py2.7.egg/copperhead/runtime/libcopperhead.so
(gdb) bt
#0  0x00007ffff5ec1074 in backend::type_t::ptr() const ()
   from /usr/lib64/python2.7/site-packages/copperhead-0.2a2-py2.7.egg/copperhead/runtime/libcopperhead.so
#1  0x00007ffff5e8da81 in backend::functorize::functorize(std::string const&, backend::registry const&) ()
   from /usr/lib64/python2.7/site-packages/copperhead-0.2a2-py2.7.egg/copperhead/runtime/libcopperhead.so
#2  0x00007ffff5e57950 in backend::compiler::operator()(backend::suite const&) ()
   from /usr/lib64/python2.7/site-packages/copperhead-0.2a2-py2.7.egg/copperhead/runtime/libcopperhead.so
#3  0x00007fffefcc703b in backend::compile(backend::compiler&, backend::suite const&) ()
   from /usr/lib64/python2.7/site-packages/copperhead-0.2a2-py2.7.egg/copperhead/compiler/backendcompiler.so
#4  0x00007fffefccb789 in boost::python::objects::caller_py_function_impl<boost::python::detail::caller<std::string (*)(backend::compiler&, backend::suite const&), boost::python::default_call_policies, boost::mpl::vector3<std::string, backend::compiler&, backend::suite const&> > >::operator()(_object*, _object*) ()
   from /usr/lib64/python2.7/site-packages/copperhead-0.2a2-py2.7.egg/copperhead/compiler/backendcompiler.so
#5  0x00007ffff68f5ceb in boost::python::objects::function::call(_object*, _object*) const ()
   from /usr/lib64/libboost_python.so.1.49.0
#6  0x00007ffff68f5f08 in ?? () from /usr/lib64/libboost_python.so.1.49.0
#7  0x00007ffff68fef2b in boost::python::handle_exception_impl(boost::function0<void>) ()
   from /usr/lib64/libboost_python.so.1.49.0
#8  0x00007ffff68f41c5 in ?? () from /usr/lib64/libboost_python.so.1.49.0
#9  0x00007ffff7a48a3e in PyObject_Call () from /usr/lib64/libpython2.7.so.1.0
#10 0x00007ffff7a56e80 in ?? () from /usr/lib64/libpython2.7.so.1.0
#11 0x00007ffff7a48a3e in PyObject_Call () from /usr/lib64/libpython2.7.so.1.0
#12 0x00007ffff7aac9fc in ?? () from /usr/lib64/libpython2.7.so.1.0
#13 0x00007ffff7a48a3e in PyObject_Call () from /usr/lib64/libpython2.7.so.1.0
#14 0x00007ffff7aebde9 in PyEval_EvalFrameEx () from /usr/lib64/libpython2.7.so.1.0
#15 0x00007ffff7aeffe9 in PyEval_EvalFrameEx () from /usr/lib64/libpython2.7.so.1.0
#16 0x00007ffff7aeffe9 in PyEval_EvalFrameEx () from /usr/lib64/libpython2.7.so.1.0
#17 0x00007ffff7af0b48 in PyEval_EvalCodeEx () from /usr/lib64/libpython2.7.so.1.0
#18 0x00007ffff7a73916 in ?? () from /usr/lib64/libpython2.7.so.1.0
#19 0x00007ffff7a48a3e in PyObject_Call () from /usr/lib64/libpython2.7.so.1.0
#20 0x00007ffff7a56e80 in ?? () from /usr/lib64/libpython2.7.so.1.0
#21 0x00007ffff7a48a3e in PyObject_Call () from /usr/lib64/libpython2.7.so.1.0
#22 0x00007ffff7aac9fc in ?? () from /usr/lib64/libpython2.7.so.1.0
#23 0x00007ffff7a48a3e in PyObject_Call () from /usr/lib64/libpython2.7.so.1.0
#24 0x00007ffff7aebde9 in PyEval_EvalFrameEx () from /usr/lib64/libpython2.7.so.1.0
#25 0x00007ffff7af0b48 in PyEval_EvalCodeEx () from /usr/lib64/libpython2.7.so.1.0
#26 0x00007ffff7a73916 in ?? () from /usr/lib64/libpython2.7.so.1.0
#27 0x00007ffff7a48a3e in PyObject_Call () from /usr/lib64/libpython2.7.so.1.0
#28 0x00007ffff7a56e80 in ?? () from /usr/lib64/libpython2.7.so.1.0
#29 0x00007ffff7a48a3e in PyObject_Call () from /usr/lib64/libpython2.7.so.1.0
#30 0x00007ffff7aac9fc in ?? () from /usr/lib64/libpython2.7.so.1.0
#31 0x00007ffff7a48a3e in PyObject_Call () from /usr/lib64/libpython2.7.so.1.0
#32 0x00007ffff7aebde9 in PyEval_EvalFrameEx () from /usr/lib64/libpython2.7.so.1.0
#33 0x00007ffff7aeffe9 in PyEval_EvalFrameEx () from /usr/lib64/libpython2.7.so.1.0
#34 0x00007ffff7af0b48 in PyEval_EvalCodeEx () from /usr/lib64/libpython2.7.so.1.0
#35 0x00007ffff7a73a27 in ?? () from /usr/lib64/libpython2.7.so.1.0
#36 0x00007ffff7a48a3e in PyObject_Call () from /usr/lib64/libpython2.7.so.1.0
#37 0x00007ffff7aeb481 in PyEval_EvalFrameEx () from /usr/lib64/libpython2.7.so.1.0
#38 0x00007ffff7af0b48 in PyEval_EvalCodeEx () from /usr/lib64/libpython2.7.so.1.0
#39 0x00007ffff7a73a27 in ?? () from /usr/lib64/libpython2.7.so.1.0
#40 0x00007ffff7a48a3e in PyObject_Call () from /usr/lib64/libpython2.7.so.1.0
#41 0x00007ffff7aeb481 in PyEval_EvalFrameEx () from /usr/lib64/libpython2.7.so.1.0
#42 0x00007ffff7aeffe9 in PyEval_EvalFrameEx () from /usr/lib64/libpython2.7.so.1.0
---Type <return> to continue, or q <return> to quit---
#43 0x00007ffff7af0b48 in PyEval_EvalCodeEx () from /usr/lib64/libpython2.7.so.1.0
#44 0x00007ffff7a73916 in ?? () from /usr/lib64/libpython2.7.so.1.0
#45 0x00007ffff7a48a3e in PyObject_Call () from /usr/lib64/libpython2.7.so.1.0
#46 0x00007ffff7a56e80 in ?? () from /usr/lib64/libpython2.7.so.1.0
#47 0x00007ffff7a48a3e in PyObject_Call () from /usr/lib64/libpython2.7.so.1.0
#48 0x00007ffff7a550d6 in ?? () from /usr/lib64/libpython2.7.so.1.0
#49 0x00007ffff7a48a3e in PyObject_Call () from /usr/lib64/libpython2.7.so.1.0
#50 0x00007ffff7aebde9 in PyEval_EvalFrameEx () from /usr/lib64/libpython2.7.so.1.0
#51 0x00007ffff7af0b48 in PyEval_EvalCodeEx () from /usr/lib64/libpython2.7.so.1.0
#52 0x00007ffff7af0c82 in PyEval_EvalCode () from /usr/lib64/libpython2.7.so.1.0
#53 0x00007ffff7b1238a in PyRun_FileExFlags () from /usr/lib64/libpython2.7.so.1.0
#54 0x00007ffff7b12dbb in PyRun_SimpleFileExFlags () from /usr/lib64/libpython2.7.so.1.0
#55 0x00007ffff7b284c2 in Py_Main () from /usr/lib64/libpython2.7.so.1.0
#56 0x00007ffff6d40a95 in __libc_start_main () from /lib64/libc.so.6
#57 0x0000000000400721 in _start ()

This is on a Slackware64 14.0 box running on a Geforce GTX 675m card with Cuda 5.0. I have been able to run the Cuda examples and samples without problems so far. My installation of copperhead went as follows:

  1. Install Thrust over Cuda 5.0 headers.
  2. Install Scons.
  3. Install numpy
  4. Enable GCC 4.6.3 (Slackware64 14.0 uses GCC 4.7 by default)
  5. Enable Cuda.
  6. Run python setup.py install

This all seemed to go through without too many problems once I installed the Thrust, numpy, and Scons dependencies. Running python setup.py test seems to run and no errors are reported, but the last line of output is 'running tests'.

After doing this, I note that the example given on the homepage, the sample programs (I ran black_scholes.py), and any of the tests give me the same segmentation violation. I have tried running the homepage sample, the black_scholes.py example, and the test_all.py program inside of tests/. Each of these gives the same sort of backtrace as above, but the black_scholes.py program is given above. I assume that I am correct in trying to run them by running python black_scholes.py and so on.

I am not a Python programmer, so I could be really messing something up here, but I would appreciate whatever assistance you could provide in setting this up.

Compile error related to boost

Processing /home/user/code_reference/copperhead
Complete output from command python setup.py egg_info:
Scanning installed packages
Setuptools installation detected at /home/user/code/env/lib/python2.7/site-packages
Non-egg installation
Could not locate setuptools*.egg-info
Downloading http://pypi.python.org/packages/source/d/distribute/distribute-0.6.4.tar.gz
Extracting in /tmp/tmpdajBlr
Now working in /tmp/tmpdajBlr/distribute-0.6.4
Building a Distribute egg in /tmp/pip-q06Tl7-build
Creating /tmp/pip-q06Tl7-build/setuptools-0.6c9-py2.7.egg-info
Creating /tmp/pip-q06Tl7-build/setuptools.pth
scons: Reading SConscript files ...

*************** siteconf.py not found ***************
We will try building anyway, but may not succeed.
Read the README for more details.

Checking g++ version... (cached) 6.2.0
Checking nvcc version... (cached) 8.0
Checking for C++ library cudart... yes
Checking for C++ library python2.7... yes
Checking for C++ library boost_python... yes
Checking for C++ header file thrust/host_vector.h... yes
Checking Thrust version...1.8.1
Checking for C++ header file tbb/tbb.h... no
********************* BACKEND SUPPORT *********************
CUDA backend: True
OpenMP backend: True
TBB backend: False
***********************************************************
Submodule 'backend' (git://github.com/copperhead/copperhead-compiler) registered for path 'backend'
Cloning into '/tmp/pip-q06Tl7-build/backend'...
Submodule path 'backend': checked out '11067c1d4bb1c850e88f9038782c41a6be3edd3c'
scons: done reading SConscript files.
scons: Building targets ...
g++ -o backend/build/allocate.os -c -O2 -Wall -O3 -std=c++0x -Wall -fPIC -DCUDA_SUPPORT -DOMP_SUPPORT -I/usr/local/cuda/include -Ibackend/inc backend/src/allocate.cpp
In file included from backend/inc/rewriter.hpp:146:0,
                 from backend/inc/allocate.hpp:27,
                 from backend/src/allocate.cpp:1:
backend/inc/rewriter.inl: In member function 'boost::static_visitor<std::shared_ptr<const backend::node> >::result_type backend::rewriter<Derived>::operator()(const backend::tuple&)':
backend/inc/rewriter.inl:67:47: error: call of overloaded 'move(std::vector<std::shared_ptr<const backend::expression> >&)' is ambiguous
     return result_type(new tuple(move(n_values), t, ct));
                                               ^
In file included from /usr/include/c++/6/bits/nested_exception.h:40:0,
                 from /usr/include/c++/6/exception:171,
                 from /usr/include/c++/6/new:40,
                 from /usr/include/boost/variant/variant.hpp:19,
                 from /usr/include/boost/variant.hpp:17,
                 from backend/inc/node.hpp:19,
                 from backend/inc/allocate.hpp:18,
                 from backend/src/allocate.cpp:1:
/usr/include/c++/6/bits/move.h:101:5: note: candidate: constexpr typename std::remove_reference< <template-parameter-1-1> >::type&& std::move(_Tp&&) [with _Tp = std::vector<std::shared_ptr<const backend::expression> >&; typename std::remove_reference< <template-parameter-1-1> >::type = std::vector<std::shared_ptr<const backend::expression> >]
     move(_Tp&& __t) noexcept
     ^~~~
In file included from /usr/include/boost/move/utility.hpp:29:0,
                 from /usr/include/boost/move/move.hpp:29,
                 from /usr/include/boost/variant/detail/move.hpp:28,
                 from /usr/include/boost/variant/detail/initializer.hpp:23,
                 from /usr/include/boost/variant/variant.hpp:30,
                 from /usr/include/boost/variant.hpp:17,
                 from backend/inc/node.hpp:19,
                 from backend/inc/allocate.hpp:18,
                 from backend/src/allocate.cpp:1:
/usr/include/boost/move/utility_core.hpp:212:93: note: candidate: typename boost::move_detail::remove_reference<T>::type&& boost::move(T&&) [with T = std::vector<std::shared_ptr<const backend::expression> >&; typename boost::move_detail::remove_reference<T>::type = std::vector<std::shared_ptr<const backend::expression> >]
          BOOST_MOVE_FORCEINLINE typename ::boost::move_detail::remove_reference<T>::type && move(T&& t) BOOST_NOEXCEPT
                                                                                             ^~~~
In file included from backend/inc/rewriter.hpp:146:0,
                 from backend/inc/allocate.hpp:27,
                 from backend/src/allocate.cpp:1:
backend/inc/rewriter.inl: In member function 'boost::static_visitor<std::shared_ptr<const backend::node> >::result_type backend::rewriter<Derived>::operator()(const backend::suite&)':
backend/inc/rewriter.inl:226:46: error: call of overloaded 'move(std::vector<std::shared_ptr<const backend::statement> >&)' is ambiguous
     return result_type(new suite(move(n_stmts)));
                                              ^
In file included from /usr/include/c++/6/bits/nested_exception.h:40:0,
                 from /usr/include/c++/6/exception:171,
                 from /usr/include/c++/6/new:40,
                 from /usr/include/boost/variant/variant.hpp:19,
                 from /usr/include/boost/variant.hpp:17,
                 from backend/inc/node.hpp:19,
                 from backend/inc/allocate.hpp:18,
                 from backend/src/allocate.cpp:1:
/usr/include/c++/6/bits/move.h:101:5: note: candidate: constexpr typename std::remove_reference< <template-parameter-1-1> >::type&& std::move(_Tp&&) [with _Tp = std::vector<std::shared_ptr<const backend::statement> >&; typename std::remove_reference< <template-parameter-1-1> >::type = std::vector<std::shared_ptr<const backend::statement> >]
     move(_Tp&& __t) noexcept
     ^~~~
In file included from /usr/include/boost/move/utility.hpp:29:0,
                 from /usr/include/boost/move/move.hpp:29,
                 from /usr/include/boost/variant/detail/move.hpp:28,
                 from /usr/include/boost/variant/detail/initializer.hpp:23,
                 from /usr/include/boost/variant/variant.hpp:30,
                 from /usr/include/boost/variant.hpp:17,
                 from backend/inc/node.hpp:19,
                 from backend/inc/allocate.hpp:18,
                 from backend/src/allocate.cpp:1:
/usr/include/boost/move/utility_core.hpp:212:93: note: candidate: typename boost::move_detail::remove_reference<T>::type&& boost::move(T&&) [with T = std::vector<std::shared_ptr<const backend::statement> >&; typename boost::move_detail::remove_reference<T>::type = std::vector<std::shared_ptr<const backend::statement> >]
          BOOST_MOVE_FORCEINLINE typename ::boost::move_detail::remove_reference<T>::type && move(T&& t) BOOST_NOEXCEPT
                                                                                             ^~~~
In file included from backend/inc/rewriter.hpp:146:0,
                 from backend/inc/allocate.hpp:27,
                 from backend/src/allocate.cpp:1:
backend/inc/rewriter.inl: In member function 'boost::static_visitor<std::shared_ptr<const backend::node> >::result_type backend::rewriter<Derived>::operator()(const backend::structure&)':
backend/inc/rewriter.inl:247:70: error: call of overloaded 'move(std::vector<std::shared_ptr<const backend::ctype::type_t> >&)' is ambiguous
     return result_type(new structure(n_id, n_stmts, move(new_typevars)));
                                                                      ^
In file included from /usr/include/c++/6/bits/nested_exception.h:40:0,
                 from /usr/include/c++/6/exception:171,
                 from /usr/include/c++/6/new:40,
                 from /usr/include/boost/variant/variant.hpp:19,
                 from /usr/include/boost/variant.hpp:17,
                 from backend/inc/node.hpp:19,
                 from backend/inc/allocate.hpp:18,
                 from backend/src/allocate.cpp:1:
/usr/include/c++/6/bits/move.h:101:5: note: candidate: constexpr typename std::remove_reference< <template-parameter-1-1> >::type&& std::move(_Tp&&) [with _Tp = std::vector<std::shared_ptr<const backend::ctype::type_t> >&; typename std::remove_reference< <template-parameter-1-1> >::type = std::vector<std::shared_ptr<const backend::ctype::type_t> >]
     move(_Tp&& __t) noexcept
     ^~~~
In file included from /usr/include/boost/move/utility.hpp:29:0,
                 from /usr/include/boost/move/move.hpp:29,
                 from /usr/include/boost/variant/detail/move.hpp:28,
                 from /usr/include/boost/variant/detail/initializer.hpp:23,
                 from /usr/include/boost/variant/variant.hpp:30,
                 from /usr/include/boost/variant.hpp:17,
                 from backend/inc/node.hpp:19,
                 from backend/inc/allocate.hpp:18,
                 from backend/src/allocate.cpp:1:
/usr/include/boost/move/utility_core.hpp:212:93: note: candidate: typename boost::move_detail::remove_reference<T>::type&& boost::move(T&&) [with T = std::vector<std::shared_ptr<const backend::ctype::type_t> >&; typename boost::move_detail::remove_reference<T>::type = std::vector<std::shared_ptr<const backend::ctype::type_t> >]
          BOOST_MOVE_FORCEINLINE typename ::boost::move_detail::remove_reference<T>::type && move(T&& t) BOOST_NOEXCEPT
                                                                                             ^~~~
backend/src/allocate.cpp: In member function 'std::shared_ptr<const backend::ctype::type_t> backend::allocate::container_type(const backend::ctype::type_t&)':
backend/src/allocate.cpp:52:22: error: call of overloaded 'move(std::vector<std::shared_ptr<const backend::ctype::type_t> >&)' is ambiguous
             move(subs));
                      ^
In file included from /usr/include/c++/6/bits/nested_exception.h:40:0,
                 from /usr/include/c++/6/exception:171,
                 from /usr/include/c++/6/new:40,
                 from /usr/include/boost/variant/variant.hpp:19,
                 from /usr/include/boost/variant.hpp:17,
                 from backend/inc/node.hpp:19,
                 from backend/inc/allocate.hpp:18,
                 from backend/src/allocate.cpp:1:
/usr/include/c++/6/bits/move.h:101:5: note: candidate: constexpr typename std::remove_reference< <template-parameter-1-1> >::type&& std::move(_Tp&&) [with _Tp = std::vector<std::shared_ptr<const backend::ctype::type_t> >&; typename std::remove_reference< <template-parameter-1-1> >::type = std::vector<std::shared_ptr<const backend::ctype::type_t> >]
     move(_Tp&& __t) noexcept
     ^~~~
In file included from /usr/include/boost/move/utility.hpp:29:0,
                 from /usr/include/boost/move/move.hpp:29,
                 from /usr/include/boost/variant/detail/move.hpp:28,
                 from /usr/include/boost/variant/detail/initializer.hpp:23,
                 from /usr/include/boost/variant/variant.hpp:30,
                 from /usr/include/boost/variant.hpp:17,
                 from backend/inc/node.hpp:19,
                 from backend/inc/allocate.hpp:18,
                 from backend/src/allocate.cpp:1:
/usr/include/boost/move/utility_core.hpp:212:93: note: candidate: typename boost::move_detail::remove_reference<T>::type&& boost::move(T&&) [with T = std::vector<std::shared_ptr<const backend::ctype::type_t> >&; typename boost::move_detail::remove_reference<T>::type = std::vector<std::shared_ptr<const backend::ctype::type_t> >]
          BOOST_MOVE_FORCEINLINE typename ::boost::move_detail::remove_reference<T>::type && move(T&& t) BOOST_NOEXCEPT
                                                                                             ^~~~
backend/src/allocate.cpp: In member function 'boost::static_visitor<std::shared_ptr<const backend::node> >::result_type backend::allocate::operator()(const backend::bind&)':
backend/src/allocate.cpp:145:51: error: call of overloaded 'move(std::vector<std::shared_ptr<const backend::statement> >&)' is ambiguous
         return make_shared<const suite>(move(stmts));
                                                   ^
In file included from /usr/include/c++/6/bits/nested_exception.h:40:0,
                 from /usr/include/c++/6/exception:171,
                 from /usr/include/c++/6/new:40,
                 from /usr/include/boost/variant/variant.hpp:19,
                 from /usr/include/boost/variant.hpp:17,
                 from backend/inc/node.hpp:19,
                 from backend/inc/allocate.hpp:18,
                 from backend/src/allocate.cpp:1:
/usr/include/c++/6/bits/move.h:101:5: note: candidate: constexpr typename std::remove_reference< <template-parameter-1-1> >::type&& std::move(_Tp&&) [with _Tp = std::vector<std::shared_ptr<const backend::statement> >&; typename std::remove_reference< <template-parameter-1-1> >::type = std::vector<std::shared_ptr<const backend::statement> >]
     move(_Tp&& __t) noexcept
     ^~~~
In file included from /usr/include/boost/move/utility.hpp:29:0,
                 from /usr/include/boost/move/move.hpp:29,
                 from /usr/include/boost/variant/detail/move.hpp:28,
                 from /usr/include/boost/variant/detail/initializer.hpp:23,
                 from /usr/include/boost/variant/variant.hpp:30,
                 from /usr/include/boost/variant.hpp:17,
                 from backend/inc/node.hpp:19,
                 from backend/inc/allocate.hpp:18,
                 from backend/src/allocate.cpp:1:
/usr/include/boost/move/utility_core.hpp:212:93: note: candidate: typename boost::move_detail::remove_reference<T>::type&& boost::move(T&&) [with T = std::vector<std::shared_ptr<const backend::statement> >&; typename boost::move_detail::remove_reference<T>::type = std::vector<std::shared_ptr<const backend::statement> >]
          BOOST_MOVE_FORCEINLINE typename ::boost::move_detail::remove_reference<T>::type && move(T&& t) BOOST_NOEXCEPT
                                                                                             ^~~~
scons: *** [backend/build/allocate.os] Error 1
scons: building terminated because of errors.
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/tmp/pip-q06Tl7-build/setup.py", line 40, in <module>
    raise CompileError("Error while building Python Extensions")
distutils.errors.CompileError: Error while building Python Extensions

----------------------------------------

Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-q06Tl7-build/

Cannot mix Long and Bool

The code below is a valid Python expression

sum(v) / float(len(v) - True)

but the similar code below does not compile:

@cutype("([Float], Bool) -> Float")
@cu
def cm2(v, sample):
    return sum(v) / float32(len(v) - sample)

IOError: Could not build the egg.

from distribute_setup import use_setuptools

$ python setup.py install
Scanning installed packages
Setuptools installation detected at /home/foxx00/Downloads/git/copperhead
Non-egg installation
Removing elements out of the way...
Already patched.
/home/foxx00/Downloads/git/copperhead/setuptools-0.6c9-py2.7.egg-info already patched.
Extracting in /tmp/tmpUEWY6Z
Now working in /tmp/tmpUEWY6Z/distribute-0.6.4
Building a Distribute egg in /home/foxx00/Downloads/git/copperhead
Traceback (most recent call last):
File "setup.py", line 142, in
scripts = scripts,
File "/usr/lib/python2.7/distutils/core.py", line 111, in setup
_setup_distribution = dist = klass(attrs)
File "/tmp/tmpUEWY6Z/distribute-0.6.4/setuptools/dist.py", line 224, in init
_Distribution.init(self,attrs)
File "/usr/lib/python2.7/distutils/dist.py", line 287, in init
self.finalize_options()
File "/tmp/tmpUEWY6Z/distribute-0.6.4/setuptools/dist.py", line 257, in finalize_options
ep.load()(self, ep.name, value)
File "/tmp/tmpUEWY6Z/distribute-0.6.4/pkg_resources.py", line 1922, in load
raise ImportError("%r has no %r attribute" % (entry,attr))
ImportError: <module 'setuptools.dist' from '/tmp/tmpUEWY6Z/distribute-0.6.4/setuptools/dist.py'> has no 'check_packages' attribute
/home/foxx00/Downloads/git/copperhead/setuptools-0.6c9-py2.7.egg-info already exists
Traceback (most recent call last):
File "setup.py", line 21, in
use_setuptools()
File "/home/foxx00/Downloads/git/copperhead/distribute_setup.py", line 139, in use_setuptools
return _do_download(version, download_base, to_dir, download_delay)
File "/home/foxx00/Downloads/git/copperhead/distribute_setup.py", line 120, in _do_download
egg = _build_egg(tarball, to_dir)
File "/home/foxx00/Downloads/git/copperhead/distribute_setup.py", line 112, in _build_egg
raise IOError('Could not build the egg.')
IOError: Could not build the egg.

Resolution:
Comment out lines 20, 21 and everything works fine.

AttributeError: 'float' object has no attribute '__name__'

Hi,

Can you please point me to how to fix it or at least where to begin and what reasons causing this? (thanks a lot in advance and all the best)

I was trying to run my blackscholes.py that i implemented from scratch different from original implementation. I use an array of numpy.float64 tuple values to compute results. However when I run it, copperhead gives me the following trace although python interpreter works perfectly:

Trying to read file (" inputs/in_4.txt ") content into a list ...

Now moving data into heterogeneous memory spaces using copperhead.cuarray ...

Stock prices computed:

Now computing CPU prices ...
CPU: [9.0956624056554016, 5.1448393856839623, 4.8148864021584643, 9.6919439520870583]
Time (sec): 0.000427961349487
Now computing CPU-OpenMP prices ...

ERROR during compilation in gather_source
def computeAll(optionDataCuarray):
return map(BlkSchlsEqEuroNoDiv, optionDataCuarray)

ERROR during compilation in frontend
def computeAll(optionDataCuarray):
return map(BlkSchlsEqEuroNoDiv, optionDataCuarray)
Traceback (most recent call last):
File "blackscholes.py", line 285, in
main()
File "blackscholes.py", line 266, in main
cpu_omp = computeAll(optionDataCuarray)
File "/usr/local/lib/python2.7/dist-packages/copperhead-0.2a2-py2.7.egg/copperhead/runtime/cufunction.py", line 58, in call
return P.execute(self, args, kwargs)
File "/usr/local/lib/python2.7/dist-packages/copperhead-0.2a2-py2.7.egg/copperhead/runtime/driver.py", line 57, in execute
return execute(self.tag(), cufn, _args, *_kwargs)
File "/usr/local/lib/python2.7/dist-packages/copperhead-0.2a2-py2.7.egg/copperhead/runtime/driver.py", line 131, in execute
**k)
File "/usr/local/lib/python2.7/dist-packages/copperhead-0.2a2-py2.7.egg/copperhead/compiler/passes.py", line 292, in compile
return run_compilation(target, source, M)
File "/usr/local/lib/python2.7/dist-packages/copperhead-0.2a2-py2.7.egg/copperhead/compiler/passes.py", line 270, in run_compilation
return target(suite, M)
File "/usr/local/lib/python2.7/dist-packages/copperhead-0.2a2-py2.7.egg/copperhead/compiler/passes.py", line 91, in call
ast = P(ast, M)
File "/usr/local/lib/python2.7/dist-packages/copperhead-0.2a2-py2.7.egg/copperhead/compiler/passes.py", line 91, in call
ast = P(ast, M)
File "/usr/local/lib/python2.7/dist-packages/copperhead-0.2a2-py2.7.egg/copperhead/compiler/passes.py", line 130, in gather_source
return Front.gather_source(ast, M)
File "/usr/local/lib/python2.7/dist-packages/copperhead-0.2a2-py2.7.egg/copperhead/compiler/rewrites.py", line 104, in gather_source
gathered = gatherer.gather(stmt)
File "/usr/local/lib/python2.7/dist-packages/copperhead-0.2a2-py2.7.egg/copperhead/compiler/rewrites.py", line 62, in gather
self.clean.insert(0, self.rewrite(stmt))
File "/usr/local/lib/python2.7/dist-packages/copperhead-0.2a2-py2.7.egg/copperhead/compiler/coresyntax.py", line 394, in rewrite
return [self.rewrite(y) for y in x]
File "/usr/local/lib/python2.7/dist-packages/copperhead-0.2a2-py2.7.egg/copperhead/compiler/coresyntax.py", line 399, in rewrite
rewritten = fn(x_copy)
File "/usr/local/lib/python2.7/dist-packages/copperhead-0.2a2-py2.7.egg/copperhead/compiler/rewrites.py", line 71, in _Procedure
self.rewrite_children(proc)
File "/usr/local/lib/python2.7/dist-packages/copperhead-0.2a2-py2.7.egg/copperhead/compiler/coresyntax.py", line 384, in rewrite_children
x.parameters = self.rewrite(x.parameters)
File "/usr/local/lib/python2.7/dist-packages/copperhead-0.2a2-py2.7.egg/copperhead/compiler/coresyntax.py", line 394, in rewrite
return [self.rewrite(y) for y in x]
File "/usr/local/lib/python2.7/dist-packages/copperhead-0.2a2-py2.7.egg/copperhead/compiler/coresyntax.py", line 399, in rewrite
rewritten = fn(x_copy)
File "/usr/local/lib/python2.7/dist-packages/copperhead-0.2a2-py2.7.egg/copperhead/compiler/rewrites.py", line 82, in _Bind
self.rewrite_children(bind)
File "/usr/local/lib/python2.7/dist-packages/copperhead-0.2a2-py2.7.egg/copperhead/compiler/coresyntax.py", line 384, in rewrite_children
x.parameters = self.rewrite(x.parameters)
File "/usr/local/lib/python2.7/dist-packages/copperhead-0.2a2-py2.7.egg/copperhead/compiler/coresyntax.py", line 394, in rewrite
return [self.rewrite(y) for y in x]
File "/usr/local/lib/python2.7/dist-packages/copperhead-0.2a2-py2.7.egg/copperhead/compiler/coresyntax.py", line 399, in rewrite
rewritten = fn(x_copy)
File "/usr/local/lib/python2.7/dist-packages/copperhead-0.2a2-py2.7.egg/copperhead/compiler/coresyntax.py", line 406, in _default
return self.rewrite_children(x)
File "/usr/local/lib/python2.7/dist-packages/copperhead-0.2a2-py2.7.egg/copperhead/compiler/coresyntax.py", line 384, in rewrite_children
x.parameters = self.rewrite(x.parameters)
File "/usr/local/lib/python2.7/dist-packages/copperhead-0.2a2-py2.7.egg/copperhead/compiler/coresyntax.py", line 394, in rewrite
return [self.rewrite(y) for y in x]
File "/usr/local/lib/python2.7/dist-packages/copperhead-0.2a2-py2.7.egg/copperhead/compiler/coresyntax.py", line 399, in rewrite
rewritten = fn(x_copy)
File "/usr/local/lib/python2.7/dist-packages/copperhead-0.2a2-py2.7.egg/copperhead/compiler/rewrites.py", line 89, in _Name
if (fn.name in self.prelude_impl):
AttributeError: 'float' object has no attribute 'name'

OpenMP sort

sort does not work with the OpenMP backend. This may be a thrust issue, or it may be an issue in the way we use thrust::sort. In either case, the sort tests on OpenMP are currently disabled and should be reenabled once this issue is resolved.

[FIXED] some issues running tests (args not flattened and negative array ranges not working well?)

Hi
I was trying to run the copperhead tests and I have found that some of them do not run, I suppose mainly for 3 reasons:

  • some required functions in prelude.py are commented
  • nested function's formal arguments seems to be not flattened before line 725 of rewrite.py

[FIX] I think I fixed it by moving the name_tuples step before the inline one

diff --git a/copperhead/compiler/passes.py b/copperhead/compiler/passes.py
index 6d5fa29..672e5bd 100644
--- a/copperhead/compiler/passes.py
+++ b/copperhead/compiler/passes.py
@@ -243,6 +243,7 @@ frontend = Pipeline('frontend', [gather_source,
                                  procedure_flatten,
                                  expression_flatten,
                                  syntax_check,
+                                 name_tuples,    # FIX: moved here to avoid inline errors with nested argument lists
                                  inline,
                                  cast_literals,
  • [FIXED] there it seems to be an error in handling negative slices of arrays, e.g. test_rotate.py fails when the rotation is negative.
    This can be fixed by changing copperhead/prelude_impl.py by making the resulting index always positive
--- a/copperhead/prelude_impl.py
+++ b/copperhead/prelude_impl.py
@@ -88,7 +88,7 @@ def shift(x, a, d):
 @cu
 def rotate(x, a):
     def torus_index(i, a, b):
-        return (i + a) % b
+        return (i + a + b) % b       # FIX: to be sure that the resulting value is positive

     def rotate_el(i):
         return x[torus_index(i, a, len(x))]

All the best
AndreaS

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.