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


C++ GlobalAddress::pointer方法代码示例

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


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

示例1: 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

示例2: 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

示例3: reset

  void reset( ) {
    DVLOG(5) << "In " << __PRETTY_FUNCTION__;
    CHECK( !acquire_started_ || acquired_ ) << "inconsistent state for reset";
    acquire_started_ = false;
    acquired_ = false;
    thread_ = NULL;
    num_messages_ = 0;
    response_count_ = 0;
    expected_reply_payload_ = sizeof( T ) * *count_;
    total_reply_payload_ = 0;
    start_time_ = 0;
    network_time_ = 0;
    if( *count_ == 0 ) {
      DVLOG(5) << "Zero-length acquire";
      *pointer_ = NULL;
      acquire_started_ = true;
      acquired_ = true;
    } else if( request_address_->is_2D() ) {
      num_messages_ = 1;
      if( request_address_->core() == Grappa::mycore() ) {
        DVLOG(5) << "Short-circuiting to address " << request_address_->pointer();
        *pointer_ = request_address_->pointer();
        acquire_started_ = true;
        acquired_ = true;
      }
    } else {
      DVLOG(5) << "Straddle: block_max is " << (*request_address_ + *count_).block_max() ;
      DVLOG(5) << ", request_address is " << *request_address_;
      DVLOG(5) << ", sizeof(T) is " << sizeof(T);
      DVLOG(5) << ", count is " << *count_;
      DVLOG(5) << ", block_min is " << request_address_->block_min();


      DVLOG(5) << "Straddle: address is " << *request_address_ ;
      DVLOG(5) << ", address + count is " << *request_address_ + *count_;

      ptrdiff_t byte_diff = ( (*request_address_ + *count_ - 1).last_byte().block_max() - 
                               request_address_->first_byte().block_min() );

      DVLOG(5) << "Straddle: address block max is " << request_address_->block_max();
      DVLOG(5) << " address + count block max is " << (*request_address_ + *count_).block_max();
      DVLOG(5) << " address block min " << request_address_->block_min();
      DVLOG(5) << "Straddle: diff is " << byte_diff << " bs " << block_size;
      num_messages_ = byte_diff / block_size;
    }

    if( num_messages_ > 1 ) DVLOG(5) << "****************************** MULTI BLOCK CACHE REQUEST ******************************";

    DVLOG(5) << "In " << __PRETTY_FUNCTION__ << "; detecting straddle for sizeof(T):" << sizeof(T)
             << " count:" << *count_
             << " num_messages_:" << num_messages_
             << " request_address:" << *request_address_;
  }
开发者ID:HPCProjectsTry,项目名称:grappa,代码行数:53,代码来源:IncoherentAcquirer.hpp

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: complete

 /// Overload to work on GlobalAddresses.
 // template<typename CompletionType>
 // inline void complete(GlobalAddress<CompletionType> ce, int64_t decr = 1) {
   // static_assert(std::is_base_of<CompletionEvent,CompletionType>::value,
   //               "complete() can only be called on subclasses of CompletionEvent");
 inline void complete(GlobalAddress<CompletionEvent> ce, int64_t decr = 1) {
   DVLOG(5) << "complete CompletionEvent";
   if (ce.core() == mycore()) {
     ce.pointer()->complete(decr);
   } else {
     ce_remote_completions += decr;
     if (decr == 1) {
       // (common case) don't send full 8 bytes just to decrement by 1
       send_heap_message(ce.core(), [ce] {
         ce.pointer()->complete();
       });
     } else {
       send_heap_message(ce.core(), [ce,decr] {
         ce.pointer()->complete(decr);
       });
     }
   }
 }
开发者ID:kawuum,项目名称:grappa,代码行数:23,代码来源:CompletionEvent.hpp

示例10: 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

示例11: push

 void push(const T& o) {
     CHECK(target_array.pointer() != NULL) << "buffer not initialized!";
     buf[curr_buf][curr_size[curr_buf]] = o;
     curr_size[curr_buf]++;
     CHECK(curr_size[curr_buf] <= BUFSIZE);
     if (curr_size[curr_buf] == BUFSIZE) {
         flush();
     }
 }
开发者ID:qiuqiyuan,项目名称:grappa,代码行数:9,代码来源:PushBuffer.hpp

示例12: DVLOG

 /// 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

示例13: 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

示例14: 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

示例15: 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


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