Beispiel #1
0
static void led_temperature(int led_idx, char temp)
{
	unsigned char weights[3];

	weights[CLR_R] = t2r(temp);
	weights[CLR_G] = t2g(temp);
	weights[CLR_B] = t2b(temp);
	led_setup(led_idx, weights);
}
void Test2() {
    Harness::SpinBarrier barr(2);
    TestFunc2a func2a(barr);
    TestTask2a t2a(0, func2a);
    TestFunc2b func2b(barr, t2a);
    NativeParallelForTask<int,TestFunc2b> t2b(1, func2b);
    FinishedTasks = 0;
    t2a.start(); t2b.start();
    Harness::Sleep(1000); // wait a second :)
    ASSERT( FinishedTasks==2, "Threads appear to deadlock" );
    t2b.wait_to_finish(); // t2a is monitored by t2b
}
void Test2() {
    Harness::SpinBarrier barr(2);
    TestFunc2a func2a(barr);
    TestTask2a t2a(0, func2a);
    TestFunc2b func2b(barr, t2a);
#if USE_LITHE
    tbb::lithe::scheduler sched;
    lithe_sched_enter(&sched);
#endif
    NativeParallelForTask<int,TestFunc2b> t2b(1, func2b);
    FinishedTasks = 0;
    t2a.start(); t2b.start();
#if USE_LITHE
    sched.joinAll();
    lithe_sched_exit();
#else
    Harness::Sleep(1000); // wait a second :)
#endif
    ASSERT( FinishedTasks==2, "Threads appear to deadlock" );
    t2b.wait_to_finish(); // t2a is monitored by t2b
}
Beispiel #4
0
void
test_constructors()
{
    cout << "test_constructors" << endl;

    sc_time t1;
    cout << t1 << endl;

    sc_time t2a( 0, SC_SEC );
    cout << t2a << endl;

    sc_time t2b( 1.2345, SC_NS );
    cout << t2b << endl;
    sc_time t2c( 1.2341, SC_NS );
    cout << t2c << endl;

    sc_time t2d( 1, SC_FS );
    cout << t2d << endl;

    sc_time t2e( -1.2345, SC_NS );
    cout << t2e << endl;
    sc_time t2f( -1.2341, SC_NS );
    cout << t2f << endl;

    char v1 = 1;
    signed char v2 = 2;
    unsigned char v3 = 3;
    short v4 = 4;
    unsigned short v5 = 5;
    int v6 = 6;
    unsigned int v7 = 7;
    long v8 = 8;
    unsigned long v9 = 9;
    float v10 = 10;
    double v11 = 11;

    sc_time t2g( v1, SC_NS );
    cout << t2g << endl;
    sc_time t2h( v2, SC_NS );
    cout << t2h << endl;
    sc_time t2i( v3, SC_NS );
    cout << t2i << endl;
    sc_time t2j( v4, SC_NS );
    cout << t2j << endl;
    sc_time t2k( v5, SC_NS );
    cout << t2k << endl;
    sc_time t2l( v6, SC_NS );
    cout << t2l << endl;
    sc_time t2m( v7, SC_NS );
    cout << t2m << endl;
    sc_time t2n( v8, SC_NS );
    cout << t2n << endl;
    sc_time t2o( v9, SC_NS );
    cout << t2o << endl;
    sc_time t2p( v10, SC_NS );
    cout << t2p << endl;
    sc_time t2q( v11, SC_NS );
    cout << t2q << endl;

    sc_time t3a( 0, SC_SEC );
    cout << t3a << endl;

    sc_time t3b( 1.2341, true );
    cout << t3b << endl;
    sc_time t3c( 1.2345, true );
    cout << t3c << endl;
    sc_time t3d( -1.2341, true );
    cout << t3d << endl;
    sc_time t3e( -1.2345, true );
    cout << t3e << endl;

    sc_time t3f( 1.2345, false );
    cout << t3f << endl;
    sc_time t3g( 1.5432, false );
    cout << t3g << endl;
    sc_time t3h( -1.2345, false );
    cout << t3h << endl;
    sc_time t3i( -1.5432, false );
    cout << t3i << endl;

#if !defined( _MSC_VER )
    sc_time t4a( 0ull, true );
    cout << t4a << endl;
    sc_time t4b( 25ull, true );
    cout << t4b << endl;
    sc_time t4c( 25ull, false );
    cout << t4c << endl;
#else
    sc_time t4a( 0ui64, true );
    cout << t4a << endl;
    sc_time t4b( 25ui64, true );
    cout << t4b << endl;
    sc_time t4c( 25ui64, false );
    cout << t4c << endl;
#endif

    sc_time t5( t4c );
    cout << t5 << endl;
}
Beispiel #5
0
int main()
{
   std::tr1::tuple<int> t1a;
   std::tr1::tuple<int> t1b(0);
   std::tr1::tuple<int> t1c(t1b);
   t1a = t1c;
   std::tr1::tuple<int> t1d(std::tr1::tuple<short>(0));
   t1a = std::tr1::tuple<short>(0);

   std::tr1::tuple<int, long> t2a;
   std::tr1::tuple<int, long> t2b(0, 0);
   std::tr1::tuple<int, long> t2c(t2b);
   t2a = t2c;
   std::tr1::tuple<int, long> t2d(std::tr1::tuple<short, int>(0, 0));
   t2a = std::tr1::tuple<short, int>(0, 0);
   //std::tr1::tuple<int, long> t2e(std::make_pair(0, 0L));
   //t2e = std::make_pair(0, 0L);
  
   // check implementation limits:
   std::tr1::tuple<int, long, float, int, int, int, int, int, int> t10(0, 0, 0, 0, 0, 0, 0, 0, 0);

   // make_tuple:
   verify_return_type(std::tr1::make_tuple(0, 0, 0L), std::tr1::tuple<int, int, long>());
   int i = 0;
   std::tr1::tuple<int&, int, long> t3a(std::tr1::make_tuple(std::tr1::ref(i), 0, 0L));
   verify_return_type(std::tr1::make_tuple(std::tr1::ref(i), 0, 0L), t3a);
   std::tr1::tuple<const int&, int, long> t3b(std::tr1::make_tuple(std::tr1::cref(i), 0, 0L));
   verify_return_type(std::tr1::make_tuple(std::tr1::cref(i), 0, 0L), t3b);
   long j = 0;
   std::tr1::tuple<int&, long&> tt(std::tr1::tie(i,j));

   BOOST_STATIC_ASSERT((::std::tr1::tuple_size<std::tr1::tuple<int, long> >::value == 2));
   BOOST_STATIC_ASSERT((::std::tr1::tuple_size<std::tr1::tuple<int, long, float, int, int, int, int, int, int> >::value == 9));

   BOOST_STATIC_ASSERT((::boost::is_same< ::std::tr1::tuple_element<0, std::tr1::tuple<int, long> >::type, int>::value));
   BOOST_STATIC_ASSERT((::boost::is_same< ::std::tr1::tuple_element<1, std::tr1::tuple<int, long> >::type, long>::value));
   BOOST_STATIC_ASSERT((::boost::is_same< ::std::tr1::tuple_element<0, std::tr1::tuple<int&, long> >::type, int&>::value));
   BOOST_STATIC_ASSERT((::boost::is_same< ::std::tr1::tuple_element<0, std::tr1::tuple<const int&, long> >::type, const int&>::value));

   // get:
   verify_return_type(&::std::tr1::get<0>(t1a), static_cast<int*>(0));
   verify_return_type(&::std::tr1::get<1>(t2d), static_cast<long*>(0));
   verify_return_type(&::std::tr1::get<0>(t3a), static_cast<int*>(0));
   verify_return_type(&::std::tr1::get<0>(t3b), static_cast<const int*>(0));
   const std::tr1::tuple<int>& cr1 = t1a;
   verify_return_type(&::std::tr1::get<0>(cr1), static_cast<const int*>(0));
   const std::tr1::tuple<int&, int, long>& cr2 = t3a;
   verify_return_type(&::std::tr1::get<0>(cr2), static_cast<int*>(0));
   const std::tr1::tuple<const int&, int, long>& cr3 = t3b;
   // comparison:
   verify_return_type(cr2 == cr3, false);
   verify_return_type(cr2 != cr3, false);
   verify_return_type(cr2 < cr3, false);
   verify_return_type(cr2 > cr3, false);
   verify_return_type(cr2 <= cr3, false);
   verify_return_type(cr2 >= cr3, false);

   // pair interface:
   BOOST_STATIC_ASSERT((::std::tr1::tuple_size<std::pair<int, long> >::value == 2));
   BOOST_STATIC_ASSERT((::std::tr1::tuple_size<std::pair<int, float> >::value == 2));
   BOOST_STATIC_ASSERT((::boost::is_same< ::std::tr1::tuple_element<0, std::pair<int, long> >::type, int>::value));
   BOOST_STATIC_ASSERT((::boost::is_same< ::std::tr1::tuple_element<1, std::pair<int, long> >::type, long>::value));

   std::pair<int, long> p1;
   const std::pair<int, long>& p2 = p1;
   verify_return_type(&std::tr1::get<0>(p1), static_cast<int*>(0));
   verify_return_type(&std::tr1::get<1>(p1), static_cast<long*>(0));
   verify_return_type(&std::tr1::get<0>(p2), static_cast<const int*>(0));
   verify_return_type(&std::tr1::get<1>(p2), static_cast<const long*>(0));

   return 0;
}
Beispiel #6
0
int main(int argc, char * const argv[])
{
        int opt_index, c;
        static struct option long_opts[] = {
                {"target", 1, 0, 0},
                {"dumpfile", 1, 0, 0},
                {"ssh", 1, 0, 0},
                {0, 0, 0, 0}
        };

        if (argc < 4 - (getenv(ENV_LUSTRE_MNTTGT)||getenv(ENV_LUSTRE_DUMPFILE)))
                usage(argv[0]);

        while ((c = getopt_long(argc, argv, "s:b:f:", long_opts, &opt_index)) != -1) {
                switch (c) {
                case 0: {
                        if (!optarg[0])
                                usage(argv[0]);

                        if (!strcmp(long_opts[opt_index].name, "target")) {
                                setenv(ENV_LUSTRE_MNTTGT, optarg, 1);
                        } else if (!strcmp(long_opts[opt_index].name, "dumpfile")) {
                                setenv(ENV_LUSTRE_DUMPFILE, optarg, 1);
                        } else if (!strcmp(long_opts[opt_index].name, "ssh")) {
                                safe_strncpy(ssh_cmd, optarg, MAX_STRING_SIZE);
                        } else
                                usage(argv[0]);
                        break;
                }
                case 's':
                        safe_strncpy(mds_server, optarg, MAX_STRING_SIZE);
                        break;
                case 'b':
                        safe_strncpy(barrier_script, optarg, MAX_STRING_SIZE);
                        break;
                case 'f':
                        safe_strncpy(failover_script, optarg, MAX_STRING_SIZE);
                        break;
                default:
                        usage(argv[0]);
                }
        }

        if (optind != argc)
                usage(argv[0]);
        if (!strlen(mds_server) || !strlen(barrier_script) ||
            !strlen(failover_script))
                usage(argv[0]);

        /* default to using ssh */
        if (!strlen(ssh_cmd)) {
                safe_strncpy(ssh_cmd, "ssh", MAX_STRING_SIZE);
        }

        test_ssh();

        /* prepare remote command */
        sprintf(barrier_cmd, "%s %s \"%s\"", 
                ssh_cmd, mds_server, barrier_script);
        sprintf(failover_cmd, "%s %s \"%s\"", 
                ssh_cmd, mds_server, failover_script);

        setenv(ENV_LUSTRE_TIMEOUT, "10", 1);

        __liblustre_setup_();

        t0();
        t1();
        t2a();
        t2b();
        t3a();
        t3b();
        t4();
        t5();
        t6();
        t7();
        t8();
        t9();
        t10();

	printf("liblustre is about shutdown\n");
        __liblustre_cleanup_();

	printf("complete successfully\n");
	return 0;
}