コード例 #1
0
ファイル: Hash.hpp プロジェクト: hlitz/rstm_sitevm
    TM_CALLABLE
    void remove(int val TM_ARG)
    {
      //std::cout << " val " << val << std::endl;
      //bool found = false;
      uint32_t buck = val % N_BUCKETS;
      //std::cout << "cuck " << buck << std::endl;
      
      uint32_t slots = TM_READ(bucket_entries[buck]);
      //std::cout << slots << " slots " << std::endl;
      if(slots>0){
	for(uint32_t i = 0; i<slots ; i++){
	  if(val==TM_READ(bucket[buck][i]) && val !=0 ){
	    //TM_WRITE(bucket[buck][i], 0);
	    TM_WRITE(bucket_entries[buck], TM_READ(bucket_entries[buck])-1);
	    //found = true;
	    for(uint32_t e = i; e<slots; e++){
	      TM_WRITE(bucket[buck][e], TM_READ(bucket[buck][e+1])); //shift the remainder elements to the left
	    }
	    break;
	  }
	}
      }
      //if(!found) std::cout << "not present" << val << std::endl;
      //else std::cout << "PRESENT" << val << std::endl;
     
    }
コード例 #2
0
ファイル: Hash.hpp プロジェクト: hlitz/rstm_sitevm
 TM_CALLABLE
 void insert(int val TM_ARG)
 {
   //std::cout << " n buck " << N_BUCKETS << std::endl;
   uint32_t buck = val % N_BUCKETS;
   uint32_t slots = TM_READ(bucket_entries[buck])+1;
   TM_WRITE(bucket_entries[buck], slots);
   TM_WRITE(bucket[buck][slots], val);
 }
コード例 #3
0
ファイル: Hash.hpp プロジェクト: hlitz/rstm_sitevm
  TM_CALLABLE
  void update(int buck, int slot TM_ARG) const
  {
    //    std::cout << " addr " << (uint64_t)(&bucket[buck][slot]) << std::endl;
    //int val = TM_READ(bucket[buck][slot]);
	    //TM_WRITE(bucket[buck][i], 0);
    TM_WRITE(bucket[buck][slot], 1);

  }
コード例 #4
0
ファイル: MCASBench.cpp プロジェクト: amohtasham/rstm
/*** Run a bunch of random transactions */
void bench_test(uintptr_t, uint32_t* seed)
{
    // cache the seed locally so we can restore it on abort
    //
    // NB: volatile needed because using a non-volatile local in conjunction
    //     with a setjmp-longjmp control transfer is undefined, and gcc won't
    //     allow it with -Wall -Werror.
    volatile uint32_t local_seed = *seed;

    TM_BEGIN(atomic) {
        for (uint32_t i = 0; i < CFG.ops; ++i) {
            uint32_t loc = rand_r_32(&local_seed) % CFG.elements;
            TM_WRITE(matrix[loc], 1 + TM_READ(matrix[loc]));
        }
    } TM_END;
    *seed = local_seed;
}
コード例 #5
0
ファイル: ReadWriteNBench.cpp プロジェクト: ml9951/rstm
/*** Run a bunch of random transactions */
void bench_test(uintptr_t id, uint32_t* seed)
{
    uint32_t loc[1024];
    int snapshot[1024];

    //determine the locations prior to the transaction
    for(uint32_t i = 0; i < CFG.ops; i++) {
        uint32_t r = rand_r(seed) % CFG.elements;
        local_mats[id][r]++;
        loc[i] = r;
    }

    TM_BEGIN(atomic) {
        for (uint32_t i = 0; i < CFG.ops; ++i) {
            snapshot[i] = TM_READ(matrix[loc[i]]);
        }
        for (uint32_t i = 0; i < CFG.ops; ++i) {
            TM_WRITE(matrix[loc[i]], 1 + snapshot[i]);
        }
    }
    TM_END;
}