Esempio n. 1
0
        static void Main(string[] args)
        {
            {
                DVVector dIn  = new DVVector(new int[] { 10, 20, 30, 40, 50, 60, 70, 80 });
                DVVector dOut = new DVVector("int32_t", 8);
                TRTC.Copy(dIn, dOut);
                print_array((int[])dOut.to_host());
            }

            Functor is_even = new Functor(new string[] { "x" }, "        return x % 2 == 0;\n");

            {
                DVVector dIn   = new DVVector(new int[] { -2, 0, -1, 0, 1, 2 });
                DVVector dOut  = new DVVector("int32_t", 6);
                long     count = TRTC.Copy_If(dIn, dOut, is_even);
                print_array((int[])dOut.to_host(0, count));
            }

            {
                DVVector dIn      = new DVVector(new int[] { 0, 1, 2, 3, 4, 5 });
                DVVector dStencil = new DVVector(new int[] { -2, 0, -1, 0, 1, 2 });
                DVVector dOut     = new DVVector("int32_t", 6);
                long     count    = TRTC.Copy_If_Stencil(dIn, dStencil, dOut, is_even);
                print_array((int[])dOut.to_host(0, count));
            }
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            DVCounter src = new DVCounter(new DVInt32(1), 10);
            DVVector  dst = new DVVector("int32_t", 10);

            TRTC.Copy(src, dst);
            print_array((int[])dst.to_host());
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            DVVector  dvalues = new DVVector(new int[] { 3, 7, 2, 5 });
            DVReverse src     = new DVReverse(dvalues);
            DVVector  dst     = new DVVector("int32_t", 4);

            TRTC.Copy(src, dst);
            print_array((int[])dst.to_host());
        }
Esempio n. 4
0
        static void Main(string[] args)
        {
            TRTC.Set_Verbose();

            // just to verify that it compiles
            DVCounter src  = new DVCounter(new DVInt32(5), 10);
            DVDiscard sink = new DVDiscard("int32_t");

            TRTC.Copy(src, sink);
        }
Esempio n. 5
0
        static void Main(string[] args)
        {
            DVVector      dvalues  = new DVVector(new float[] { 10.0f, 20.0f, 30.0f, 40.0f, 50.0f, 60.0f, 70.0f, 80.0f });
            DVVector      dindices = new DVVector(new int[] { 2, 6, 1, 3 });
            DVPermutation src      = new DVPermutation(dvalues, dindices);
            DVVector      dst      = new DVVector("float", 4);

            TRTC.Copy(src, dst);
            print_array((float[])dst.to_host());
        }
Esempio n. 6
0
        static void Main(string[] args)
        {
            DVVector       d_in = new DVVector(new int[] { 0, 1, 2, 3, 4 });
            DVCustomVector src  = new DVCustomVector(new DeviceViewable[] { d_in }, new string[] { "src" }, "idx",
                                                     "        return src[idx % src.size()];\n", "int32_t", d_in.size() * 5);
            DVVector dst = new DVVector("int32_t", 25);

            TRTC.Copy(src, dst);
            print_array((int[])dst.to_host());
        }
        static void Main(string[] args)
        {
            DVVector    dvalues     = new DVVector(new float[] { 1.0f, 4.0f, 9.0f, 16.0f });
            Functor     square_root = new Functor(new string[] { "x" }, "        return sqrtf(x);\n");
            DVTransform src         = new DVTransform(dvalues, "float", square_root);
            DVVector    dst         = new DVVector("float", 4);

            TRTC.Copy(src, dst);
            print_array((float[])dst.to_host());
        }
Esempio n. 8
0
        static void Main(string[] args)
        {
            DVVector d_int_in   = new DVVector(new int[] { 0, 1, 2, 3, 4 });
            DVVector d_float_in = new DVVector(new float[] { 0.0f, 10.0f, 20.0f, 30.0f, 40.0f });

            DVVector d_int_out   = new DVVector("int32_t", 5);
            DVVector d_float_out = new DVVector("float", 5);

            DVZipped src = new DVZipped(new DVVectorLike[] { d_int_in, d_float_in }, new string[] { "a", "b" });
            DVZipped dst = new DVZipped(new DVVectorLike[] { d_int_out, d_float_out }, new string[] { "a", "b" });

            TRTC.Copy(src, dst);

            print_array((int[])d_int_out.to_host());
            print_array((float[])d_float_out.to_host());
        }