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


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

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


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

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

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

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

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

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

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

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

  void reset( ) {
    CHECK( !release_started_ || released_ ) << "inconsistent state for reset";
    release_started_ = false;
    released_ = false;
    thread_ = NULL;
    num_messages_ = 0;
    response_count_ = 0;
    if( *count_ == 0 ) {
      DVLOG(5) << "Zero-length release";
      release_started_ = true;
      released_ = true;
    } else if( request_address_->is_2D() ) {
      num_messages_ = 1;
      if( request_address_->core() == Grappa::mycore() ) {
        release_started_ = true;
        released_ = 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 + count -1 block max is " << (*request_address_ + *count_ - 1).block_max();
      DVLOG(5) << " difference is " << ( (*request_address_ + *count_ - 1).block_max() - request_address_->block_min() );
      DVLOG(5) << " multiplied difference is " << ( (*request_address_ + *count_ - 1).block_max() - request_address_->block_min() ) * sizeof(T);
      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) << "Detecting straddle for sizeof(T):" << sizeof(T)
             << " count:" << *count_
             << " num_messages_:" << num_messages_
             << " request_address:" << *request_address_;
  }
开发者ID:HTOKORG,项目名称:grappa,代码行数:48,代码来源:IncoherentReleaser.hpp

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

示例14: bucket_sort

void bucket_sort(GlobalAddress<S> array, size_t nelems, int (*Scmp)(const void*,const void*), size_t (*lobits)(S,int), int log2buckets, int log2maxkey ) {
  double t, sort_time, histogram_time, allreduce_time, scatter_time, local_sort_scatter_time, put_back_time;

  int LOBITS = log2maxkey - log2buckets;
  size_t nbuckets = 1 << log2buckets;

  GlobalAddress<bucket_t<S> > bucketlist = Grappa::global_alloc<bucket_t<S> >(nbuckets);

#ifdef DEBUG
  for (size_t i=0; i<nbuckets; i++) {
    GlobalAddress<bucket_t<S> > bi = bucketlist+i;
    VLOG(1) << "bucket[" << i << "] on Node " << bi.core() << ", offset = " << bi.pointer() - bucketlist.localize(bi.core()) << ", ptr = " << bi.pointer();
  }
#endif

  sort_time = Grappa::walltime();

  // initialize globals and histogram counts
  // { setup_counts f(array, nbuckets, bucketlist); fork_join_custom(&f); }
  on_all_cores([nbuckets]{
    counts.resize(nbuckets);
    offsets.resize(nbuckets);
    for (size_t i=0; i<nbuckets; i++) {
      counts[i] = 0;
    }
  });

  t = Grappa::walltime();

  // do local bucket counts
  // forall_local<uint64_t,histogram>(array, nelems);
  forall(array, nelems, [lobits,LOBITS](int64_t i, S& v) {
    size_t b = lobits(v, LOBITS); // TODO decide how to compare general in pieces
    counts[b]++;
  });

  histogram_time = Grappa::walltime() - t;
  LOG(INFO) << "histogram_time: " << histogram_time;
  t = Grappa::walltime();

  // allreduce everyone's counts & compute global offsets (prefix sum)
  // { aggregate_counts f; fork_join_custom(&f); }
  on_all_cores([nbuckets] {
    CHECK_EQ(nbuckets, counts.size());
    // all nodes get total counts put into their counts array
    allreduce_inplace<size_t,collective_add>(&counts[0], counts.size());

    VLOG(1) << "after allreduce_inplace (just in case)";

    // everyone computes prefix sum over buckets locally
    offsets[0] = 0;
    for (size_t i=1; i<offsets.size(); i++) {
      offsets[i] = offsets[i-1] + counts[i-1];
    }
  });
  
  allreduce_time = Grappa::walltime() - t;
  LOG(INFO) << "allreduce_time: " << allreduce_time;

  // allocate space in buckets
  VLOG(3) << "allocating space...";
  // forall_local<bucket_t,init_buckets>(bucketlist, nbuckets);
  forall(bucketlist, nbuckets, [](int64_t id, bucket_t<S>& bucket){
    // (global malloc doesn't call constructors)
    new (&bucket) bucket_t<S>();
    bucket.reserve(counts[id]);
  });
  
  VLOG(3) << "scattering...";
      t = Grappa::walltime();

  // scatter into buckets
  // forall_local<uint64_t,scatter>(array, nelems);
  forall(array, nelems, [bucketlist,lobits,LOBITS](int64_t s, int64_t n, S * first){
    size_t nbuckets = counts.size();
    
    for (int i=0; i<n; i++) {
      auto v = first[i];
      size_t b = lobits(v, LOBITS);
      CHECK( b < nbuckets ) << "bucket id = " << b << ", nbuckets = " << nbuckets;
      // ff_delegate<bucket_t,uint64_t,ff_append>(bucketlist+b, v);
      auto destb = bucketlist+b;
      delegate::call<async>(destb.core(), [destb,v]{
        destb.pointer()->append(v);
      });
    }
  });
    
  scatter_time = Grappa::walltime() - t;
  LOG(INFO) << "scatter_time: " << scatter_time;
  t = Grappa::walltime();

  // sort buckets locally
  // forall_local<bucket_t,sort_bucket>(bucketlist, nbuckets);
  /// Do some kind of local serial sort of a bucket
  forall(bucketlist, nbuckets, [Scmp](int64_t bucket_id, bucket_t<S>& bucket){
    if (bucket.size() == 0) return;
    qsort(&bucket[0], bucket.size(), sizeof(S), Scmp);
  });

//.........这里部分代码省略.........
开发者ID:HTOKORG,项目名称:grappa,代码行数:101,代码来源:sort.hpp

示例15: fill_remote

 void fill_remote(GlobalAddress<FullEmpty<T>> result_addr, const T& val) {
   send_heap_message(result_addr.core(), [result_addr,val]{
     result_addr->writeXF(val);
   });
 }
开发者ID:HPCProjectsTry,项目名称:grappa,代码行数:5,代码来源:FullEmpty.hpp


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