Example #1
0
 void run_threaded_string_sends_0(size_t length, size_t numthreads) {
   if (rmi.procid() == 1) {
     rmi.full_barrier();
     return;
   }
   timer ti;
   std::cout << numthreads << " threaded " << SEND_LIMIT_PRINT <<" sends, "
                                           << length << " bytes\n";
   ti.start();
   size_t numsends = SEND_LIMIT / (length * numthreads);
   size_t rd = rdtsc();
   thread_group thrgrp;
   for (size_t i = 0; i < numthreads; ++i) {
     thrgrp.launch(boost::bind(&teststruct::perform_string_sends_0, this, length, numsends));
   }
   thrgrp.join();
   size_t rd2 = rdtsc();
   std::cout << (rd2 - rd) / (numthreads * numsends)  << " cycles per call\n";
   double t1 = ti.current_time();
   rmi.dc().flush();
   double t2 = ti.current_time();
   rmi.full_barrier();
   double t3 = ti.current_time();
   print_res(t1,t2,t3);
 }
Example #2
0
    /**
     * Sets the newval to be the value associated with the key
     */
    void set(const KeyType &key, const ValueType &newval) {
        // who owns the data?
        const size_t hashvalue = hasher(key);
        const size_t owningmachine = hashvalue % rpc.numprocs();

        // if it is me, set it
        if (owningmachine == rpc.dc().procid()) {
            lock.lock();
            storage[hashvalue] = newval;
            lock.unlock();
        } else {
            rpc.remote_call(owningmachine,
                            &dht<KeyType,ValueType>::set,
                            key, newval);
        }
    }
Example #3
0
 void run_short_sends_0() {
   if (rmi.procid() == 1) {
     rmi.full_barrier();
     return;
   }
   timer ti;
   std::cout << "Single Threaded " << SEND_LIMIT_PRINT << " sends, 4 integer blocks\n";
   ti.start();
   size_t numsends = SEND_LIMIT / (sizeof(size_t) * 4);
   perform_short_sends_0(numsends);
   double t1 = ti.current_time();
   rmi.dc().flush();
   double t2 = ti.current_time();
   rmi.full_barrier();
   double t3 = ti.current_time();
   print_res(t1,t2,t3);
 }
Example #4
0
    /**
     * gets the value associated with a key.
     * Returns (true, Value) if the entry is available.
     * Returns (false, undefined) otherwise.
     */
    std::pair<bool, ValueType> get(const KeyType &key) const {
        // who owns the data?

        const size_t hashvalue = hasher(key);
        const size_t owningmachine = hashvalue % rpc.numprocs();
        std::pair<bool, ValueType> retval;
        // if it is me, we can return it
        if (owningmachine == rpc.dc().procid()) {

            lock.lock();
            typename storage_type::const_iterator iter = storage.find(hashvalue);
            retval.first = iter != storage.end();
            if (retval.first) retval.second = iter->second;
            lock.unlock();
        } else {
            retval = rpc.remote_request(owningmachine,
                                        &dht<KeyType,ValueType>::get,
                                        key);
        }
        return retval;
    }
Example #5
0
 void run_threaded_short_pod_sends_0(size_t numthreads) {
   if (rmi.procid() == 1) {
     rmi.full_barrier();
     return;
   }
   timer ti;
   std::cout << numthreads << " threaded "<< SEND_LIMIT_PRINT <<" POD sends, 4 integers\n";
   size_t numsends = SEND_LIMIT / (sizeof(size_t) * 4 * numthreads);
   ti.start();
   thread_group thrgrp;
   for (size_t i = 0; i < numthreads; ++i) {
     thrgrp.launch(boost::bind(&teststruct::perform_short_pod_sends_0, this, numsends));
   }
   thrgrp.join();
   double t1 = ti.current_time();
   rmi.dc().flush();
   double t2 = ti.current_time();
   rmi.full_barrier();
   double t3 = ti.current_time();
   print_res(t1,t2,t3);
 }
Example #6
0
 void run_string_sends_0(size_t length) {
   if (rmi.procid() == 1) {
     rmi.full_barrier();
     return;
   }
   timer ti;
   size_t numsends = SEND_LIMIT / (length);
   std::cout << "Single Threaded " << SEND_LIMIT_PRINT <<" sends, " << length << " bytes * "<< numsends <<  "\n";
   ti.start();
   size_t rd = rdtsc();
   perform_string_sends_0(length, numsends);
   size_t rd2 = rdtsc();
   std::cout << "Completed in: " << ti.current_time() << " seconds\n";
   std::cout << (rd2 - rd) / numsends << " cycles per call\n";
   double t1 = ti.current_time();
   rmi.dc().flush();
   std::cout << "Flush in: " << ti.current_time() << " seconds\n";
   double t2 = ti.current_time();
   rmi.full_barrier();
   std::cout << "Receive Complete in: " << ti.current_time() << " seconds\n";
   double t3 = ti.current_time();
   print_res(t1,t2,t3);
 }
Example #7
0
 /**
  * Get the owner of the key
  */
 procid_t owner(const KeyType& key) const {
     return hasher(key) % rpc.dc().numprocs();
 }