当前位置: 首页>>代码示例>>C++>>正文


C++ GlobalAddress类代码示例

本文整理汇总了C++中GlobalAddress的典型用法代码示例。如果您正苦于以下问题:C++ GlobalAddress类的具体用法?C++ GlobalAddress怎么用?C++ GlobalAddress使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了GlobalAddress类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: read

 T read(GlobalAddress<T> target) {
   delegate_reads++;
   return call<S,C>(target.core(), [target]() -> T {
     delegate_read_targets++;
     return *target.pointer();
   });
 }
开发者ID:kawuum,项目名称:grappa,代码行数:7,代码来源:Delegate.hpp

示例2: CHECK

bool GlobalQueue<T>::push( GlobalAddress<T> chunk_base, uint64_t chunk_amount ) {
  CHECK( initialized );
  DVLOG(5) << "push() base:" << chunk_base << " amount:" << chunk_amount;

  GlobalAddress< QueueEntry<T> > loc = Grappa_delegate_func< bool, GlobalAddress< QueueEntry<T> >, GlobalQueue<T>::push_reserve_g > ( false, HOME_NODE );
  size_t msg_bytes = Grappa_sizeof_delegate_func_request< bool, GlobalAddress< QueueEntry<T> > >( );

  DVLOG(5) << "push() reserve done -- loc:" << loc;

  if ( loc.pointer() == NULL ) {
    Grappa::Metrics::global_queue_stats.record_push_reserve_request( msg_bytes, false );
    // no space in global queue; push failed
    return false;
  }

  Grappa::Metrics::global_queue_stats.record_push_reserve_request( msg_bytes, true );

  // push the queue entry that points to my chunk 
  ChunkInfo<T> c;
  c.base = chunk_base;
  c.amount = chunk_amount;
  push_entry_args<T> entry_args;
  entry_args.target = loc;
  entry_args.chunk = c;
  DVLOG(5) << "push() sending entry to " << loc;
  bool had_sleeper = Grappa_delegate_func< push_entry_args<T>, bool, GlobalQueue<T>::push_entry_g > ( entry_args, loc.core() ); 
  size_t entry_msg_bytes = Grappa_sizeof_delegate_func_request< push_entry_args<T>, bool >( );
  Grappa::Metrics::global_queue_stats.record_push_entry_request( entry_msg_bytes, had_sleeper );

  return true;
}
开发者ID:kawuum,项目名称:grappa,代码行数:31,代码来源:GlobalQueue.hpp

示例3: update

    void update( K key, UV val ) {
      uint64_t index = computeIndex( key );
      GlobalAddress< Cell > target = base + index; 

      Grappa::delegate::call( target.core(), [key, val, target]() {   // TODO: upgrade to call_async; using GCE
        // list of entries in this cell
        std::list<DHT_TYPE(Entry)> * entries = target.pointer()->entries;

        // if first time the cell is hit then initialize
        if ( entries == NULL ) {
          entries = new std::list<Entry>();
          target.pointer()->entries = entries;
        }

        // find matching key in the list
        typename std::list<DHT_TYPE(Entry)>::iterator i;
        for (i = entries->begin(); i!=entries->end(); ++i) {
          if ( i->key == key ) {
            // key found so update
            i->value = UpF(i->value, val);
            hash_tables_size+=1;
            return 0;
          }
        }

        // this is the first time the key has been seen
        // so add it to the list
        Entry newe( key, UpF(Init, val));

        return 0; 
      });
    }
开发者ID:HPCProjectsTry,项目名称:grappa,代码行数:32,代码来源:DHT.hpp

示例4: readFF

 T readFF(GlobalAddress<FullEmpty<T>> fe_addr) {
   if (fe_addr.core() == mycore()) {
     DVLOG(2) << "local";
     return fe_addr.pointer()->readFF();
   }
   
   FullEmpty<T> result;
   auto result_addr = make_global(&result);
   
   send_message(fe_addr.core(), [fe_addr,result_addr]{
     auto& fe = *fe_addr.pointer();
     
     if (fe.full()) {
       // DVLOG(2) << "no need to block";
       fill_remote(result_addr, fe.readFF());
       return;
     }
     
     DVLOG(2) << "setting up to block (" << fe_addr << ")";
     auto* c = SuspendedDelegate::create([&fe,result_addr]{
       VLOG(0) << "suspended_delegate!";
       fill_remote(result_addr, fe.readFF());
     });
     add_waiter(&fe, c);
   });
   
   return result.readFF();
 }
开发者ID:HPCProjectsTry,项目名称:grappa,代码行数:28,代码来源:FullEmpty.hpp

示例5: increment

 void increment(GlobalAddress<T> target, U inc) {
   static_assert(std::is_convertible<T,U>(), "type of inc must match GlobalAddress type");
   delegate_async_increments++;
   delegate::call<SyncMode::Async,C>(target.core(), [target,inc]{
     (*target.pointer()) += inc;
   });
 }
开发者ID:kawuum,项目名称:grappa,代码行数:7,代码来源:Delegate.hpp

示例6: lock

 inline void lock( GlobalAddress<Mutex> m ) {
   // if local, just acquire
   if( m.core() == mycore() ) {
     lock( m.pointer() );
   } else { // if remote, spawn a task on the home node to acquire 
     CHECK(false);
   }
 }
开发者ID:HPCProjectsTry,项目名称:grappa,代码行数:8,代码来源:Mutex.hpp

示例7: write

 void write(GlobalAddress<T> target, U value) {
   static_assert(std::is_convertible<T,U>(), "type of value must match GlobalAddress type");
   delegate_writes++;
   // TODO: don't return any val, requires changes to `delegate::call()`.
   return call<S,C>(target.core(), [target, value] {
     delegate_write_targets++;
     *target.pointer() = value;
   });
 }
开发者ID:kawuum,项目名称:grappa,代码行数:9,代码来源:Delegate.hpp

示例8: fetch_and_add

 T fetch_and_add(GlobalAddress<T> target, U inc) {
   delegate_fetchadds++;
   return call(target.core(), [target, inc]() -> T {
     delegate_fetchadd_targets++;
     T* p = target.pointer();
     T r = *p;
     *p += inc;
     return r;
   });
 }
开发者ID:kawuum,项目名称:grappa,代码行数:10,代码来源:Delegate.hpp

示例9: remote_malloc

 /// delegate malloc
 static GlobalAddress< void > remote_malloc( size_t size_bytes ) {
   // ask node 0 to allocate memory
   auto allocated_address = Grappa::impl::call( 0, [size_bytes] {
       DVLOG(5) << "got malloc request for size " << size_bytes;
       GlobalAddress< void > a = global_allocator->local_malloc( size_bytes );
       DVLOG(5) << "malloc returning pointer " << a.pointer();
       return a;
     });
   return allocated_address;
 }
开发者ID:gfarnadi,项目名称:grappa,代码行数:11,代码来源:GlobalAllocator.hpp

示例10: NullAcquirer

 NullAcquirer(GlobalAddress<T> * request_address, size_t * count, T** pointer)
 : request_address_(request_address), count_(count), pointer_(pointer)
 {
   VLOG(6) << "pointer = " << pointer << ", pointer_ = " << pointer_;
   if( count == 0 ) {
     DVLOG(5) << "Zero-length acquire";
     *pointer_ = NULL;
   } else if( request_address_->is_2D() && request_address_->core() == Grappa::mycore() ) {
     DVLOG(5) << "Short-circuiting to address " << request_address_->pointer();
     *pointer_ = request_address_->pointer();
   }
 }
开发者ID:HPCProjectsTry,项目名称:grappa,代码行数:12,代码来源:Cache.hpp

示例11: lookup

    void lookup ( K key, CF f ) {
      uint64_t index = computeIndex( key );
      GlobalAddress< Cell > target = base + index; 

      // FIXME: remove 'this' capture when using gcc4.8, this is just a bug in 4.7
      //TODO optimization where only need to do remotePrivateTask instead of call_async
      //if you are going to do more suspending ops (comms) inside the loop
      Grappa::spawnRemote<GCE>( target.core(), [key, target, f, this]() {
        Entry e;
        if (lookup_local( key, target.pointer(), &e)) {
          f(e.value);
        }
      });
    }
开发者ID:HPCProjectsTry,项目名称:grappa,代码行数:14,代码来源:DHT.hpp

示例12: compare_and_swap

 bool compare_and_swap(GlobalAddress<T> target, U cmp_val, V new_val) {
   static_assert(std::is_convertible<T,U>(), "type of cmp_val must match GlobalAddress type");
   static_assert(std::is_convertible<T,V>(), "type of new_val must match GlobalAddress type");
   
   delegate_cmpswaps++;
   return call(target.core(), [target, cmp_val, new_val]() -> bool {
     T * p = target.pointer();
     delegate_cmpswap_targets++;
     if (cmp_val == *p) {
       *p = new_val;
       return true;
     } else {
       return false;
     }
   });
 }
开发者ID:kawuum,项目名称:grappa,代码行数:16,代码来源:Delegate.hpp

示例13: perf_test

double perf_test(GlobalAddress<GlobalVector<int64_t>> qa) {
  double t = Grappa::walltime();
  
  forall(0, FLAGS_nelems, [qa](int64_t i){
    if (EXP == Exp::QUEUE) {
      
      if (choose_random(FLAGS_fraction_push)) {
        qa->push(next_random<int64_t>());
      } else {
        qa->dequeue();
      }
      
    } else if (EXP == Exp::STACK) {
      
      if (choose_random(FLAGS_fraction_push)) {
        qa->push(next_random<int64_t>());
      } else {
        // qa->pop();
        CHECK_GT(qa->pop(), -1);
      }
      
    } else if (EXP == Exp::PUSH) {
      qa->push(next_random<int64_t>());
    } else if (EXP == Exp::POP) {
      qa->pop();
    } else if (EXP == Exp::DEQUEUE) {
      qa->dequeue();
    }
  });
  
  t = Grappa::walltime() - t;
  return t;
}
开发者ID:HTOKORG,项目名称:grappa,代码行数:33,代码来源:GlobalVector_tests.cpp

示例14: reduce

   T reduce( GlobalAddress<T> localizable ) {
     CompletionEvent ce(cores() - 1); 

     T total = *(localizable.localize());
     Core origin = mycore();

     for (Core c=0; c<cores(); c++) {
      if (c != origin) {
        send_heap_message(c, [localizable, &ce, &total, origin]{
          T val = *(localizable.localize());
          send_heap_message(origin, [val,&ce,&total] {
            total = ReduceOp(total, val);
            ce.complete();
          });
        });
      }
     }
    ce.wait();
    return total;
   }
开发者ID:kawuum,项目名称:grappa,代码行数:20,代码来源:Collective.hpp

示例15: get_edge_weight

 static double get_edge_weight(GlobalAddress<G> g, int64_t i, int64_t j) {
   return delegate::call(g->vs+i, [=](Vertex& v){ 
       for (int k = 0; v.nadj; k++) {
         auto e = g->edge(v,k);
         if (e.id == j)
           return e->weight;
       }
       // we can not reach this, possibly better to throw exception
       return 0.0;
   });
 }
开发者ID:HPCProjectsTry,项目名称:grappa,代码行数:11,代码来源:sssp.hpp


注:本文中的GlobalAddress类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。