├── .gitmodules ├── CMakeLists.txt ├── README.md ├── cmake └── Dependencies.cmake ├── ddio_tools ├── CMakeLists.txt ├── dca.cc ├── ddio_tune.cc └── pciutils-3.5.1 │ ├── .gitignore │ ├── COPYING │ ├── ChangeLog │ ├── Makefile │ ├── README │ ├── README.Windows │ ├── TODO │ ├── common.c │ ├── compat │ ├── README │ ├── getopt.c │ └── getopt.h │ ├── example.c │ ├── lib │ ├── .gitignore │ ├── Makefile │ ├── access.c │ ├── aix-device.c │ ├── caps.c │ ├── configure │ ├── darwin.c │ ├── dump.c │ ├── fbsd-device.c │ ├── filter.c │ ├── generic.c │ ├── header.h │ ├── i386-io-beos.h │ ├── i386-io-cygwin.h │ ├── i386-io-haiku.h │ ├── i386-io-hurd.h │ ├── i386-io-linux.h │ ├── i386-io-sunos.h │ ├── i386-io-windows.h │ ├── i386-ports.c │ ├── init.c │ ├── internal.h │ ├── libpci.pc.in │ ├── libpci.ver │ ├── names-cache.c │ ├── names-hash.c │ ├── names-hwdb.c │ ├── names-net.c │ ├── names-parse.c │ ├── names.c │ ├── names.h │ ├── nbsd-libpci.c │ ├── obsd-device.c │ ├── params.c │ ├── pci.h │ ├── pread.h │ ├── proc.c │ ├── sysdep.h │ ├── sysfs.c │ └── types.h │ ├── ls-caps-vendor.c │ ├── ls-caps.c │ ├── ls-ecaps.c │ ├── ls-kernel.c │ ├── ls-map.c │ ├── ls-tree.c │ ├── ls-vpd.c │ ├── lspci.c │ ├── lspci.h │ ├── lspci.man │ ├── maint │ ├── RELEASE │ ├── gen-zone │ ├── release │ ├── release.pm │ └── tag-release │ ├── pci.ids │ ├── pcilib.man │ ├── pciutils.h │ ├── pciutils.lsm │ ├── pciutils.spec │ ├── setpci.c │ ├── setpci.man │ ├── tests │ ├── PCI-X-bridges-and-domains │ ├── broken-ecaps │ ├── cap-MSI-mapping │ ├── cap-address-xlation │ ├── cap-debug-port │ ├── cap-dpc │ ├── cap-ea-1 │ ├── cap-l1-pm │ ├── cap-pasid-pri │ ├── cap-pci-af │ ├── cap-pcie-1 │ ├── cap-pcie-2 │ ├── cap-ptm-1 │ ├── cap-ptm-2 │ ├── cap-vc-and-rcl │ ├── cap-vc-pat │ └── cap-vendor-virtio │ ├── update-pciids.man │ ├── update-pciids.sh │ └── win32 │ ├── config.h │ └── config.mk ├── nvm ├── analysis.py ├── benchs │ ├── gen_addr.hh │ ├── latency.hh │ ├── local.cc │ ├── multi.cc │ ├── nt_memcpy.hh │ ├── one_sided │ │ ├── #client.cc# │ │ ├── aclient.cc │ │ ├── aclient.cc~ │ │ ├── bandwidth.cc │ │ ├── bandwidth.cc~ │ │ ├── client.cc │ │ ├── client.cc~ │ │ ├── local_bandwidth.cc │ │ ├── local_bandwidth.cc~ │ │ └── server.cc │ ├── statucs.hh │ ├── thread.hh │ ├── timer.hpp │ └── two_sided │ │ ├── #client.cc# │ │ ├── #ring_server.cc# │ │ ├── avx_512.hh │ │ ├── avx_512.hh~ │ │ ├── client.cc │ │ ├── constants.hh │ │ ├── core.hh │ │ ├── proto.hh │ │ ├── r740.hh │ │ ├── rc_client.cc │ │ ├── rc_server.cc │ │ ├── ring_client.cc │ │ ├── ring_server.cc │ │ ├── server.cc │ │ ├── test.cc │ │ └── val19.hh ├── docs │ └── Understanding-Performance-of-PCI-Express-Systems.pdf ├── huge_region.hh ├── log_bundler.hh ├── memory_region.hh ├── nvm │ └── benchs │ │ └── one_sided │ │ └── aclient.cc └── nvm_region.hh ├── scripts ├── bootstrap_proxy.py └── run_one.toml ├── sys ├── .DS_Store ├── drtmh │ ├── .DS_Store │ ├── .gitmodules │ ├── CMakeLists.txt │ ├── README.md │ ├── cmake │ │ ├── Dependencies.cmake │ │ ├── gtest.cmake │ │ ├── gtest.cmake.in │ │ ├── rocc.cmake │ │ ├── tpce.cmake │ │ └── unit_tests.cmake │ ├── config_template.xml │ ├── scripts │ │ ├── .DS_Store │ │ ├── aws-config.py │ │ ├── awsrun.sh │ │ ├── batch_bench_runner.py │ │ ├── boostrap.py │ │ ├── bootstrap_proxy.py │ │ ├── checker.py │ │ ├── config.xml │ │ ├── count_line.sh │ │ ├── cp.toml │ │ ├── drtmh-tpcc.toml │ │ ├── drtmh.toml │ │ ├── hosts.xml │ │ ├── kill.toml │ │ ├── make.toml │ │ ├── module_test.py │ │ ├── octopus.toml │ │ ├── query.py │ │ ├── run-aws.py │ │ ├── run.toml │ │ ├── run2.py │ │ ├── run_batch_aws.py │ │ ├── run_test3.py │ │ ├── run_two_rc.toml │ │ ├── run_util.py │ │ ├── runner.py │ │ ├── sync.toml │ │ ├── sync_to_aws.sh │ │ ├── sync_to_client.sh │ │ └── sync_to_server.sh │ ├── src │ │ ├── all.h │ │ ├── app │ │ │ ├── README │ │ │ ├── config.h │ │ │ ├── graph │ │ │ │ ├── base_distribution.hpp │ │ │ │ ├── grap_main.cc │ │ │ │ ├── graph.h │ │ │ │ ├── graph_constants.h │ │ │ │ ├── graph_scheme.h │ │ │ │ ├── graph_util.hpp │ │ │ │ └── real_distribution.hpp │ │ │ ├── micro_benches │ │ │ │ ├── bench_micro.cc │ │ │ │ ├── bench_micro.h │ │ │ │ ├── micro_logger.cc │ │ │ │ ├── micro_rdma.cc │ │ │ │ ├── micro_rdma_sched.cc │ │ │ │ ├── micro_rpc.cc │ │ │ │ └── micro_tx.cc │ │ │ ├── smallbank │ │ │ │ ├── bank_log_cleaner.h │ │ │ │ ├── bank_main.cc │ │ │ │ ├── bank_schema.h │ │ │ │ ├── bank_worker.cc │ │ │ │ ├── bank_worker.h │ │ │ │ └── bank_worker_new.cc │ │ │ ├── tpcc │ │ │ │ ├── tpcc_cache.cc │ │ │ │ ├── tpcc_loader.cc │ │ │ │ ├── tpcc_log_cleaner.h │ │ │ │ ├── tpcc_main.cc │ │ │ │ ├── tpcc_mixin.h │ │ │ │ ├── tpcc_rpc_handlers.cc │ │ │ │ ├── tpcc_schema.h │ │ │ │ ├── tpcc_worker.cc │ │ │ │ ├── tpcc_worker.h │ │ │ │ └── tpcc_worker_new.cc │ │ │ └── tpce │ │ │ │ ├── egen │ │ │ │ ├── AddressTable.cpp │ │ │ │ ├── AddressTable.h │ │ │ │ ├── BaseLoader.h │ │ │ │ ├── BaseLoaderFactory.h │ │ │ │ ├── BaseLogFormatter.h │ │ │ │ ├── BaseLogger.cpp │ │ │ │ ├── BaseLogger.h │ │ │ │ ├── BigMath.h │ │ │ │ ├── Brokers.h │ │ │ │ ├── CE.cpp │ │ │ │ ├── CE.h │ │ │ │ ├── CESUTInterface.h │ │ │ │ ├── CETxnInputGenerator.cpp │ │ │ │ ├── CETxnInputGenerator.h │ │ │ │ ├── CETxnMixGenerator.cpp │ │ │ │ ├── CETxnMixGenerator.h │ │ │ │ ├── ChargeTable.h │ │ │ │ ├── CommissionRateTable.h │ │ │ │ ├── CompanyCompetitorFile.h │ │ │ │ ├── CompanyCompetitorTable.h │ │ │ │ ├── CompanyFile.h │ │ │ │ ├── CompanyTable.h │ │ │ │ ├── CustomerAccountsAndPermissionsTable.h │ │ │ │ ├── CustomerSelection.cpp │ │ │ │ ├── CustomerSelection.h │ │ │ │ ├── CustomerTable.cpp │ │ │ │ ├── CustomerTable.h │ │ │ │ ├── CustomerTaxratesTable.h │ │ │ │ ├── DM.cpp │ │ │ │ ├── DM.h │ │ │ │ ├── DMSUTInterface.h │ │ │ │ ├── DailyMarketTable.h │ │ │ │ ├── DateTime.cpp │ │ │ │ ├── DateTime.h │ │ │ │ ├── DriverParamSettings.h │ │ │ │ ├── DriverTypes.h │ │ │ │ ├── EGenBaseLoader_stdafx.h │ │ │ │ ├── EGenError.h │ │ │ │ ├── EGenGenerateAndLoad.cpp │ │ │ │ ├── EGenGenerateAndLoad.h │ │ │ │ ├── EGenGenerateAndLoadBaseOutput.h │ │ │ │ ├── EGenGenerateAndLoadStandardOutput.h │ │ │ │ ├── EGenGenerateAndLoad_stdafx.h │ │ │ │ ├── EGenLoader.cxx │ │ │ │ ├── EGenLoader_stdafx.h │ │ │ │ ├── EGenLogFormatterTab.cpp │ │ │ │ ├── EGenLogFormatterTab.h │ │ │ │ ├── EGenLogger.h │ │ │ │ ├── EGenNullLoader_stdafx.h │ │ │ │ ├── EGenStandardTypes.h │ │ │ │ ├── EGenTables_common.h │ │ │ │ ├── EGenTables_stdafx.h │ │ │ │ ├── EGenUtilities_stdafx.h │ │ │ │ ├── EGenValidate.cxx │ │ │ │ ├── EGenVersion.cpp │ │ │ │ ├── EGenVersion.h │ │ │ │ ├── ExchangeTable.h │ │ │ │ ├── FinalTransform.h │ │ │ │ ├── FinancialTable.h │ │ │ │ ├── FixedArray.h │ │ │ │ ├── FixedMap.h │ │ │ │ ├── FlatAccountPermissionLoad.h │ │ │ │ ├── FlatAddressLoad.h │ │ │ │ ├── FlatBrokerLoad.h │ │ │ │ ├── FlatCashTransactionLoad.h │ │ │ │ ├── FlatChargeLoad.h │ │ │ │ ├── FlatCommissionRateLoad.h │ │ │ │ ├── FlatCompanyCompetitorLoad.h │ │ │ │ ├── FlatCompanyLoad.h │ │ │ │ ├── FlatCustomerAccountLoad.h │ │ │ │ ├── FlatCustomerLoad.h │ │ │ │ ├── FlatCustomerTaxrateLoad.h │ │ │ │ ├── FlatDailyMarketLoad.h │ │ │ │ ├── FlatExchangeLoad.h │ │ │ │ ├── FlatFile.h │ │ │ │ ├── FlatFileLoad_common.h │ │ │ │ ├── FlatFileLoad_stdafx.h │ │ │ │ ├── FlatFileLoader.cpp │ │ │ │ ├── FlatFileLoader.h │ │ │ │ ├── FlatFinancialLoad.h │ │ │ │ ├── FlatHoldingHistoryLoad.h │ │ │ │ ├── FlatHoldingLoad.h │ │ │ │ ├── FlatHoldingSummaryLoad.h │ │ │ │ ├── FlatIndustryLoad.h │ │ │ │ ├── FlatLastTradeLoad.h │ │ │ │ ├── FlatLoaderFactory.h │ │ │ │ ├── FlatNewsItemLoad.h │ │ │ │ ├── FlatNewsXRefLoad.h │ │ │ │ ├── FlatSectorLoad.h │ │ │ │ ├── FlatSecurityLoad.h │ │ │ │ ├── FlatSettlementLoad.h │ │ │ │ ├── FlatStatusTypeLoad.h │ │ │ │ ├── FlatTaxrateLoad.h │ │ │ │ ├── FlatTradeHistoryLoad.h │ │ │ │ ├── FlatTradeLoad.h │ │ │ │ ├── FlatTradeRequestLoad.h │ │ │ │ ├── FlatTradeTypeLoad.h │ │ │ │ ├── FlatWatchItemLoad.h │ │ │ │ ├── FlatWatchListLoad.h │ │ │ │ ├── FlatZipCodeLoad.h │ │ │ │ ├── HoldingsAndTradesTable.h │ │ │ │ ├── IndustryTable.h │ │ │ │ ├── InputFile.h │ │ │ │ ├── InputFileNoWeight.h │ │ │ │ ├── InputFlatFilesDeclarations.h │ │ │ │ ├── InputFlatFilesStructure.cpp │ │ │ │ ├── InputFlatFilesStructure.h │ │ │ │ ├── LastTradeTable.h │ │ │ │ ├── MEE.cxx │ │ │ │ ├── MEE.h │ │ │ │ ├── MEEPriceBoard.cpp │ │ │ │ ├── MEEPriceBoard.h │ │ │ │ ├── MEESUTInterface.h │ │ │ │ ├── MEESecurity.cpp │ │ │ │ ├── MEESecurity.h │ │ │ │ ├── MEETickerTape.cpp │ │ │ │ ├── MEETickerTape.h │ │ │ │ ├── MEETradeRequestActions.h │ │ │ │ ├── MEETradingFloor.cpp │ │ │ │ ├── MEETradingFloor.h │ │ │ │ ├── MiscConsts.h │ │ │ │ ├── Money.cpp │ │ │ │ ├── Money.h │ │ │ │ ├── NewsItemAndXRefTable.h │ │ │ │ ├── NullLoad_stdafx.h │ │ │ │ ├── NullLoader.h │ │ │ │ ├── NullLoaderFactory.h │ │ │ │ ├── Person.cpp │ │ │ │ ├── Person.h │ │ │ │ ├── RNGSeeds.h │ │ │ │ ├── Random.cpp │ │ │ │ ├── Random.h │ │ │ │ ├── ReadRowFunctions.cpp │ │ │ │ ├── ReadRowFunctions_istream.cpp │ │ │ │ ├── ReadRowFunctions_sscanf.cpp │ │ │ │ ├── SectorTable.h │ │ │ │ ├── SecurityFile.h │ │ │ │ ├── SecurityPriceRange.h │ │ │ │ ├── SecurityTable.h │ │ │ │ ├── StatusTypeTable.h │ │ │ │ ├── SyncLockInterface.h │ │ │ │ ├── TableConsts.h │ │ │ │ ├── TableTemplate.h │ │ │ │ ├── Table_Defs.h │ │ │ │ ├── TaxrateTable.h │ │ │ │ ├── TimerWheel.h │ │ │ │ ├── TimerWheelTimer.h │ │ │ │ ├── TradeGen.cpp │ │ │ │ ├── TradeGen.h │ │ │ │ ├── TradeTypeIDs.h │ │ │ │ ├── TradeTypeTable.h │ │ │ │ ├── TxnHarnessBrokerVolume.h │ │ │ │ ├── TxnHarnessCustomerPosition.h │ │ │ │ ├── TxnHarnessDBInterface.h │ │ │ │ ├── TxnHarnessDataMaintenance.h │ │ │ │ ├── TxnHarnessMarketFeed.h │ │ │ │ ├── TxnHarnessMarketWatch.h │ │ │ │ ├── TxnHarnessSecurityDetail.h │ │ │ │ ├── TxnHarnessSendToMarketInterface.h │ │ │ │ ├── TxnHarnessStructs.h │ │ │ │ ├── TxnHarnessTradeCleanup.h │ │ │ │ ├── TxnHarnessTradeLookup.h │ │ │ │ ├── TxnHarnessTradeOrder.h │ │ │ │ ├── TxnHarnessTradeResult.h │ │ │ │ ├── TxnHarnessTradeStatus.h │ │ │ │ ├── TxnHarnessTradeUpdate.h │ │ │ │ ├── WatchListsAndItemsTable.h │ │ │ │ ├── Wheel.h │ │ │ │ ├── WheelTime.cpp │ │ │ │ ├── WheelTime.h │ │ │ │ ├── ZipCodeTable.h │ │ │ │ ├── bucketsimulator.cpp │ │ │ │ ├── bucketsimulator.h │ │ │ │ ├── error.cpp │ │ │ │ ├── error.h │ │ │ │ ├── flat │ │ │ │ │ └── egen_flat_in │ │ │ │ │ │ ├── AreaCode.txt │ │ │ │ │ │ ├── Charge.txt │ │ │ │ │ │ ├── CommissionRate.txt │ │ │ │ │ │ ├── Company.txt │ │ │ │ │ │ ├── CompanyCompetitor.txt │ │ │ │ │ │ ├── CompanySPRate.txt │ │ │ │ │ │ ├── Exchange.txt │ │ │ │ │ │ ├── FemaleFirstName.txt │ │ │ │ │ │ ├── Industry.txt │ │ │ │ │ │ ├── LastName.txt │ │ │ │ │ │ ├── MaleFirstName.txt │ │ │ │ │ │ ├── NonTaxableAccountName.txt │ │ │ │ │ │ ├── Sector.txt │ │ │ │ │ │ ├── Security.txt │ │ │ │ │ │ ├── StatusType.txt │ │ │ │ │ │ ├── StreetName.txt │ │ │ │ │ │ ├── StreetSuffix.txt │ │ │ │ │ │ ├── TaxRatesCountry.txt │ │ │ │ │ │ ├── TaxRatesDivision.txt │ │ │ │ │ │ ├── TaxableAccountName.txt │ │ │ │ │ │ ├── TradeType.txt │ │ │ │ │ │ └── ZipCode.txt │ │ │ │ ├── locking.cpp │ │ │ │ ├── locking.h │ │ │ │ ├── progressmeter.cpp │ │ │ │ ├── progressmeter.h │ │ │ │ ├── progressmeterinterface.cpp │ │ │ │ ├── progressmeterinterface.h │ │ │ │ ├── shore_tpce_egen.h │ │ │ │ ├── strutil.cpp │ │ │ │ ├── strutil.h │ │ │ │ ├── threading.cpp │ │ │ │ ├── threading.h │ │ │ │ ├── threading_pthread.h │ │ │ │ ├── threading_single.h │ │ │ │ ├── unusedflag.h │ │ │ │ └── user_time.h │ │ │ │ ├── tpce_constants.h │ │ │ │ ├── tpce_loader.cc │ │ │ │ ├── tpce_loader_factory.h │ │ │ │ ├── tpce_main.cc │ │ │ │ ├── tpce_mixin.h │ │ │ │ ├── tpce_rpc_handler.cc │ │ │ │ ├── tpce_schema.h │ │ │ │ ├── tpce_worker.cc │ │ │ │ ├── tpce_worker.h │ │ │ │ └── tpce_worker_new.cc │ │ ├── core │ │ │ ├── common.h │ │ │ ├── commun_queue.hpp │ │ │ ├── logging.cc │ │ │ ├── logging.h │ │ │ ├── rdma_sched.cc │ │ │ ├── rdma_sched.h │ │ │ ├── routine.cc │ │ │ ├── routine.h │ │ │ ├── rrpc.cc │ │ │ ├── rrpc.h │ │ │ ├── rworker.cc │ │ │ ├── rworker.h │ │ │ ├── rworker_yield_impl.hpp │ │ │ ├── tcp_adapter.cc │ │ │ ├── tcp_adapter.hpp │ │ │ └── utils │ │ │ │ ├── amd64.h │ │ │ │ ├── count_vector.hpp │ │ │ │ ├── latency_profier.h │ │ │ │ ├── macros.h │ │ │ │ ├── ndb_type_traits.h │ │ │ │ ├── records_buffer.hpp │ │ │ │ ├── scopedperf.hh │ │ │ │ ├── serializer.h │ │ │ │ ├── small_vector.h │ │ │ │ ├── spinbarrier.h │ │ │ │ ├── thread.cc │ │ │ │ ├── thread.h │ │ │ │ ├── util.h │ │ │ │ ├── varint.cc │ │ │ │ └── varint.h │ │ ├── db │ │ │ ├── config.h │ │ │ ├── db_logger.cc │ │ │ ├── db_logger.h │ │ │ ├── db_logger.hpp │ │ │ ├── db_logger_wrapper.h │ │ │ ├── db_one_remote.cc │ │ │ ├── db_one_remote.h │ │ │ ├── forkset.cc │ │ │ ├── forkset.h │ │ │ ├── forkset.h │ │ │ ├── remote_set.cc │ │ │ ├── remote_set.h │ │ │ ├── remote_set_structs.h │ │ │ └── txs │ │ │ │ ├── db_2pl.h │ │ │ │ ├── db_farm.cc │ │ │ │ ├── db_farm.h │ │ │ │ ├── db_farm_rpc.cc │ │ │ │ ├── dbrad.cc │ │ │ │ ├── dbrad.h │ │ │ │ ├── dbrad_rpc_handler.cc │ │ │ │ ├── dbsi.cc │ │ │ │ ├── dbsi.h │ │ │ │ ├── dbsi_rpc_handler.cc │ │ │ │ ├── dbtx.cc │ │ │ │ ├── dbtx.h │ │ │ │ ├── dbtx_remote.cc │ │ │ │ ├── dbtx_rpc_handler.cc │ │ │ │ ├── si_ts_manager.cpp │ │ │ │ ├── si_ts_manager.h │ │ │ │ ├── ts_manager.hpp │ │ │ │ └── tx_handler.h │ │ ├── framework │ │ │ ├── backup_worker.cc │ │ │ ├── backup_worker.h │ │ │ ├── bench_listener.h │ │ │ ├── bench_listener2.cc │ │ │ ├── bench_reporter.cc │ │ │ ├── bench_reporter.h │ │ │ ├── bench_runner.cc │ │ │ ├── bench_runner.h │ │ │ ├── bench_worker.cc │ │ │ ├── bench_worker.h │ │ │ ├── config.cc │ │ │ ├── config.h │ │ │ ├── log_cleaner.cc │ │ │ ├── log_cleaner.h │ │ │ ├── main.cc │ │ │ ├── req_buf_allocator.h │ │ │ ├── rpc.cc │ │ │ ├── rpc.h │ │ │ ├── tpc_msg.h │ │ │ ├── utils │ │ │ │ ├── abstract_db.h │ │ │ │ ├── amd64.h │ │ │ │ ├── encoder.h │ │ │ │ ├── inline_str.h │ │ │ │ ├── macros.h │ │ │ │ ├── ndb_type_traits.h │ │ │ │ ├── scopedperf.hh │ │ │ │ ├── serializer.h │ │ │ │ ├── small_vector.h │ │ │ │ ├── spinbarrier.h │ │ │ │ ├── thread.cc │ │ │ │ ├── thread.h │ │ │ │ ├── util.h │ │ │ │ ├── varint.cc │ │ │ │ └── varint.h │ │ │ ├── view_manager.cc │ │ │ └── view_manager.h │ │ ├── memstore │ │ │ ├── cluster_chaining.hpp │ │ │ ├── cluster_chaining_remote_op.hpp │ │ │ ├── memdb.cc │ │ │ ├── memdb.h │ │ │ ├── memstore.cc │ │ │ ├── memstore.h │ │ │ ├── memstore_bplustree.cc │ │ │ ├── memstore_bplustree.h │ │ │ ├── memstore_hash.cc │ │ │ ├── memstore_hash.h │ │ │ ├── memstore_uint64bplustree.cc │ │ │ ├── memstore_uint64bplustree.h │ │ │ ├── rdma_chainhash.h │ │ │ ├── rdma_cuckoohash.h │ │ │ ├── rdma_hash.hpp │ │ │ ├── rdma_hashext.h │ │ │ └── simple_cache.hpp │ │ ├── port │ │ │ ├── README │ │ │ ├── atomic-template.h │ │ │ ├── atomic.h │ │ │ ├── atomic_pointer.h │ │ │ ├── port.h │ │ │ ├── port_example.h │ │ │ ├── port_posix.cc │ │ │ ├── port_posix.h │ │ │ ├── thread_annotations.h │ │ │ └── win │ │ │ │ └── stdint.h │ │ ├── rocc_config.h.in │ │ ├── rtx │ │ │ ├── batch_op_impl.hpp │ │ │ ├── checker.hpp │ │ │ ├── default_log_cleaner_impl.hpp │ │ │ ├── global_vars.cc │ │ │ ├── global_vars.h │ │ │ ├── local_op_impl.hpp │ │ │ ├── log_cleaner.hpp │ │ │ ├── log_mem_manager.hpp │ │ │ ├── log_store_manager.hpp │ │ │ ├── logger.hpp │ │ │ ├── logger_test.cxx │ │ │ ├── msg_format.hpp │ │ │ ├── occ.cc │ │ │ ├── occ.h │ │ │ ├── occ_inline.hpp │ │ │ ├── occ_internal_structure.h │ │ │ ├── occ_iterator.hpp │ │ │ ├── occ_rdma.cc │ │ │ ├── occ_rdma.h │ │ │ ├── occ_statistics.h │ │ │ ├── occ_variants.hpp │ │ │ ├── op_test.cxx │ │ │ ├── opt_config.hh │ │ │ ├── qp_selection_helper.h │ │ │ ├── rdma_logger_impl.hpp │ │ │ ├── rdma_op_impl.hpp │ │ │ ├── rdma_req_helper.hpp │ │ │ ├── rpc_logger_impl.hpp │ │ │ ├── tx_operator.hpp │ │ │ ├── view.cc │ │ │ └── view.h │ │ ├── tx_config.h.in │ │ └── util │ │ │ ├── Makefile │ │ │ ├── mapped_log.cc │ │ │ ├── mapped_log.h │ │ │ ├── msg_buf_allocator.h │ │ │ ├── mutexlock.h │ │ │ ├── random.h │ │ │ ├── rdtsc_converter.cxx │ │ │ ├── rtm.cc │ │ │ ├── rtm.h │ │ │ ├── simple_logger.h │ │ │ ├── spinlock.h │ │ │ ├── temp_log.h │ │ │ ├── timer.h │ │ │ ├── txprofile.h │ │ │ ├── util.cc │ │ │ └── util.h │ └── third_party │ │ ├── gflags │ │ ├── .gitattributes │ │ ├── .gitignore │ │ ├── .gitmodules │ │ ├── .travis.yml │ │ ├── AUTHORS.txt │ │ ├── BUILD │ │ ├── CMakeLists.txt │ │ ├── COPYING.txt │ │ ├── ChangeLog.txt │ │ ├── GPATH │ │ ├── GRTAGS │ │ ├── GTAGS │ │ ├── INSTALL.md │ │ ├── README.md │ │ ├── WORKSPACE │ │ ├── appveyor.yml │ │ ├── bazel │ │ │ └── gflags.bzl │ │ ├── cmake │ │ │ ├── README_runtime.txt │ │ │ ├── cmake_uninstall.cmake.in │ │ │ ├── config.cmake.in │ │ │ ├── execute_test.cmake │ │ │ ├── package.cmake.in │ │ │ ├── package.pc.in │ │ │ ├── utils.cmake │ │ │ └── version.cmake.in │ │ ├── src │ │ │ ├── config.h │ │ │ ├── defines.h.in │ │ │ ├── gflags.cc │ │ │ ├── gflags.h.in │ │ │ ├── gflags_completions.cc │ │ │ ├── gflags_completions.h.in │ │ │ ├── gflags_completions.sh │ │ │ ├── gflags_declare.h.in │ │ │ ├── gflags_ns.h.in │ │ │ ├── gflags_reporting.cc │ │ │ ├── mutex.h │ │ │ ├── util.h │ │ │ ├── windows_port.cc │ │ │ └── windows_port.h │ │ └── test │ │ │ ├── CMakeLists.txt │ │ │ ├── config │ │ │ ├── CMakeLists.txt │ │ │ └── main.cc │ │ │ ├── flagfile.1 │ │ │ ├── flagfile.2 │ │ │ ├── flagfile.3 │ │ │ ├── gflags_build.py.in │ │ │ ├── gflags_declare_flags.cc │ │ │ ├── gflags_declare_test.cc │ │ │ ├── gflags_strip_flags_test.cc │ │ │ ├── gflags_strip_flags_test.cmake │ │ │ ├── gflags_unittest.cc │ │ │ ├── gflags_unittest_flagfile │ │ │ └── nc │ │ │ ├── CMakeLists.txt │ │ │ └── gflags_nc.cc │ │ └── micautil │ │ ├── city.h │ │ ├── city_mod.cc │ │ ├── citycrc.h │ │ ├── citycrc_mod.h │ │ ├── hash.h │ │ ├── rte_memcpy.h │ │ ├── rte_memcpy_mod.h │ │ └── table │ │ ├── fixedtable.h │ │ ├── fixedtable_impl │ │ ├── bucket.h │ │ ├── del.h │ │ ├── get.h │ │ ├── info.h │ │ ├── init.h │ │ ├── item.h │ │ ├── lock.h │ │ ├── lock_bkt.h │ │ ├── lock_bkt_and_get.h │ │ ├── lock_bkt_for_ins.h │ │ ├── prefetch.h │ │ ├── set.h │ │ ├── set_spinlock.h │ │ └── unlock_bkt.h │ │ ├── ltable.h │ │ ├── ltable_impl │ │ ├── bucket.h │ │ ├── del.h │ │ ├── get.h │ │ ├── increment.h │ │ ├── info.h │ │ ├── init.h │ │ ├── item.h │ │ ├── lock.h │ │ ├── move_to_head.h │ │ ├── prefetch.h │ │ ├── set.h │ │ ├── specialization.h │ │ └── test.h │ │ ├── table.h │ │ └── types.h └── octopus │ ├── .DS_Store │ ├── .gitmodules │ ├── CMakeLists.txt │ ├── cmake │ └── FindCrypto.cmake │ ├── conf.xml │ ├── include │ ├── Configuration.hpp │ ├── RPCClient.hpp │ ├── RPCServer.hpp │ ├── RdmaSocket.hpp │ ├── TxManager.hpp │ ├── bitmap.hpp │ ├── common.hpp │ ├── debug.hpp │ ├── filesystem.hpp │ ├── global.h │ ├── hashtable.hpp │ ├── libnrfs.h │ ├── lock.h │ ├── mempool.hpp │ ├── nrfs.h │ ├── org_apache_hadoop_fs_nrfs_RawFileSystem.h │ ├── sha256.h │ ├── storage.hpp │ └── table.hpp │ ├── scripts │ ├── boostrap.py │ ├── build.toml │ ├── run.toml │ └── run_bd.toml │ └── src │ ├── client │ ├── JavaApiImpl.cpp │ ├── libnrfs.cpp │ └── nrfs.cpp │ ├── dummy.cpp │ ├── fs │ ├── TxManager.cpp │ ├── bitmap.cpp │ ├── dmfs.cpp │ ├── filesystem.cpp │ ├── hashtable.cpp │ ├── huge_region.hh │ ├── lock.cpp │ ├── memory_region.hh │ ├── nvm_region.hh │ ├── sha256.c │ └── storage.cpp │ ├── net │ ├── Configuration.cpp │ ├── RPCClient.cpp │ ├── RPCServer.cpp │ ├── RdmaSocket.cpp │ └── mempool.cpp │ ├── test │ ├── fusenrfs.cpp │ ├── locktest.cpp │ ├── mpibw.cpp │ ├── mpitest.cpp │ ├── nrfsCli.cpp │ └── nrfstest.cpp │ └── tools │ └── debug.cpp └── third_party └── rlib ├── .gitignore ├── .gitlab-ci.yml ├── .gitmodules ├── CMakeLists.txt ├── README.md ├── benchs ├── README.md ├── bench.cmake ├── bench_client.cc ├── bench_main.cc ├── bench_op.hh ├── bench_server.cc ├── db_bench │ └── client.cc ├── fly_bench │ └── client.cc ├── or_bench │ └── client.cc ├── reporter.hh ├── statics.hh └── thread.hh ├── core ├── bootstrap │ ├── channel.hh │ ├── multi_msg.hh │ ├── multi_msg_iter.hh │ ├── proto.hh │ └── srpc.hh ├── common.hh ├── lib.hh ├── naming.hh ├── nic.hh ├── nicinfo.hh ├── qps │ ├── abs_recv_allocator.hh │ ├── config.hh │ ├── doorbell_helper.hh │ ├── impl.hh │ ├── mod.hh │ ├── op.hh │ ├── rc.hh │ ├── rc_recv_manager.hh │ ├── recv_helper.hh │ ├── recv_iter.hh │ └── ud.hh ├── rctrl.hh ├── result.hh ├── rmem │ ├── config.hh │ ├── handler.hh │ └── mem.hh └── utils │ ├── abs_factory.hh │ ├── ipname.hh │ ├── logging.hh │ ├── marshal.hh │ ├── marshal.hpp │ ├── mod.hh │ ├── option.hh │ ├── timer.hh │ └── util.hpp ├── docs ├── INSTALL.md ├── benchs │ ├── TUTORIALS.md │ ├── op_performance.md │ └── ro_performance.md └── examples │ └── TUTORIALS.md ├── examples ├── exp.cmake ├── rc_overflow │ ├── client.cc │ └── server.cc ├── rc_pingpong │ ├── client.cc │ └── server.cc ├── rc_write │ ├── client.cc │ └── server.cc ├── rnic.cc ├── simple_connect.cc ├── ud_overflow │ ├── client.cc │ └── server.cc └── ud_pingpong │ ├── client.cc │ └── server.cc ├── roadmap ├── scripts ├── bench.toml ├── benchs │ └── rw_bench │ │ ├── make.toml │ │ └── run.toml ├── bootstrap.py ├── examples │ ├── rc_overflow │ │ ├── make.toml │ │ └── run.toml │ └── ud_overflow │ │ ├── make.toml │ │ └── run.toml ├── make.toml ├── run.toml └── sync_to_server.sh ├── sync_to_server.sh └── tests ├── fast_random.hh ├── main.cc ├── random.hh ├── sample.cc ├── test_channel.cc ├── test_cm.cc ├── test_common.cc ├── test_device.cc ├── test_marshal.cc ├── test_mem.cc ├── test_mmsg.cc ├── test_nicinfo.cc ├── test_op.cc ├── test_qp_progress.cc ├── test_rc.cc ├── test_rc_send.cc ├── test_rc_send_cm.cc ├── test_rpc.cc ├── test_ud.cc └── tests.cmake /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "third_party/r2"] 2 | path = third_party/r2 3 | url = https://github.com/wxdwfc/r2.git 4 | [submodule "third_party/gflags"] 5 | path = third_party/gflags 6 | url = https://github.com/gflags/gflags.git 7 | -------------------------------------------------------------------------------- /ddio_tools/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.2) 2 | 3 | ADD_DEFINITIONS( -std=c++17) 4 | 5 | set(ggflags_DIR "../third_party/gflags") 6 | add_subdirectory(${ggflags_DIR} gflags) 7 | include_directories("${ggflags_DIR}/include") 8 | 9 | project(dca) 10 | 11 | include_directories(../third_party) 12 | 13 | add_executable(setup_dca dca.cc ) 14 | 15 | target_link_libraries(setup_dca ${CMAKE_SOURCE_DIR}/pciutils-3.5.1/lib/libpci.a udev z gflags) 16 | 17 | add_executable(ddio_tune ddio_tune.cc ../third_party/r2/src/logging.cc) 18 | 19 | target_link_libraries(ddio_tune ${CMAKE_SOURCE_DIR}/pciutils-3.5.1/lib/libpci.a udev z gflags) 20 | -------------------------------------------------------------------------------- /ddio_tools/pciutils-3.5.1/.gitignore: -------------------------------------------------------------------------------- 1 | *.a 2 | *.o 3 | *.so 4 | *.[0-9] 5 | lspci 6 | setpci 7 | example 8 | update-pciids 9 | pci.ids.gz 10 | -------------------------------------------------------------------------------- /ddio_tools/pciutils-3.5.1/README.Windows: -------------------------------------------------------------------------------- 1 | Since 2.1.99-test5, pciutils should also be compilable on Windows. Thanks 2 | to Alexander Stock for contributing the port. 3 | 4 | Updated after version 2.2.6 to compile again, and with MinGW, even (only?) 5 | cross-compiling. (Hopefully it works with MSVC too.) 6 | 7 | To use this port, you need to install WinIO.dll first. You can get it 8 | from http://www.internals.com/. 9 | 10 | However, you need to use win32/config.{h,mk} instead of the automatically 11 | generated lib/config.{h,mk} as lib/configure does not run on Windows. 12 | 13 | ================================================================================ 14 | BEWARE: The current implementation pokes I/O ports to access the PCI devices 15 | directly. This leads to several problems: some devices are invisible, extended 16 | PCIe configuration space is not available, and there are many potential race 17 | conditions. Instead, libpci should use the proper Windows drivers. 18 | 19 | Unfortunately, the Windows port currently lacks a maintainer. If you are willing 20 | to step up and fix the issues, please let me know. -- Martin Mares 21 | ================================================================================ 22 | -------------------------------------------------------------------------------- /ddio_tools/pciutils-3.5.1/TODO: -------------------------------------------------------------------------------- 1 | - review class names 2 | 3 | Setpci: 4 | - auto-width 5 | - extend the register table 6 | 7 | Capabilities with partial decoding: 8 | - PCIe 2nd set of control/status registers (have spec) 9 | - HyperTransport caps (have spec) 10 | 11 | Capabilities with no decoding: 12 | - CompactPCI hot-swap 13 | - CompactPCI central resource control 14 | - AGP3 15 | - Secure device 16 | - Power Budgeting (ext'd, needs write access to enumerate) 17 | - Root Complex * (ext'd) 18 | - Multi-Function Virtual Channel (ext'd) 19 | - Root Bridge Control Block (ext'd) 20 | 21 | PCIIDS: 22 | - delete old DB at SF 23 | -------------------------------------------------------------------------------- /ddio_tools/pciutils-3.5.1/compat/README: -------------------------------------------------------------------------------- 1 | This directory contains implementations of standard library functions 2 | for systems where the default C libraries lack them. 3 | -------------------------------------------------------------------------------- /ddio_tools/pciutils-3.5.1/example.c: -------------------------------------------------------------------------------- 1 | /* 2 | * The PCI Library -- Example of use (simplistic lister of PCI devices) 3 | * 4 | * Written by Martin Mares and put to public domain. You can do 5 | * with it anything you want, but I don't give you any warranty. 6 | */ 7 | 8 | #include 9 | 10 | #include "lib/pci.h" 11 | 12 | int main(void) 13 | { 14 | struct pci_access *pacc; 15 | struct pci_dev *dev; 16 | unsigned int c; 17 | char namebuf[1024], *name; 18 | 19 | pacc = pci_alloc(); /* Get the pci_access structure */ 20 | /* Set all options you want -- here we stick with the defaults */ 21 | pci_init(pacc); /* Initialize the PCI library */ 22 | pci_scan_bus(pacc); /* We want to get the list of devices */ 23 | for (dev=pacc->devices; dev; dev=dev->next) /* Iterate over all devices */ 24 | { 25 | pci_fill_info(dev, PCI_FILL_IDENT | PCI_FILL_BASES | PCI_FILL_CLASS); /* Fill in header info we need */ 26 | c = pci_read_byte(dev, PCI_INTERRUPT_PIN); /* Read config register directly */ 27 | printf("%04x:%02x:%02x.%d vendor=%04x device=%04x class=%04x irq=%d (pin %d) base0=%lx", 28 | dev->domain, dev->bus, dev->dev, dev->func, dev->vendor_id, dev->device_id, 29 | dev->device_class, dev->irq, c, (long) dev->base_addr[0]); 30 | 31 | /* Look up and print the full name of the device */ 32 | name = pci_lookup_name(pacc, namebuf, sizeof(namebuf), PCI_LOOKUP_DEVICE, dev->vendor_id, dev->device_id); 33 | printf(" (%s)\n", name); 34 | } 35 | pci_cleanup(pacc); /* Close everything */ 36 | return 0; 37 | } 38 | -------------------------------------------------------------------------------- /ddio_tools/pciutils-3.5.1/lib/.gitignore: -------------------------------------------------------------------------------- 1 | config.h 2 | config.mk 3 | libpci.pc 4 | -------------------------------------------------------------------------------- /ddio_tools/pciutils-3.5.1/lib/i386-io-beos.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The PCI Library -- Access to i386 I/O ports on BeOS 3 | * 4 | * Copyright (c) 2009 Francois Revol 5 | * 6 | * Can be freely distributed and used under the terms of the GNU GPL. 7 | */ 8 | 9 | /* those are private syscalls */ 10 | extern int read_isa_io(int pci_bus, void *addr, int size); 11 | extern int write_isa_io(int pci_bus, void *addr, int size, u32 value); 12 | 13 | static int 14 | intel_setup_io(struct pci_access *a UNUSED) 15 | { 16 | return 1; 17 | } 18 | 19 | static inline int 20 | intel_cleanup_io(struct pci_access *a UNUSED) 21 | { 22 | return 1; 23 | } 24 | 25 | static inline u8 26 | inb (u16 port) 27 | { 28 | return (u8)read_isa_io(0, (void *)(u32)port, sizeof(u8)); 29 | } 30 | 31 | static inline u16 32 | inw (u16 port) 33 | { 34 | return (u16)read_isa_io(0, (void *)(u32)port, sizeof(u16)); 35 | } 36 | 37 | static inline u32 38 | inl (u16 port) 39 | { 40 | return (u32)read_isa_io(0, (void *)(u32)port, sizeof(u32)); 41 | } 42 | 43 | static inline void 44 | outb (u8 value, u16 port) 45 | { 46 | write_isa_io(0, (void *)(u32)port, sizeof(value), value); 47 | } 48 | 49 | static inline void 50 | outw (u16 value, u16 port) 51 | { 52 | write_isa_io(0, (void *)(u32)port, sizeof(value), value); 53 | } 54 | 55 | static inline void 56 | outl (u32 value, u16 port) 57 | { 58 | write_isa_io(0, (void *)(u32)port, sizeof(value), value); 59 | } 60 | -------------------------------------------------------------------------------- /ddio_tools/pciutils-3.5.1/lib/i386-io-cygwin.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The PCI Library -- Access to i386 I/O ports under Windows with CYGWIN 3 | * 4 | * Copyright (c) 1997--2006 Martin Mares 5 | * 6 | * Can be freely distributed and used under the terms of the GNU GPL. 7 | */ 8 | 9 | #include 10 | 11 | static int 12 | intel_setup_io(struct pci_access *a UNUSED) 13 | { 14 | return (iopl(3) < 0) ? 0 : 1; 15 | } 16 | 17 | static inline int 18 | intel_cleanup_io(struct pci_access *a UNUSED) 19 | { 20 | iopl(3); 21 | return -1; 22 | } 23 | -------------------------------------------------------------------------------- /ddio_tools/pciutils-3.5.1/lib/i386-io-hurd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The PCI Library -- Access to i386 I/O ports on GNU Hurd 3 | * 4 | * Copyright (c) 2003 Marco Gerards 5 | * Copyright (c) 2003 Martin Mares 6 | * Copyright (c) 2006 Samuel Thibault and 7 | * Thomas Schwinge 8 | * Copyright (c) 2007 Thomas Schwinge 9 | * 10 | * Can be freely distributed and used under the terms of the GNU GPL. 11 | */ 12 | 13 | #include 14 | 15 | static inline int 16 | intel_setup_io(struct pci_access *a UNUSED) 17 | { 18 | return (ioperm (0, 65535, 1) == -1) ? 0 : 1; 19 | } 20 | 21 | static inline int 22 | intel_cleanup_io(struct pci_access *a UNUSED) 23 | { 24 | ioperm (0, 65535, 0); 25 | 26 | return -1; 27 | } 28 | -------------------------------------------------------------------------------- /ddio_tools/pciutils-3.5.1/lib/i386-io-linux.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The PCI Library -- Access to i386 I/O ports on Linux 3 | * 4 | * Copyright (c) 1997--2006 Martin Mares 5 | * 6 | * Can be freely distributed and used under the terms of the GNU GPL. 7 | */ 8 | 9 | #include 10 | 11 | static int 12 | intel_setup_io(struct pci_access *a UNUSED) 13 | { 14 | return (iopl(3) < 0) ? 0 : 1; 15 | } 16 | 17 | static inline int 18 | intel_cleanup_io(struct pci_access *a UNUSED) 19 | { 20 | iopl(3); 21 | return -1; 22 | } 23 | -------------------------------------------------------------------------------- /ddio_tools/pciutils-3.5.1/lib/i386-io-sunos.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The PCI Library -- Access to i386 I/O ports on Solaris 3 | * 4 | * Copyright (c) 2003 Bill Moore 5 | * Copyright (c) 2003--2006 Martin Mares 6 | * 7 | * Can be freely distributed and used under the terms of the GNU GPL. 8 | */ 9 | 10 | #include 11 | #include 12 | 13 | static int 14 | intel_setup_io(struct pci_access *a UNUSED) 15 | { 16 | return (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) < 0) ? 0 : 1; 17 | } 18 | 19 | static inline int 20 | intel_cleanup_io(struct pci_access *a UNUSED) 21 | { 22 | /* FIXME: How to switch off I/O port access? */ 23 | return 1; 24 | } 25 | 26 | static inline u8 27 | inb (u16 port) 28 | { 29 | u8 v; 30 | __asm__ __volatile__ ("inb (%w1)":"=a" (v):"Nd" (port)); 31 | return v; 32 | } 33 | 34 | static inline u16 35 | inw (u16 port) 36 | { 37 | u16 v; 38 | __asm__ __volatile__ ("inw (%w1)":"=a" (v):"Nd" (port)); 39 | return v; 40 | } 41 | 42 | static inline u32 43 | inl (u16 port) 44 | { 45 | u32 v; 46 | __asm__ __volatile__ ("inl (%w1)":"=a" (v):"Nd" (port)); 47 | return v; 48 | } 49 | 50 | static inline void 51 | outb (u8 value, u16 port) 52 | { 53 | __asm__ __volatile__ ("outb (%w1)": :"a" (value), "Nd" (port)); 54 | } 55 | 56 | static inline void 57 | outw (u16 value, u16 port) 58 | { 59 | __asm__ __volatile__ ("outw (%w1)": :"a" (value), "Nd" (port)); 60 | } 61 | 62 | static inline void 63 | outl (u32 value, u16 port) 64 | { 65 | __asm__ __volatile__ ("outl (%w1)": :"a" (value), "Nd" (port)); 66 | } 67 | -------------------------------------------------------------------------------- /ddio_tools/pciutils-3.5.1/lib/libpci.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@PREFIX@ 2 | includedir=@INCDIR@ 3 | libdir=@LIBDIR@ 4 | idsdir=@IDSDIR@ 5 | 6 | Name: libpci 7 | Description: libpci 8 | Version: @VERSION@ 9 | Libs: -L${libdir} -lpci 10 | Libs.private: @LDLIBS@ 11 | Cflags: -I${includedir} 12 | -------------------------------------------------------------------------------- /ddio_tools/pciutils-3.5.1/lib/libpci.ver: -------------------------------------------------------------------------------- 1 | /* Version script for the libpci */ 2 | 3 | /* 4 | * Visibility declarations in the source take precedence over this script, 5 | * so we can boldly declare pci_* as public and still keep the internal 6 | * functions properly hidden. 7 | */ 8 | 9 | LIBPCI_3.0 { 10 | global: 11 | pci_alloc; 12 | pci_cleanup; 13 | pci_fill_info; 14 | pci_filter_init; 15 | pci_filter_match; 16 | pci_filter_parse_id; 17 | pci_filter_parse_slot; 18 | pci_free_dev; 19 | pci_free_name_list; 20 | pci_get_dev; 21 | pci_get_method_name; 22 | pci_get_param; 23 | pci_id_cache_flush; 24 | pci_init; 25 | pci_load_name_list; 26 | pci_lookup_method; 27 | pci_lookup_name; 28 | pci_read_block; 29 | pci_read_byte; 30 | pci_read_long; 31 | pci_read_word; 32 | pci_scan_bus; 33 | pci_set_name_list_path; 34 | pci_set_param; 35 | pci_setup_cache; 36 | pci_walk_params; 37 | pci_write_block; 38 | pci_write_byte; 39 | pci_write_long; 40 | pci_write_word; 41 | local: *; 42 | }; 43 | 44 | LIBPCI_3.1 { 45 | global: 46 | pci_fill_info; 47 | pci_find_cap; 48 | pci_read_vpd; 49 | }; 50 | 51 | LIBPCI_3.2 { 52 | global: 53 | pci_fill_info; 54 | }; 55 | 56 | LIBPCI_3.3 { 57 | global: 58 | pci_fill_info; 59 | pci_filter_init; 60 | pci_filter_match; 61 | pci_filter_parse_id; 62 | pci_filter_parse_slot; 63 | }; 64 | 65 | LIBPCI_3.4 { 66 | global: 67 | pci_fill_info; 68 | }; 69 | 70 | LIBPCI_3.5 { 71 | global: 72 | pci_init; 73 | pci_fill_info; 74 | }; 75 | -------------------------------------------------------------------------------- /ddio_tools/pciutils-3.5.1/lib/types.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The PCI Library -- Types and Format Strings 3 | * 4 | * Copyright (c) 1997--2008 Martin Mares 5 | * 6 | * Can be freely distributed and used under the terms of the GNU GPL. 7 | */ 8 | 9 | #include 10 | 11 | #ifndef PCI_HAVE_Uxx_TYPES 12 | 13 | #ifdef PCI_OS_WINDOWS 14 | #include 15 | typedef BYTE u8; 16 | typedef WORD u16; 17 | typedef DWORD u32; 18 | #elif defined(PCI_HAVE_STDINT_H) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) 19 | #include 20 | typedef uint8_t u8; 21 | typedef uint16_t u16; 22 | typedef uint32_t u32; 23 | #else 24 | typedef u_int8_t u8; 25 | typedef u_int16_t u16; 26 | typedef u_int32_t u32; 27 | #endif 28 | 29 | #ifdef PCI_HAVE_64BIT_ADDRESS 30 | #include 31 | #if ULONG_MAX > 0xffffffff 32 | typedef unsigned long u64; 33 | #define PCI_U64_FMT "l" 34 | #else 35 | typedef unsigned long long u64; 36 | #define PCI_U64_FMT "ll" 37 | #endif 38 | #endif 39 | 40 | #endif /* PCI_HAVE_Uxx_TYPES */ 41 | 42 | #ifdef PCI_HAVE_64BIT_ADDRESS 43 | typedef u64 pciaddr_t; 44 | #define PCIADDR_T_FMT "%08" PCI_U64_FMT "x" 45 | #define PCIADDR_PORT_FMT "%04" PCI_U64_FMT "x" 46 | #else 47 | typedef u32 pciaddr_t; 48 | #define PCIADDR_T_FMT "%08x" 49 | #define PCIADDR_PORT_FMT "%04x" 50 | #endif 51 | 52 | #ifdef PCI_ARCH_SPARC64 53 | /* On sparc64 Linux the kernel reports remapped port addresses and IRQ numbers */ 54 | #undef PCIADDR_PORT_FMT 55 | #define PCIADDR_PORT_FMT PCIADDR_T_FMT 56 | #define PCIIRQ_FMT "%08x" 57 | #else 58 | #define PCIIRQ_FMT "%d" 59 | #endif 60 | 61 | #if defined(__GNUC__) && __GNUC__ > 2 62 | #define PCI_PRINTF(x,y) __attribute__((format(printf, x, y))) 63 | #else 64 | #define PCI_PRINTF(x,y) 65 | #endif 66 | -------------------------------------------------------------------------------- /ddio_tools/pciutils-3.5.1/maint/RELEASE: -------------------------------------------------------------------------------- 1 | How to release pciutils 2 | ~~~~~~~~~~~~~~~~~~~~~~~ 3 | (a couple of hints for the forgetful maintainer) 4 | 5 | Update pci.ids. 6 | 7 | Check version numbers in Makefile and lib/pci.h. 8 | 9 | ssh-add ~/.ssh/id_korg 10 | 11 | maint/tag-release vX.Y.Z 12 | git push --tags 13 | 14 | maint/release 15 | 16 | Update progs/pciutils at Jabberwock. 17 | 18 | Check that everything was pushed to both kernel.org and github.com. 19 | -------------------------------------------------------------------------------- /ddio_tools/pciutils-3.5.1/maint/gen-zone: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -w 2 | # Create a DNS zone with PCI ID records 3 | 4 | use strict; 5 | 6 | my %ids = (); 7 | my %comments = (); 8 | foreach our $file (@ARGV) { 9 | my $fn = ($file =~ /\.gz$/) ? "zcat $file |" : ($file =~ /\.bz2$/) ? "bzcat $file |" : $file; 10 | open F, $fn or die "Unable to open $file: $!"; 11 | my @id = (); 12 | my $comm = ""; 13 | sub err($) { 14 | print STDERR "Error in $file, line $.: @_\n"; 15 | exit 1; 16 | } 17 | while () { 18 | if (/^(#.*)/) { 19 | $comm .= $_; 20 | next; 21 | } 22 | chomp; 23 | if (my ($indent, $id, $ignored, $name) = /^(\t*)(([0-9a-fA-Z]+ ?)*)(( |\t|$)\s*(.*))$/) { 24 | my $depth = length $indent; 25 | $depth <= @id or err "Mismatched indentation"; 26 | @id = (@id[0..$depth-1], $id); 27 | my $i = join(":", @id); 28 | if ($i ne "") { 29 | !exists $ids{$i} or die "ID $i defined twice"; 30 | $ids{$i} = $name; 31 | $comments{$i} = $comm if $comm; 32 | } 33 | } elsif (!/^$/) { 34 | err "Parse error"; 35 | } 36 | $comm = ""; 37 | } 38 | close F; 39 | } 40 | 41 | sub esc($) { 42 | my ($x) = @_; 43 | $x =~ s/^\s+//; 44 | $x =~ s/"/\\"/g; 45 | return $x; 46 | } 47 | 48 | foreach my $i (keys %ids) { 49 | my $j = join(".", reverse split(/[: ]/, $i)); 50 | print "$j.pci\tTXT \"i=", esc($ids{$i}), "\"\n"; 51 | # print "$j.pci\tTXT \"c=", esc($comments{$i}), "\"\n" 52 | } 53 | -------------------------------------------------------------------------------- /ddio_tools/pciutils-3.5.1/maint/tag-release: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | if [ -z "$1" -o -n "$2" ] ; then 3 | echo >&2 'Usage: tag-release vX.Y.Z' 4 | exit 1 5 | fi 6 | git tag -u ED70F82D $1 7 | -------------------------------------------------------------------------------- /ddio_tools/pciutils-3.5.1/pciutils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The PCI Utilities -- Declarations 3 | * 4 | * Copyright (c) 1997--2008 Martin Mares 5 | * 6 | * Can be freely distributed and used under the terms of the GNU GPL. 7 | */ 8 | 9 | #include "lib/pci.h" 10 | #include "lib/sysdep.h" 11 | 12 | #ifdef PCI_OS_WINDOWS 13 | #include "compat/getopt.h" 14 | #else 15 | #include 16 | #endif 17 | 18 | #define PCIUTILS_VERSION PCILIB_VERSION 19 | 20 | extern const char program_name[]; 21 | 22 | void die(char *msg, ...) NONRET PCI_PRINTF(1,2); 23 | void *xmalloc(unsigned int howmuch); 24 | void *xrealloc(void *ptr, unsigned int howmuch); 25 | char *xstrdup(char *str); 26 | int parse_generic_option(int i, struct pci_access *pacc, char *optarg); 27 | 28 | #ifdef PCI_HAVE_PM_INTEL_CONF 29 | #define GENOPT_INTEL "H:" 30 | #define GENHELP_INTEL "-H \tUse direct hardware access ( = 1 or 2)\n" 31 | #else 32 | #define GENOPT_INTEL 33 | #define GENHELP_INTEL 34 | #endif 35 | #if defined(PCI_HAVE_PM_DUMP) && !defined(PCIUTILS_SETPCI) 36 | #define GENOPT_DUMP "F:" 37 | #define GENHELP_DUMP "-F \tRead PCI configuration dump from a given file\n" 38 | #else 39 | #define GENOPT_DUMP 40 | #define GENHELP_DUMP 41 | #endif 42 | 43 | #define GENERIC_OPTIONS "A:GO:" GENOPT_INTEL GENOPT_DUMP 44 | #define GENERIC_HELP \ 45 | "-A \tUse the specified PCI access method (see `-A help' for a list)\n" \ 46 | "-O =\tSet PCI access parameter (see `-O help' for a list)\n" \ 47 | "-G\t\tEnable PCI access debugging\n" \ 48 | GENHELP_INTEL GENHELP_DUMP 49 | -------------------------------------------------------------------------------- /ddio_tools/pciutils-3.5.1/pciutils.lsm: -------------------------------------------------------------------------------- 1 | Begin3 2 | Title: The PCI Utilities 3 | Version: 3.5.1 4 | Entered-date: 160522 5 | Description: This package contains various utilities for inspecting and 6 | setting of devices connected to the PCI bus. 7 | Keywords: kernel, pci, lspci, setpci, libpci 8 | Author: mj@ucw.cz (Martin Mares) 9 | Maintained-by: mj@ucw.cz (Martin Mares) 10 | Primary-site: atrey.karlin.mff.cuni.cz pub/linux/pci/pciutils-3.5.1.tar.gz 11 | Alternate-site: ftp.kernel.org pub/software/utils/pciutils/pciutils-3.5.1.tar.gz 12 | Alternate-site: metalab.unc.edu pub/Linux/hardware/pciutils-3.5.1.tar.gz 13 | Copying-policy: GPL 14 | End 15 | -------------------------------------------------------------------------------- /ddio_tools/pciutils-3.5.1/pciutils.spec: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SJTU-IPADS/librdpma/5216d108dd5496e8428c473134012c12dae54f5c/ddio_tools/pciutils-3.5.1/pciutils.spec -------------------------------------------------------------------------------- /ddio_tools/pciutils-3.5.1/tests/cap-MSI-mapping: -------------------------------------------------------------------------------- 1 | 0a:01.0 PCI bridge: Broadcom HT2100 PCI-Express Bridge (rev a2) (prog-if 01 [Subtractive decode]) 2 | 00: 66 11 40 01 47 00 10 00 a2 01 04 06 40 00 01 00 3 | 10: 00 00 00 00 00 00 00 00 0a 0b 0b 00 51 51 00 20 4 | 20: 60 ff 60 ff f1 ff 01 00 ff ff ff ff 00 00 00 00 5 | 30: 00 00 00 00 a0 00 00 00 00 00 00 00 00 01 01 00 6 | 40: 00 00 00 00 01 00 01 00 01 00 00 00 00 00 01 00 7 | 50: 08 00 a1 00 20 00 11 11 40 00 11 77 40 05 75 00 8 | 60: 02 00 75 00 00 00 00 00 00 00 00 00 0c 05 03 03 9 | 70: 00 00 00 00 00 00 00 00 0d 50 00 00 00 00 00 00 10 | 80: 05 78 82 00 00 00 00 00 00 00 00 00 00 00 00 00 11 | 90: 00 00 00 00 00 00 00 00 01 80 03 c8 08 00 00 00 12 | a0: 08 b0 01 a8 00 00 e0 fe 0f 00 00 00 00 00 00 00 13 | b0: 10 98 41 00 02 80 00 00 10 08 00 00 01 6d 1a 01 14 | c0: 08 00 81 20 00 00 08 00 c0 03 48 01 00 00 00 00 15 | d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 16 | e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 17 | f0: 01 00 08 01 00 00 00 00 00 00 00 00 00 00 00 03 18 | -------------------------------------------------------------------------------- /ddio_tools/pciutils-3.5.1/tests/cap-debug-port: -------------------------------------------------------------------------------- 1 | 0000:00:02.1 USB Controller: nVidia Corporation CK804 USB Controller (rev a3) 2 | 00: de 10 5b 00 06 00 b0 00 a3 20 03 0c 00 00 80 00 3 | 10: 00 00 b0 fe 00 00 00 00 00 00 00 00 00 00 00 00 4 | 20: 00 00 00 00 00 00 00 00 00 00 00 00 62 14 85 71 5 | 30: 00 00 00 00 44 00 00 00 00 00 00 00 03 02 03 01 6 | 40: 62 14 85 71 0a 80 98 20 00 00 00 00 00 00 00 00 7 | 50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 8 | 60: 20 20 01 00 00 60 18 85 03 3c 3f 01 00 00 00 00 9 | 70: 00 00 08 05 00 10 20 80 89 3d b6 22 77 25 04 00 10 | 80: 01 00 02 fe 00 00 00 00 00 00 00 00 15 16 00 00 11 | 90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 12 | a0: 01 00 00 00 00 00 08 c0 00 00 00 00 00 00 00 00 13 | b0: 00 11 22 33 44 00 00 00 ff 03 00 00 00 00 00 00 14 | c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 15 | d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 16 | e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 17 | f0: 00 00 00 00 00 00 00 00 10 ff ff ff 00 00 30 07 18 | -------------------------------------------------------------------------------- /ddio_tools/pciutils-3.5.1/tests/cap-l1-pm: -------------------------------------------------------------------------------- 1 | Sample lspci -vvxxxx output showing first 8 bytes of extended config space for 2 | the L1 Substate Capability. Cannot show more since hardware is unreleased. 3 | 4 | MJ: Added fake header, so that the test parses. 5 | 6 | 00:1c.0 PCI bridge: 7 | Capabilities: [200 v1] L1 PM Substates 8 | L1SubCap: PCI-PM_L1.2+, PCI-PM_L1.1+, ASPM_L1.2+, ASPM_L1.1+, L1_PM_Substates+ 9 | PortCommonModeRestoreTime=40us, PortTPowerOnTime=10us 10 | 00: 86 80 08 34 47 01 10 00 12 00 04 06 10 00 01 00 11 | 10: 00 00 00 00 00 00 00 00 00 01 01 00 10 10 00 00 12 | 20: 00 e0 90 e0 81 c7 f1 c7 00 00 00 00 00 00 00 00 13 | 30: 00 00 00 00 40 00 00 00 00 00 00 00 0b 01 00 00 14 | 40: 0d 60 00 00 86 80 53 4f 00 00 00 00 00 00 00 00 15 | 50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 16 | 60: 05 90 02 01 20 00 00 00 00 00 00 00 00 00 00 00 17 | 70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 18 | 80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 19 | 90: 10 e0 42 01 21 80 00 00 20 00 00 00 42 3c 39 01 20 | a0: 42 00 41 70 1f 00 02 02 c0 07 48 01 00 00 01 00 21 | b0: 00 00 00 00 3e 00 00 00 39 00 00 00 00 00 00 00 22 | c0: 11 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 23 | d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 24 | e0: 01 00 03 c8 00 00 00 00 00 00 00 00 00 00 00 00 25 | f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 26 | 100: 1e 00 01 00 1f 28 28 00 27 | -------------------------------------------------------------------------------- /ddio_tools/pciutils-3.5.1/tests/cap-pci-af: -------------------------------------------------------------------------------- 1 | 00:1d.0 USB Controller: Intel Corporation 82801JI (ICH10 Family) USB UHCI Controller #1 (prog-if 00 [UHCI]) 2 | Subsystem: Intel Corporation Device 4f53 3 | Control: I/O+ Mem- BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx- 4 | Status: Cap+ 66MHz- UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- SERR- . 34 | -------------------------------------------------------------------------------- /ddio_tools/pciutils-3.5.1/win32/config.h: -------------------------------------------------------------------------------- 1 | #define PCI_ARCH_I386 2 | #define PCI_OS_WINDOWS 3 | #define PCI_HAVE_PM_INTEL_CONF 4 | #define PCI_IDS "pci.ids" 5 | #define PCI_PATH_IDS_DIR "." 6 | #define PCILIB_VERSION "3.5.1" 7 | -------------------------------------------------------------------------------- /ddio_tools/pciutils-3.5.1/win32/config.mk: -------------------------------------------------------------------------------- 1 | # TOOLPREFIX is for cross compiling 2 | 3 | CC=$(TOOLPREFIX)gcc 4 | LD=$(TOOLPREFIX)ld 5 | AR=$(TOOLPREFIX)ar 6 | RANLIB=$(TOOLPREFIX)ranlib 7 | 8 | PCI_ARCH_I386=yes 9 | PCI_OS_WINDOWS=yes 10 | PCI_HAVE_PM_INTEL_CONF=yes 11 | 12 | PCILIB=$(LIBNAME).a 13 | PCILIBPC=$(LIBNAME).pc 14 | -------------------------------------------------------------------------------- /nvm/benchs/gen_addr.hh: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "rlib/tests/random.hh" 4 | 5 | #include "r2/src/common.hh" 6 | 7 | namespace nvm { 8 | 9 | class RandomAddr { 10 | const ::r2::u64 space = 0; 11 | const ::r2::u64 off = 0; 12 | 13 | public: 14 | explicit RandomAddr(const ::r2::u64 &space, const ::r2::u64 off) 15 | : space(space), off(off) {} 16 | ::r2::u64 gen(::test::FastRandom &rand) { 17 | return (off + rand.next() % space) + off; 18 | } 19 | }; 20 | 21 | class SeqAddr { 22 | public: 23 | const ::r2::u64 space = 0; 24 | const ::r2::u64 off = 0; 25 | ::r2::u64 cur_off = 0; 26 | 27 | explicit SeqAddr(const ::r2::u64 &space, const ::r2::u64 off) : space(space), off(off) {} 28 | 29 | ::r2::u64 gen(const ::r2::u64 &step) { 30 | auto res = off + cur_off % space; 31 | cur_off += step; 32 | return res; 33 | } 34 | }; 35 | 36 | } // namespace nvm 37 | -------------------------------------------------------------------------------- /nvm/benchs/latency.hh: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | #include "r2/src/common.hh" 5 | 6 | namespace nvm { 7 | 8 | /*! 9 | Only record the *average* latency. 10 | */ 11 | struct FlatLatRecorder { 12 | double cur_lat = 0.0; 13 | ::r2::u64 counts = 1; 14 | 15 | FlatLatRecorder() = default; 16 | 17 | double get_lat() const { return cur_lat; } 18 | 19 | void add_one(double lat) { 20 | cur_lat += (lat - cur_lat) / counts; 21 | counts += 1; 22 | } 23 | }; 24 | 25 | } // namespace nvm 26 | -------------------------------------------------------------------------------- /nvm/benchs/nt_memcpy.hh: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace nvm { 7 | 8 | 9 | } // namespace nvm 10 | -------------------------------------------------------------------------------- /nvm/benchs/one_sided/bandwidth.cc~: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "rlib/core/lib.hh" 4 | -------------------------------------------------------------------------------- /nvm/benchs/one_sided/local_bandwidth.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "../../nvm_region.hh" 4 | 5 | using namespace nvm; 6 | 7 | #include "../two_sided/core.hh" 8 | 9 | DEFINE_uint32(payload, 2, "The sequential write payload ()"); 10 | 11 | int main(int argc, char **argv) { 12 | 13 | gflags::ParseCommandLineFlags(&argc, &argv, true); 14 | 15 | r2::Timer timer; 16 | u64 write_transfered = 0; 17 | u64 write_cnt = 0; 18 | 19 | char *local_mem = new char[FLAGS_payload]; 20 | 21 | u32 off = 0; 22 | while (true) { 23 | // perform write 24 | // 4096 ensures that in the same DIMM 25 | write_transfered += nt_memcpy(local_mem, FLAGS_payload, dst + off % 4096); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /nvm/benchs/one_sided/local_bandwidth.cc~: -------------------------------------------------------------------------------- 1 | #include "../../nvm_region.hh" 2 | 3 | using namespace nvm; 4 | -------------------------------------------------------------------------------- /nvm/benchs/thread.hh: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace nvm { 8 | 9 | /*! 10 | This is a simple wrapper over pthread, which uses a more abstracted way to create threads. 11 | T: the return type of the thread. 12 | 13 | Example: 14 | To create one thread using the function `fn run() -> T`, one can use the following way: 15 | auto t = Thread([]() -> T { 16 | T res; 17 | return res; 18 | }); 19 | t.start(); // really run the thread 20 | t.join(); // wait for it to stop 21 | */ 22 | template 23 | class alignas(128) Thread 24 | { 25 | using thread_body_t = std::function; 26 | 27 | thread_body_t core_func; 28 | T res; 29 | pthread_t pid; // pthread id 30 | 31 | public: 32 | explicit Thread(const thread_body_t& b) 33 | : core_func(b) 34 | {} 35 | 36 | void start() 37 | { 38 | pthread_attr_t attr; 39 | assert(pthread_attr_init(&attr) == 0); 40 | assert(pthread_create(&pid, &attr, pthread_bootstrap, (void*)this) == 0); 41 | assert(pthread_attr_destroy(&attr) == 0); 42 | } 43 | 44 | T join() 45 | { 46 | assert(pthread_join(pid, nullptr) == 0); 47 | return get_res(); 48 | } 49 | 50 | T get_res() const { return res; } 51 | 52 | private: 53 | // TODO: what if the sizeof(T) is very large? 54 | static_assert(sizeof(T) < (128 - sizeof(thread_body_t) - sizeof(pthread_t)), 55 | "xx"); 56 | char padding[128 - (sizeof(thread_body_t) + sizeof(T) + sizeof(pthread_t))]; 57 | 58 | static void* pthread_bootstrap(void* p) 59 | { 60 | Thread* self = static_cast(p); 61 | self->res = self->core_func(); 62 | return nullptr; 63 | } 64 | }; 65 | 66 | } 67 | -------------------------------------------------------------------------------- /nvm/benchs/timer.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace r2 { 6 | /** 7 | * a simple wrapper over std::time API 8 | */ 9 | class Timer { 10 | public: 11 | static const constexpr double no_timeout = std::numeric_limits::max(); 12 | 13 | Timer(std::chrono::time_point t = std::chrono::steady_clock::now()) 14 | : start_time_(t) { 15 | } 16 | 17 | ~Timer() = default; 18 | 19 | template 20 | bool timeout(double count) const { 21 | return passed() >= count; 22 | } 23 | 24 | double passed_sec() const { 25 | return passed(); 26 | } 27 | 28 | double passed_msec() const { 29 | return passed(); 30 | } 31 | 32 | template double passed() const { 33 | return passed(std::chrono::steady_clock::now()); 34 | } 35 | 36 | template double 37 | passed(std::chrono::time_point tt) const { 38 | const auto elapsed = std::chrono::duration_cast( 39 | tt - start_time_); 40 | return elapsed.count(); 41 | } 42 | 43 | void reset() { 44 | start_time_ = std::chrono::steady_clock::now(); 45 | } 46 | 47 | Timer& operator=(Timer&) = default; 48 | private: 49 | std::chrono::time_point start_time_; 50 | }; 51 | 52 | } // end namespace r2 53 | -------------------------------------------------------------------------------- /nvm/benchs/two_sided/avx_512.hh: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // credit: code from 4 | // https : // github.com/NVSL/OptaneStudy/blob/master/src/kernel/memaccess.c 5 | 6 | #define SIZEBTNT_64_AVX512 \ 7 | "vmovntdq %%zmm0, 0x0(%%r9, %%r10) \n" \ 8 | "add $0x40, %%r10 \n" 9 | 10 | #define SIZEBTLD_FENCE "" 11 | 12 | namespace nvm { 13 | 14 | 15 | void stride_nt(char *start_addr, long size, long skip, long delay, long count) { 16 | asm volatile( 17 | "xor %%r8, %%r8 \n" /* r8: access offset */ 18 | "xor %%r11, %%r11 \n" /* r11: counter */ 19 | "movq %[start_addr], %%xmm0 \n" /* zmm0: read/write register */ 20 | // 1 21 | "LOOP_STRIDENT_OUTER: \n" /* outer (counter) loop */ 22 | "lea (%[start_addr], %%r8), %%r9 \n" /* r9: access loc */ 23 | "xor %%r10, %%r10 \n" /* r10: accessed size */ 24 | "LOOP_STRIDENT_INNER: \n" /* inner (access) loop, unroll 8 times */ 25 | SIZEBTNT_64_AVX512 /* Access: uses r10[size_accessed], r9 */ 26 | "cmp %[accesssize], %%r10 \n" 27 | "jl LOOP_STRIDENT_INNER \n" SIZEBTLD_FENCE 28 | 29 | "xor %%r10, %%r10 \n" 30 | "LOOP_STRIDENT_DELAY: \n" /* delay cycles */ 31 | "inc %%r10 \n" 32 | "cmp %[delay], %%r10 \n" 33 | "jl LOOP_STRIDENT_DELAY \n" 34 | 35 | "add %[skip], %%r8 \n" 36 | "inc %%r11 \n" 37 | "cmp %[count], %%r11 \n" 38 | 39 | "jl LOOP_STRIDENT_OUTER \n" 40 | 41 | ::[start_addr] "r"(start_addr), 42 | [accesssize] "r"(size), [count] "r"(count), [skip] "r"(skip), 43 | [delay] "r"(delay) 44 | : "%r11", "%r10", "%r9", "%r8"); 45 | } 46 | } // namespace nvm 47 | -------------------------------------------------------------------------------- /nvm/benchs/two_sided/avx_512.hh~: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace nvm { 4 | 5 | void stride_nt() { 6 | asm volatile( 7 | "xor %%r8, %%r8 \n" /* r8: access offset */ 8 | "xor %%r11, %%r11 \n" /* r11: counter */ 9 | "movq %[start_addr], %%xmm0 \n" /* zmm0: read/write register */ 10 | // 1 11 | "LOOP_STRIDENT_OUTER: \n" /* outer (counter) loop */ 12 | "lea (%[start_addr], %%r8), %%r9 \n" /* r9: access loc */ 13 | "xor %%r10, %%r10 \n" /* r10: accessed size */ 14 | "LOOP_STRIDENT_INNER: \n" /* inner (access) loop, unroll 8 times */ 15 | SIZEBTNT_64_AVX512 /* Access: uses r10[size_accessed], r9 */ 16 | "cmp %[accesssize], %%r10 \n" 17 | "jl LOOP_STRIDENT_INNER \n" SIZEBTLD_FENCE 18 | 19 | "xor %%r10, %%r10 \n" 20 | "LOOP_STRIDENT_DELAY: \n" /* delay cycles */ 21 | "inc %%r10 \n" 22 | "cmp %[delay], %%r10 \n" 23 | "jl LOOP_STRIDENT_DELAY \n" 24 | 25 | "add %[skip], %%r8 \n" 26 | "inc %%r11 \n" 27 | "cmp %[count], %%r11 \n" 28 | 29 | "jl LOOP_STRIDENT_OUTER \n" 30 | 31 | ::[start_addr] "r"(start_addr), 32 | [ accesssize ] "r"(size), [ count ] "r"(count), [ skip ] "r"(skip), 33 | [ delay ] "r"(delay) 34 | : "%r11", "%r10", "%r9", "%r8"); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /nvm/benchs/two_sided/constants.hh: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "r2/src/common.hh" 4 | 5 | namespace nvm { 6 | 7 | using namespace r2; 8 | 9 | const usize ring_sz = 4096 * 4096; 10 | const usize max_msg_sz = 8192; 11 | const usize ring_entry = 128; 12 | 13 | } // namespace nvm 14 | -------------------------------------------------------------------------------- /nvm/benchs/two_sided/proto.hh: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "rlib/core/qps/ud.hh" 4 | #include "rlib/core/common.hh" 5 | 6 | #include "rlib/core/rmem/handler.hh" 7 | 8 | namespace nvm { 9 | 10 | using namespace rdmaio; 11 | using namespace rdmaio::qp; 12 | 13 | enum MsgType : u8 { Req = 0, Reply, Connect, ConnectR }; 14 | 15 | struct __attribute__((packed)) MsgHeader { 16 | MsgType type; 17 | u32 magic = 73; 18 | u32 coro_id = 0; 19 | u32 sz = 0; 20 | } __attribute__((aligned(sizeof(uint64_t)))); 21 | 22 | /*! 23 | used for UD connect 24 | */ 25 | struct __attribute__((packed)) ConnectReq { 26 | QPAttr attr; 27 | } __attribute__((aligned(sizeof(uint64_t)))) ; 28 | 29 | /*! 30 | used for RC connect 31 | */ 32 | struct __attribute__((packed)) ConnectReq2 { 33 | RegAttr attr; 34 | } __attribute__((aligned(sizeof(uint64_t)))); 35 | 36 | struct __attribute__((packed)) ConnectReply { 37 | u32 session_id; 38 | u32 coro_id; 39 | } __attribute__((aligned(sizeof(uint64_t)))); 40 | 41 | struct __attribute__((packed)) Request { 42 | u64 payload; 43 | u64 addr; 44 | u8 read = 0; // if read == 1, just read the value 45 | } __attribute__((aligned(sizeof(uint64_t)))); 46 | }// namespace nvm 47 | -------------------------------------------------------------------------------- /nvm/benchs/two_sided/r740.hh: -------------------------------------------------------------------------------- 1 | /*! 2 | The lscpu setup of r740. 3 | */ 4 | namespace nvm { 5 | 6 | static const int per_socket_cores = 20; 7 | 8 | #if 1 9 | static int socket_zero[] = {0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 10 | 20, 22, 24, 26, 28, 30, 32, 34, 36, 38}; 11 | 12 | static int socket_one[] = {1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 13 | 21, 23, 25, 27, 29, 31, 33, 35, 37, 39}; 14 | #else 15 | 16 | // switch 17 | static int socket_one[] = {0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 18 | 20, 22, 24, 26, 28, 30, 32, 34, 36, 38}; 19 | 20 | static int socket_zero[] = {1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21 | 21, 23, 25, 27, 29, 31, 33, 35, 37, 39}; 22 | #endif 23 | 24 | inline int bind_to_core(int t_id) { 25 | 26 | if (t_id >= (per_socket_cores * 2)) 27 | return 0; 28 | 29 | int x = t_id; 30 | int y = 0; 31 | 32 | #ifdef SCALE 33 | assert(false); 34 | // specific binding for scale tests 35 | int mac_per_node = 16 / nthreads; // there are total 16 threads avialable 36 | int mac_num = current_partition % mac_per_node; 37 | 38 | if (mac_num < mac_per_node / 2) { 39 | y = socket_0[x + mac_num * nthreads]; 40 | } else { 41 | y = socket_one[x + (mac_num - mac_per_node / 2) * nthreads]; 42 | } 43 | #else 44 | // bind ,andway 45 | if (x >= per_socket_cores) { 46 | // there is no other cores in the first socket 47 | y = socket_one[x - per_socket_cores]; 48 | } else { 49 | y = socket_zero[x]; 50 | } 51 | 52 | #endif 53 | 54 | // fprintf(stdout,"worker: %d binding %d\n",x,y); 55 | cpu_set_t mask; 56 | CPU_ZERO(&mask); 57 | CPU_SET(y, &mask); 58 | sched_setaffinity(0, sizeof(mask), &mask); 59 | 60 | return 0; 61 | } 62 | 63 | } // namespace nvm 64 | -------------------------------------------------------------------------------- /nvm/benchs/two_sided/test.cc: -------------------------------------------------------------------------------- 1 | 2 | { 3 | RTMScope rtm; 4 | { 5 | // code protected by the RTM 6 | } 7 | }; 8 | -------------------------------------------------------------------------------- /nvm/benchs/two_sided/val19.hh: -------------------------------------------------------------------------------- 1 | /*! 2 | The lscpu setup of val19. 3 | */ 4 | namespace nvm { 5 | 6 | static const int per_socket_cores = 12; // TODO!! hard coded 7 | // const int per_socket_cores = 8;//reserve 2 cores 8 | 9 | static int socket_0[] = {0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 10 | 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46}; 11 | 12 | static int socket_1[] = {1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 13 | 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47}; 14 | 15 | int bind_to_core(int t_id) { 16 | 17 | if (t_id >= (per_socket_cores * 2)) 18 | return 0; 19 | 20 | int x = t_id; 21 | int y = 0; 22 | 23 | #ifdef SCALE 24 | assert(false); 25 | // specific binding for scale tests 26 | int mac_per_node = 16 / nthreads; // there are total 16 threads avialable 27 | int mac_num = current_partition % mac_per_node; 28 | 29 | if (mac_num < mac_per_node / 2) { 30 | y = socket_0[x + mac_num * nthreads]; 31 | } else { 32 | y = socket_one[x + (mac_num - mac_per_node / 2) * nthreads]; 33 | } 34 | #else 35 | // bind ,andway 36 | if (x >= per_socket_cores) { 37 | // there is no other cores in the first socket 38 | y = socket_0[x - per_socket_cores]; 39 | } else { 40 | y = socket_1[x]; 41 | } 42 | 43 | #endif 44 | 45 | // fprintf(stdout,"worker: %d binding %d\n",x,y); 46 | cpu_set_t mask; 47 | CPU_ZERO(&mask); 48 | CPU_SET(y, &mask); 49 | sched_setaffinity(0, sizeof(mask), &mask); 50 | 51 | return 0; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /nvm/docs/Understanding-Performance-of-PCI-Express-Systems.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SJTU-IPADS/librdpma/5216d108dd5496e8428c473134012c12dae54f5c/nvm/docs/Understanding-Performance-of-PCI-Express-Systems.pdf -------------------------------------------------------------------------------- /nvm/huge_region.hh: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "./memory_region.hh" 6 | 7 | namespace nvm { 8 | 9 | using namespace rdmaio; 10 | 11 | /*! 12 | Malloc huge pages in 2M huge pages 13 | */ 14 | class HugeRegion : public MemoryRegion { 15 | static u64 align_to_sz(const u64 &x, const usize &align_sz) { 16 | return (((x) + align_sz - 1) / align_sz * align_sz); 17 | } 18 | 19 | public: 20 | static ::rdmaio::Option> create(const u64 &sz, const usize &align_sz = (2 << 20)) { 21 | auto region = std::make_shared(sz,align_sz); 22 | if (region->valid()) 23 | return region; 24 | return {}; 25 | } 26 | 27 | explicit HugeRegion(const u64 &sz, const usize &align_sz = (2 << 20)) { 28 | 29 | this->sz = align_to_sz(sz + align_sz, align_sz); 30 | char *ptr = (char *)mmap( 31 | nullptr, this->sz, PROT_READ | PROT_WRITE, 32 | MAP_PRIVATE | MAP_ANONYMOUS | MAP_POPULATE | MAP_HUGETLB, -1, 0); 33 | 34 | if (ptr == MAP_FAILED) { 35 | this->addr = nullptr; 36 | RDMA_LOG(4) << "error allocating huge page wiht sz: " << this->sz 37 | << " aligned with: " << align_sz 38 | << "; with error: " << strerror(errno); 39 | } else { 40 | //RDMA_LOG(4) << "alloc huge page size: " << this->sz; 41 | this->addr = ptr; 42 | } 43 | } 44 | }; 45 | 46 | } // namespace nvm 47 | -------------------------------------------------------------------------------- /nvm/log_bundler.hh: -------------------------------------------------------------------------------- 1 | #pragma once 2 | -------------------------------------------------------------------------------- /nvm/memory_region.hh: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | // use some utilities (i.e., Option) defined in RLib 6 | #include "rlib/core/common.hh" 7 | #include "rlib/core/rmem/mem.hh" 8 | 9 | namespace nvm { 10 | 11 | using namespace rdmaio; 12 | 13 | struct MemoryRegion { 14 | u64 sz; // total region size 15 | 16 | void *addr = nullptr; // region 17 | 18 | void *start_ptr() const { return addr; } 19 | 20 | u64 size() const { return sz; } 21 | 22 | MemoryRegion() = default; 23 | 24 | MemoryRegion(const u64 &sz, void *addr) : sz(sz), addr(addr) {} 25 | 26 | virtual bool valid() { return addr != nullptr; } 27 | 28 | ::rdmaio::Option> convert_to_rmem() { 29 | if (!valid()) 30 | return {}; 31 | return std::make_shared(sz, [this](u64 s) { return addr; }, 32 | [](rmem::RMem::raw_ptr_t p) {}); 33 | } 34 | }; 35 | 36 | class DRAMRegion : public MemoryRegion { 37 | public: 38 | explicit DRAMRegion(const u64 &sz) : MemoryRegion(sz, malloc(sz)) { 39 | RDMA_ASSERT(this->addr != nullptr); 40 | } 41 | 42 | DRAMRegion(const u64 &sz, const int &numa_node) : MemoryRegion(sz, numa_alloc_onnode(sz, numa_node)) { 43 | RDMA_ASSERT(this->addr != nullptr); 44 | 45 | } 46 | 47 | static ::rdmaio::Option> create(const u64 &sz) { 48 | return std::make_shared(sz); 49 | } 50 | 51 | static ::rdmaio::Option> create(const u64 &sz,const int &numa) { 52 | return std::make_shared(sz,numa); 53 | } 54 | }; 55 | } // namespace nvm 56 | -------------------------------------------------------------------------------- /nvm/nvm/benchs/one_sided/aclient.cc: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /scripts/run_one.toml: -------------------------------------------------------------------------------- 1 | pwd="Genousw4036xx#" 2 | 3 | global_configs="--threads=10 --round_payload=64 --round_up=true --use_nic_idx=1 --remote_nic_idx=1 --random=true --cross_dimm=true --payload=16 --coros=8 --addr='r740:6666' --add_sync=false --address_space=5 --use_read=false --undefok=use_read,address_space,coros,window_sz,payload,add_sync,cross_dimm,random,use_nic_idx,round_up,threads,addr,remote_nic_idx,round_payload,threads" 4 | 5 | [[pass]] 6 | host = "r740" 7 | path = '~/projects/librdpma' 8 | cmd = 'sudo ./scripts/nvm_server --host=localhost --port=6666 -use_nvm=true -touch_mem=false --nvm_sz=10 --nvm_file=/dev/dax0.1 --numa_node=1' 9 | ## avaliable use cases: /dev/dax0.1 | /dev/dax1.3 10 | 11 | [[pass]] 12 | host = "val14" 13 | path = '/cock/librdpma' 14 | cmd = './scripts/nvm_client -addr="r740:6666" --coros=8 --id=0 --use_nic_idx=1 --use_read=false --payload=64 --add_sync=false --address_space=2 --random=true' 15 | 16 | [[pass]] 17 | host = "val15" 18 | path = '/cock/librdpma' 19 | cmd = './scripts/nvm_client -addr="r740:6666" --coros=8 --id=1 --use_nic_idx=1 --use_read=false --payload=64 --add_sync=false --address_space=2 --random=true' 20 | 21 | [[pass]] 22 | host = "val12" 23 | path = '/cock/librdpma' 24 | cmd = './scripts/nvm_client -addr="r740:6666" --coros=8 --id=2 --use_nic_idx=1 --use_read=false --payload=64 --add_sync=false --address_space=2 --random=true' 25 | 26 | -------------------------------------------------------------------------------- /sys/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SJTU-IPADS/librdpma/5216d108dd5496e8428c473134012c12dae54f5c/sys/.DS_Store -------------------------------------------------------------------------------- /sys/drtmh/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SJTU-IPADS/librdpma/5216d108dd5496e8428c473134012c12dae54f5c/sys/drtmh/.DS_Store -------------------------------------------------------------------------------- /sys/drtmh/.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "third_party/cpuinfo"] 2 | path = third_party/cpuinfo 3 | url = https://github.com/pytorch/cpuinfo.git 4 | [submodule "third_party/gflags"] 5 | path = third_party/gflags 6 | url = https://github.com/gflags/gflags.git 7 | [submodule "third_party/rib"] 8 | path = third_party/rib 9 | url = https://ipads.se.sjtu.edu.cn:1312/weixd/rib.git 10 | [submodule "third_party/r2"] 11 | path = third_party/r2 12 | url = https://github.com/wxdwfc/r2.git 13 | [submodule "third_party/rlib"] 14 | path = third_party/rlib 15 | url = https://github.com/wxdwfc/rlibv2.git 16 | -------------------------------------------------------------------------------- /sys/drtmh/cmake/gtest.cmake: -------------------------------------------------------------------------------- 1 | # Download and unpack googletest at configure time 2 | configure_file(cmake/gtest.cmake.in googletest-download/CMakeLists.txt) 3 | execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . 4 | RESULT_VARIABLE result 5 | WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/googletest-download ) 6 | if(result) 7 | message(FATAL_ERROR "CMake step for googletest failed: ${result}") 8 | endif() 9 | execute_process(COMMAND ${CMAKE_COMMAND} --build . 10 | RESULT_VARIABLE result 11 | WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/googletest-download ) 12 | if(result) 13 | message(FATAL_ERROR "Build step for googletest failed: ${result}") 14 | endif() 15 | 16 | # Prevent overriding the parent project's compiler/linker 17 | # settings on Windows 18 | set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) 19 | 20 | # Add googletest directly to our build. This defines 21 | # the gtest and gtest_main targets. 22 | add_subdirectory(${CMAKE_BINARY_DIR}/googletest-src 23 | ${CMAKE_BINARY_DIR}/googletest-build 24 | EXCLUDE_FROM_ALL) 25 | 26 | # The gtest/gtest_main targets carry header search path 27 | # dependencies automatically when using CMake 2.8.11 or 28 | # later. Otherwise we have to add them here ourselves. 29 | if (CMAKE_VERSION VERSION_LESS 2.8.11) 30 | include_directories("${gtest_SOURCE_DIR}/include") 31 | endif() -------------------------------------------------------------------------------- /sys/drtmh/cmake/gtest.cmake.in: -------------------------------------------------------------------------------- 1 | ## the cmake file imported from https://github.com/google/googletest/blob/master/googletest/README.md 2 | 3 | cmake_minimum_required(VERSION 2.8.2) 4 | 5 | project(googletest-download NONE) 6 | 7 | include(ExternalProject) 8 | ExternalProject_Add(googletest 9 | GIT_REPOSITORY https://github.com/google/googletest.git 10 | GIT_TAG master 11 | SOURCE_DIR "${CMAKE_BINARY_DIR}/googletest-src" 12 | BINARY_DIR "${CMAKE_BINARY_DIR}/googletest-build" 13 | CONFIGURE_COMMAND "" 14 | BUILD_COMMAND "" 15 | INSTALL_COMMAND "" 16 | TEST_COMMAND "" 17 | ) -------------------------------------------------------------------------------- /sys/drtmh/cmake/rocc.cmake: -------------------------------------------------------------------------------- 1 | function(load_global_config) 2 | configure_file("src/rocc_config.h.in" "src/rocc_config.h") 3 | endfunction() 4 | 5 | function(load_tx_config) 6 | 7 | if(TX_LOG_STYLE) 8 | else() 9 | set(TX_LOG_STYLE 2) ## default uses RPC as logging 10 | endif() 11 | 12 | if(PA) 13 | else() 14 | set(PA NULL) ## default uses RPC as logging 15 | endif() 16 | 17 | ## whether to record staleness counter for timestamp based methods 18 | if(RECORD_STALE) 19 | else() 20 | set(RECORD_STALE NULL) ## default uses RPC as logging 21 | endif() 22 | 23 | 24 | if(TX_BACKUP_STORE) 25 | else() 26 | set(TX_BACKUP_STORE 1) 27 | endif() 28 | 29 | 30 | if(ONE_SIDED_READ) 31 | else() 32 | set(ONE_SIDED_READ NULL) 33 | endif() 34 | 35 | if(USE_RDMA_COMMIT) 36 | else() 37 | set(USE_RDMA_COMMIT NULL) 38 | endif() 39 | 40 | if(RDMA_CACHE) 41 | else() 42 | set(RDMA_CACHE 0) 43 | endif() 44 | 45 | if(RDMA_STORE_SIZE) 46 | else() 47 | if(ONE_SIDED_READ) 48 | set(RDMA_STORE_SIZE 0) 49 | else() 50 | set(RDMA_STORE_SIZE 8) 51 | endif() 52 | endif() 53 | 54 | 55 | configure_file("src/tx_config.h.in" "src/tx_config.h") 56 | endfunction() -------------------------------------------------------------------------------- /sys/drtmh/cmake/tpce.cmake: -------------------------------------------------------------------------------- 1 | ## TPC-E related configurations 2 | ## current it's not well since not all file in *egen* is necessary 3 | set(EGEN_PREFIX src/app/tpce/egen/) 4 | file(GLOB TPCE_SOURCES 5 | "${EGEN_PREFIX}DateTime.cpp" "${EGEN_PREFIX}error.cpp" 6 | "${EGEN_PREFIX}Random.cpp" "${EGEN_PREFIX}Money.cpp" 7 | "${EGEN_PREFIX}EGenVersion.cpp" "${EGEN_PREFIX}locking.cpp" 8 | "${EGEN_PREFIX}threading.cpp" "${EGEN_PREFIX}BaseLogger.cpp" "${EGEN_PREFIX}EGenLogFormatterTab.cpp" 9 | "${EGEN_PREFIX}MEEPriceBoard.cpp" "${EGEN_PREFIX}MEESecurity.cpp" "${EGEN_PREFIX}MEETickerTape.cpp" 10 | "${EGEN_PREFIX}MEETradingFloor.cpp" "${EGEN_PREFIX}WheelTime.cpp" "${EGEN_PREFIX}AddressTable.cpp" 11 | "${EGEN_PREFIX}CustomerSelection.cpp" "${EGEN_PREFIX}CustomerTable.cpp" "${EGEN_PREFIX}InputFlatFilesStructure.cpp" 12 | "${EGEN_PREFIX}Person.cpp" "${EGEN_PREFIX}ReadRowFunctions.cpp" 13 | "${EGEN_PREFIX}TradeGen.cpp" "${EGEN_PREFIX}FlatFileLoader.cpp" "${EGEN_PREFIX}CE.cpp" "${EGEN_PREFIX}CETxnInputGenerator.cpp" 14 | "${EGEN_PREFIX}CETxnMixGenerator.cpp" "${EGEN_PREFIX}DM.cpp" "${EGEN_PREFIX}EGenGenerateAndLoad.cpp" "${EGEN_PREFIX}strutil.cpp" 15 | "${EGEN_PREFIX}progressmeter.cpp" "${EGEN_PREFIX}progressmeterinterface.cpp" "${EGEN_PREFIX}bucketsimulator.cpp") 16 | -------------------------------------------------------------------------------- /sys/drtmh/cmake/unit_tests.cmake: -------------------------------------------------------------------------------- 1 | add_executable(logger src/rtx/logger_test.cxx) 2 | target_link_libraries(logger gtest_main) 3 | target_link_libraries(logger 4 | ssmalloc 5 | boost_coroutine boost_chrono boost_thread boost_context boost_system ) 6 | add_test(NAME logger_test COMMAND logger) 7 | 8 | add_executable(op src/rtx/op_test.cxx) 9 | target_link_libraries(op gtest_main) 10 | target_link_libraries(op 11 | ssmalloc 12 | boost_coroutine boost_chrono boost_thread boost_context boost_system ) 13 | add_test(NAME operator_test COMMAND op) 14 | -------------------------------------------------------------------------------- /sys/drtmh/config_template.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 0 4 | 1 5 | 6 | 7 | 8 | 9 | noccrad 10 | 11 | 25 12 | 15 13 | 15 14 | 15 15 | 15 16 | 15 17 | 18 | 19 | 20 | 45 21 | 43 22 | 4 23 | 4 24 | 4 25 | 26 | 27 | 13 28 | 10 29 | 10 30 | 14 31 | 8 32 | 19 33 | 5 34 | 1 35 | 18 36 | 2 37 | 38 | 21 39 | 40 | -------------------------------------------------------------------------------- /sys/drtmh/scripts/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SJTU-IPADS/librdpma/5216d108dd5496e8428c473134012c12dae54f5c/sys/drtmh/scripts/.DS_Store -------------------------------------------------------------------------------- /sys/drtmh/scripts/awsrun.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | aws ec2 run-instances \ 4 | --image-id "ami-41695a24" \ 5 | --instance-type "r4.2xlarge" \ 6 | --key-name "tp" \ 7 | --monitoring '{"Enabled":false}' \ 8 | --security-group-ids "sg-2131064a" \ 9 | --instance-initiated-shutdown-behavior "stop" \ 10 | --subnet-id "subnet-fec85696" \ 11 | --count 5 12 | -------------------------------------------------------------------------------- /sys/drtmh/scripts/checker.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | from batch_bench_runner import parse_hosts 4 | from run_util import print_with_tag 5 | from subprocess import Popen, PIPE 6 | 7 | import sys 8 | 9 | def check_hugepage(): 10 | mac_set = parse_hosts() 11 | for m in mac_set: 12 | bcmd = "cat /sys/devices/system/node/node0/hugepages/hugepages-2048kB/nr_hugepages" 13 | stdout, stderr = Popen(['ssh',"-o","ConnectTimeout=1",m, bcmd], 14 | stdout=PIPE).communicate() 15 | huge_page_num = int(stdout) 16 | if (huge_page_num < 8192): 17 | print_with_tag("check","mac %s huge page %f failed" % (m,huge_page_num)) 18 | 19 | return 20 | 21 | def check_status(): 22 | mac_set = parse_hosts() 23 | for m in mac_set: 24 | bcmd = "ps aux | grep nocc" 25 | print("check " + m) 26 | stdout, stderr = Popen(['ssh',"-o","ConnectTimeout=1",m, bcmd], 27 | stdout=PIPE).communicate() 28 | print(stdout) 29 | return 30 | 31 | def check_log(): 32 | mac_set = parse_hosts() 33 | for m in mac_set: 34 | bcmd = "cat log" 35 | print("check " + m) 36 | stdout, stderr = Popen(['ssh',"-o","ConnectTimeout=1",m, bcmd], 37 | stdout=PIPE).communicate() 38 | print(stdout) 39 | return 40 | 41 | 42 | def main(): 43 | code = 0 44 | if len(sys.argv) > 1: 45 | code = int(sys.argv[1]) 46 | if code == 0: 47 | check_hugepage() 48 | if code == 1: 49 | check_status() 50 | if code == 2: 51 | check_log() 52 | 53 | return 54 | 55 | 56 | if __name__ == "__main__": 57 | main() 58 | -------------------------------------------------------------------------------- /sys/drtmh/scripts/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 1 3 | 12 4 | 1 5 | 14 6 | 0 7 | 8 | 25 9 | 15 10 | 15 11 | 15 12 | 15 13 | 15 14 | 15 | 16 | 17 | 100 18 | 0 19 | 0 20 | 0 21 | 0 22 | 23 | 24 | 25 | 100 26 | 27 | 28 | -------------------------------------------------------------------------------- /sys/drtmh/scripts/count_line.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | find "../src" -path '../' \ 3 | -prune -o -path '../src/app/tpce/egen' \ 4 | -prune -o -path '../src/port' \ 5 | -prune -o -path '../src/tests' \ 6 | -prune -o -path '../src/app' \ 7 | -prune -o -print \ 8 | | egrep '\.php|\.as|\.sql|\.css|\.js|\.cc|\.h|.cpp|.c ' \ 9 | | grep -v '\.svn' | xargs cat | sed '/^\s*$/d' \ 10 | | wc -l 11 | -------------------------------------------------------------------------------- /sys/drtmh/scripts/cp.toml: -------------------------------------------------------------------------------- 1 | [[pass]] 2 | host = "val19" 3 | path = '~/projects/rocc_nvm' 4 | cmd = 'cd scripts; ./cp.sh' 5 | -------------------------------------------------------------------------------- /sys/drtmh/scripts/drtmh-tpcc.toml: -------------------------------------------------------------------------------- 1 | global_configs="-p 6 -t 10 --bench tpcc" 2 | 3 | [[pass]] 4 | host = "r740" 5 | path = '~/projects/rocc_nvm' 6 | cmd = 'sudo ./scripts/noccocc --txn-flags 1 --verbose --config config.xml --id 0 -t 10 -c 8 -r 1 -p 3' 7 | 8 | [[pass]] 9 | host = "val19" 10 | path = '' 11 | cmd = './noccocc --txn-flags 1 --verbose --config config.xml --id 1 -t 10 -c 8 -r 100 -p 3' 12 | 13 | 14 | [[pass]] 15 | host = "val20" 16 | path = '' 17 | cmd = './noccocc --txn-flags 1 --verbose --config config.xml --id 2 -t 10 -c 8 -r 100 -p 3' 18 | 19 | 20 | [[pass]] 21 | host = "val21" 22 | path = '' 23 | cmd = './noccocc --txn-flags 1 --verbose --config config.xml --id 3 -t 10 -c 8 -r 100 -p 3' 24 | 25 | [[pass]] 26 | host = "val22" 27 | path = '' 28 | cmd = './noccocc --txn-flags 1 --verbose --config config.xml --id 4 -t 10 -c 8 -r 100 -p 3' 29 | 30 | [[pass]] 31 | host = "val23" 32 | path = '' 33 | cmd = './noccocc --txn-flags 1 --verbose --config config.xml --id 5 -t 10 -c 8 -r 100 -p 3' 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /sys/drtmh/scripts/drtmh.toml: -------------------------------------------------------------------------------- 1 | global_configs="-p 6 -t 10" 2 | 3 | [[pass]] 4 | host = "r740" 5 | path = '~/projects/rocc_nvm' 6 | cmd = 'sudo ./scripts/noccocc --bench bank --txn-flags 1 --verbose --config config.xml --id 0 -t 10 -c 1 -r 1 -p 3' 7 | 8 | [[pass]] 9 | host = "val19" 10 | path = '' 11 | cmd = './noccocc --bench bank --txn-flags 1 --verbose --config config.xml --id 1 -t 10 -c 8 -r 100 -p 3' 12 | 13 | 14 | [[pass]] 15 | host = "val20" 16 | path = '' 17 | cmd = './noccocc --bench bank --txn-flags 1 --verbose --config config.xml --id 2 -t 10 -c 8 -r 100 -p 3' 18 | 19 | 20 | [[pass]] 21 | host = "val21" 22 | path = '' 23 | cmd = './noccocc --bench bank --txn-flags 1 --verbose --config config.xml --id 3 -t 10 -c 8 -r 100 -p 3' 24 | 25 | [[pass]] 26 | host = "val22" 27 | path = '' 28 | cmd = './noccocc --bench bank --txn-flags 1 --verbose --config config.xml --id 4 -t 10 -c 8 -r 100 -p 3' 29 | 30 | [[pass]] 31 | host = "val23" 32 | path = '' 33 | cmd = './noccocc --bench bank --txn-flags 1 --verbose --config config.xml --id 5 -t 10 -c 8 -r 100 -p 3' 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /sys/drtmh/scripts/hosts.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | r740 5 | val19 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /sys/drtmh/scripts/kill.toml: -------------------------------------------------------------------------------- 1 | [[pass]] 2 | host = "val19" 3 | path = '~/projects/rocc_nvm' 4 | cmd = 'pkill nvm_client; pkill nvm_bandwith; pkill nvm_rrtclient; pkill noccocc; pkill nvm_rrtclient; pkill co_client; pkill nvm_server;' 5 | 6 | [[pass]] 7 | host = "val21" 8 | path = '~/projects/rocc_nvm' 9 | cmd = 'pkill nvm_client; pkill nvm_tclient; pkill noccocc; pkill nvm_rrtclient; pkill co_client;' 10 | 11 | [[pass]] 12 | host = "val22" 13 | path = '~/projects/rocc_nvm' 14 | cmd = 'pkill nvm_client; pkill nvm_tclient; pkill noccocc; pkill nvm_rrtclient; pkill co_client;' 15 | 16 | [[pass]] 17 | host = "val23" 18 | path = '' 19 | cmd = 'pkill nvm_client; pkill nvm_tclient; pkill noccocc; pkill nvm_rrtclient; pkill co_client;' 20 | 21 | [[pass]] 22 | host = "val20" 23 | path = '' 24 | cmd = 'pkill nvm_client; pkill nvm_tclient; pkill noccocc; pkill nvm_rrtclient; pkill co_client;' 25 | 26 | 27 | 28 | [[pass]] 29 | host = "r740" 30 | path = '~/projects/rocc_nvm' 31 | cmd = 'sudo pkill nvm_server; sudo pkill nvm_rrtserver; sudo pkill nvm_tserver; sudo pkill noccocc;' -------------------------------------------------------------------------------- /sys/drtmh/scripts/make.toml: -------------------------------------------------------------------------------- 1 | [[pass]] 2 | host = "r740" 3 | path = '~/projects/rocc_nvm' 4 | cmd = 'cmake . -DTX_LOG_STYLE=2 -DRDMA_CACHE=1 -DONE_SIDED_READ=1 -DPA=1 -DRDMA_STORE_SIZE=8192; make nvm_server; make nvm_client;make nvm_tserver; make nvm_rrtserver;make nvm_hello;make noccocc -j12;' 5 | 6 | [[pass]] 7 | host = "val19" 8 | path = '~/projects/rocc_nvm' 9 | cmd = 'cmake . -DTX_LOG_STYLE=2 -DRDMA_CACHE=1 -DONE_SIDED_READ=1 -DPA=1 -DRDMA_STORE_SIZE=8192; make nvm_client; make nvm_tclient; make nvm_rrtclient; make noccocc -j12; make nvm_bandwidth; make nvm_server;' 10 | 11 | 12 | -------------------------------------------------------------------------------- /sys/drtmh/scripts/module_test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | 4 | from run_test3 import calculate_results 5 | import sys 6 | 7 | 8 | if __name__ == "__main__": 9 | assert(len(sys.argv) > 1) 10 | log_file_name = sys.argv[1] 11 | 12 | print(calculate_results(log_file_name)) 13 | -------------------------------------------------------------------------------- /sys/drtmh/scripts/octopus.toml: -------------------------------------------------------------------------------- 1 | [[pass]] 2 | host = "r740" 3 | path = '~/projects/rocc_nvm' 4 | cmd = 'sudo ./scripts/nvm_server --host=localhost --port=8888 -use_nvm=false -touch_mem=false --nvm_sz=8 --nvm_file=/dev/dax1.3' 5 | 6 | [[pass]] 7 | host = "r740" 8 | path = '~/octopus' 9 | cmd = 'sudo ./dmfs' 10 | 11 | 12 | [[pass]] 13 | host = "val20" 14 | path = '~/octopus' 15 | cmd = 'sleep 1; /home/wxd/openmpi-install/bin/mpiexec -hostfile mpd.hosts -n 12 ./mpibw 64 100000' 16 | -------------------------------------------------------------------------------- /sys/drtmh/scripts/run_util.py: -------------------------------------------------------------------------------- 1 | ## helper functions for various script 2 | 3 | import os # for chdir 4 | 5 | ## print with color helper class 6 | class bcolors: 7 | HEADER = '\033[5;%s;2m' 8 | OKBLUE = '34' 9 | OKRED = '31' 10 | OKGREEN = '\033[92m' 11 | WARNING = '\033[93m' 12 | FAIL = '\033[91m' 13 | ENDC = '\033[0m' 14 | BOLD = '\033[1m' 15 | UNDERLINE = '\033[4m' 16 | 17 | @staticmethod 18 | def wrap_text_with_color(txt,c): 19 | return ("%s%s%s" % ((bcolors.HEADER % c),txt,bcolors.ENDC)) 20 | 21 | def print_with_tag(tag,s): 22 | tag = bcolors.wrap_text_with_color(tag,bcolors.OKRED) 23 | print "[%s] %s" % (tag,s) 24 | 25 | 26 | class PrintTee(object): 27 | def __init__(self,*files): 28 | self.files = files 29 | 30 | def write(self, obj): 31 | for f in self.files: 32 | f.write(obj) 33 | 34 | ## end class bcolors 35 | 36 | def change_to_parent(): 37 | os.chdir("..") 38 | return 39 | -------------------------------------------------------------------------------- /sys/drtmh/scripts/sync.toml: -------------------------------------------------------------------------------- 1 | #[[sync]] 2 | #source = "wxd@val19:~/projects/rocc_nvm/scripts/nvm_client" 3 | #targets = ["wxd@val21:~/projects/rocc_nvm/scripts/"] 4 | 5 | user = "weixingda" 6 | pwd = "genousw4036" 7 | 8 | [[pass]] 9 | host = "localhost" 10 | path = '/Users/weixingda/lab/rocc/scripts' 11 | cmd = './sync_to_client.sh val19' 12 | local = "yes" 13 | 14 | [[pass]] 15 | host = "localhost" 16 | path = '/Users/weixingda/lab/rocc/scripts' 17 | cmd = './sync_to_client.sh r740' 18 | local = "yes" 19 | 20 | 21 | 22 | [[pass]] 23 | host = "localhost" 24 | path = '/Users/weixingda/lab/rocc/scripts' 25 | cmd = './sync_to_client.sh val01' 26 | local = "yes" 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /sys/drtmh/scripts/sync_to_aws.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | target="$1" 4 | ## this script will sync the project to the remote server 5 | #rsync -i -rtuv $PWD/../ $target:~/nocc --exclude ./pre-data/ 6 | rsync -e "ssh -i ../aws/tp.pem" -rtuv $PWD/../ ubuntu@$target:~/nocc --exclude ./pre-data/ --exclude .git 7 | -------------------------------------------------------------------------------- /sys/drtmh/scripts/sync_to_client.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | target="$1" 4 | #target=wxd@val19 5 | ## this script will sync the project to the remote server 6 | rsync -i -rtuv $PWD/../ wxd@$target:~/projects/rocc_nvm --exclude ./pre-data/ 7 | #rsync -e "ssh -i ../aws/tp.pem" -rtuv $PWD/../ $target:~/nocc --exclude ./pre-data/ 8 | -------------------------------------------------------------------------------- /sys/drtmh/scripts/sync_to_server.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | target=wxd@val01 4 | ## this script will sync the project to the remote server 5 | rsync -i -rtuv $PWD/../ $target:~/projects/rocc_nvm --exclude ./pre-data/ 6 | #rsync -e "ssh -i ../aws/tp.pem" -rtuv $PWD/../ $target:~/nocc --exclude ./pre-data/ 7 | -------------------------------------------------------------------------------- /sys/drtmh/src/all.h: -------------------------------------------------------------------------------- 1 | /* This file contains constants used in the framework. ************************/ 2 | 3 | #ifndef _ALL 4 | #define _ALL 5 | 6 | /* Coroutine related staff */ 7 | /* Using boost coroutine */ 8 | #include 9 | 10 | typedef boost::coroutines::symmetric_coroutine::call_type coroutine_func_t; 11 | typedef boost::coroutines::symmetric_coroutine::yield_type yield_func_t; 12 | 13 | namespace nocc { 14 | 15 | /***** hardware parameters ********/ 16 | #define CACHE_LINE_SZ 64 // cacheline size of x86 platform 17 | //#define MAX_MSG_SIZE 25600 // max msg size used 18 | #define MAX_MSG_SIZE 4096 19 | //#define MAX_MSG_SIZE 512 20 | 21 | #define HUGE_PAGE_SZ (2 * 1024 * 1024) // huge page size supported 22 | 23 | #define MAX_SERVERS 32 // maxium number of machines in the cluster 24 | #define MAX_SERVER_TO_SENT MAX_SERVERS // maxium broadcast number of one msg 25 | 26 | #define NOCC_BENCH_MAX_TX 16 27 | 28 | /**********************************/ 29 | 30 | 31 | /* some usefull macros ******************************************************/ 32 | #define unlikely(x) __builtin_expect(!!(x), 0) 33 | #define likely(x) __builtin_expect(!!(x), 1) 34 | 35 | #define NOCC_NOT_IMPLEMENT(fnc) { fprintf(stderr,"[NOCC] %s function not implemented.\n",fnc);assert(false); } 36 | } 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /sys/drtmh/src/app/README: -------------------------------------------------------------------------------- 1 | This file mainly contains our benchmark code. 2 | TPCC's main TX's implementations are in tpcc/tpcc_worker_new.cc, while Smallbank's implementations are in smallbank/bank_worker_new.cc . -------------------------------------------------------------------------------- /sys/drtmh/src/app/config.h: -------------------------------------------------------------------------------- 1 | #ifndef APP_CONFIG_H_ 2 | #define APP_CONFIG_H_ 3 | 4 | // 1: naive RPC 5 | // 2: naive + RPC batching 6 | // 3: naive + RPC batching + speculative execuation 7 | #define NAIVE 4 // does not batch RPC, send it one-by-one 8 | 9 | #define READ_RANDOM 1 // 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /sys/drtmh/src/app/graph/graph.h: -------------------------------------------------------------------------------- 1 | #ifndef NOCC_APP_GRAPH_ 2 | #define NOCC_APP_GRAPH_ 3 | 4 | #include "all.h" 5 | #include "tx_config.h" 6 | #include "app/config.h" 7 | 8 | namespace nocc { 9 | namespace oltp { 10 | namespace link { 11 | 12 | void GraphTest(int argc,char **argv); // main hook function 13 | 14 | }; // end namespace link 15 | }; // end namespace oltp 16 | }; 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /sys/drtmh/src/app/graph/graph_constants.h: -------------------------------------------------------------------------------- 1 | namespace nocc { 2 | 3 | namespace oltp { 4 | namespace link { 5 | int DEFAULT_LINK_TYPE = 123456789; 6 | int DEFAULT_NODE_TYPE = 2048; 7 | bool VISIBILITY_HIDDEN = 0; 8 | bool VISIBILITY_DEFAULT = 1; 9 | int DEFAULT_LIMIT = 10000; 10 | int MAX_LINK_DATA = 255; 11 | int DEFAULT_LIMI = 10000; 12 | 13 | double LINK_DATASIZE_SIGMA = 1.0; 14 | double NODE_DATASIZE_SIGMA = 1.0; 15 | }; 16 | }; 17 | }; 18 | -------------------------------------------------------------------------------- /sys/drtmh/src/app/graph/graph_scheme.h: -------------------------------------------------------------------------------- 1 | #ifndef NOCC_APP_GRAPH_SCHEME_ 2 | #define NOCC_APP_GRAPH_SCHEME_ 3 | 4 | #include "all.h" 5 | 6 | namespace nocc { 7 | namespace oltp { 8 | namespace link { 9 | 10 | struct Node { 11 | uint64_t id; 12 | int type; 13 | uint64_t version; 14 | uint64_t time; 15 | char data[CACHE_LINE_SZ]; 16 | }; 17 | 18 | class Edge { 19 | int type; 20 | bool visiblilty; 21 | uint64_t version; 22 | char data[CACHE_LINE_SZ]; 23 | }; 24 | 25 | inline ALWAYS_INLINE 26 | uint64_t makeEdgeKey(uint64_t id0,uint64_t id1,uint64_t time) { 27 | uint64_t *sec = new uint64_t[3]; 28 | sec[0] = id0; sec[1] = id1;sec[2] = time; 29 | return (uint64_t )sec; 30 | } 31 | 32 | } // end namespace link 33 | } 34 | } 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /sys/drtmh/src/app/graph/graph_util.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // for std random generators 4 | #include 5 | #include 6 | #include // for logs 7 | 8 | namespace nocc { 9 | 10 | namespace oltp { 11 | 12 | namespace link { 13 | 14 | class LogNormalDistWrapper { 15 | 16 | std::mt19937 gen_; 17 | std::lognormal_distribution<> rng_; 18 | int min_; 19 | int max_; 20 | double mu_; 21 | double sigma_; 22 | 23 | public: 24 | LogNormalDistWrapper(int min,int max,int medium, double sigma,uint64_t seed) 25 | :gen_(seed), 26 | rng_(), 27 | min_(min), 28 | max_(max), 29 | sigma_(sigma), 30 | mu_(std::log(medium)) 31 | { 32 | } 33 | 34 | int choose() { 35 | double next_guassian = rng_(gen_); 36 | assert(0 <= next_guassian && next_guassian <= 1); 37 | double content = next_guassian * sigma_ + mu_; 38 | int choice = (int)(std::round(std::exp(content))); 39 | if(choice < min_) return min_; 40 | if(choice > max_) return max_ - 1; 41 | return choice; 42 | } 43 | }; // end class log normal wrapper 44 | }; 45 | }; 46 | 47 | }; 48 | -------------------------------------------------------------------------------- /sys/drtmh/src/app/micro_benches/micro_logger.cc: -------------------------------------------------------------------------------- 1 | #include "bench_micro.h" 2 | 3 | namespace nocc { 4 | 5 | namespace oltp { 6 | 7 | namespace micro { 8 | 9 | txn_result_t MicroWorker::micro_logger_write(yield_func_t &yield) { 10 | return txn_result_t(true,0); 11 | } 12 | 13 | txn_result_t MicroWorker::micro_logger_func(yield_func_t &yield) { 14 | 15 | char* ptr; 16 | db_logger_->log_begin(cor_id_); 17 | 18 | db_logger_->get_log_entry(cor_id_,7,0x00001010,8); 19 | db_logger_->close_entry(cor_id_,4); 20 | 21 | ptr = db_logger_->get_log_entry(cor_id_,4,0x03201010,8,1); 22 | *((uint64_t*)ptr) = current_partition; 23 | db_logger_->close_entry(cor_id_,8); 24 | 25 | db_logger_->get_log_entry(cor_id_,34,0x03203410,8,0); 26 | db_logger_->close_entry(cor_id_,16); 27 | 28 | db_logger_->log_backups(cor_id_); 29 | indirect_must_yield(yield); 30 | db_logger_->log_end(cor_id_); 31 | 32 | return txn_result_t(true,0); 33 | } 34 | 35 | } // end namespace micro 36 | 37 | } // end namespace nocc 38 | 39 | } // end namespace oltp 40 | -------------------------------------------------------------------------------- /sys/drtmh/src/app/micro_benches/micro_rdma_sched.cc: -------------------------------------------------------------------------------- 1 | #include "bench_micro.h" 2 | #include "tx_config.h" 3 | 4 | namespace nocc { 5 | 6 | namespace oltp { 7 | 8 | namespace micro { 9 | 10 | txn_result_t MicroWorker::micro_rdma_sched(yield_func_t &yield) { 11 | int target_id = current_partition; 12 | int num_nodes = cm_->get_num_nodes(); 13 | int target_nums = num_nodes - 1; 14 | for (int i = 0; i < target_nums; i++) { 15 | target_id = (target_id + 1) % num_nodes; 16 | Qp* qp = qps_[target_id]; 17 | qp->rc_post_send(IBV_WR_RDMA_READ,rdma_buf_,512,(uint64_t)1024*1024*1024*12,IBV_SEND_SIGNALED); 18 | // rdma_sched_->add_pending(cor_id_, qp); 19 | } 20 | indirect_must_yield(yield); 21 | 22 | 23 | return txn_result_t(true,0); 24 | } 25 | 26 | } // end namespace micro 27 | 28 | } // end namespace nocc 29 | 30 | } // end namespace oltp 31 | -------------------------------------------------------------------------------- /sys/drtmh/src/app/smallbank/bank_log_cleaner.h: -------------------------------------------------------------------------------- 1 | #ifndef NOCC_OLTP_BANK_LOG_CLEANER_H 2 | #define NOCC_OLTP_BANK_LOG_CLEANER_H 3 | 4 | #include "bank_worker.h" 5 | #include "framework/log_cleaner.h" 6 | 7 | extern size_t nthreads; 8 | extern size_t current_partition; 9 | 10 | 11 | namespace nocc { 12 | namespace oltp { 13 | namespace bank { 14 | 15 | class BankLogCleaner : public LogCleaner { 16 | public: 17 | BankLogCleaner():LogCleaner() {} 18 | 19 | virtual int clean_log(int table_id, uint64_t key, uint64_t seq, char *val,int length){ 20 | 21 | int p_id = AcctToPid(key); 22 | assert(p_id >= 0 && p_id < 16); 23 | if(backup_stores_.find(p_id) == backup_stores_.end()){ 24 | // printf("log_cleaner: %d\n", p_id); 25 | return -1; 26 | } 27 | MemDB* db = backup_stores_[p_id]; 28 | 29 | int vlen = db->_schemas[table_id].vlen; 30 | assert(vlen == length); 31 | // printf("table:%d, key: %lu, partition:%d \n",table_id, key, p_id ); 32 | MemNode *node = db->stores_[table_id]->GetWithInsert(key); 33 | 34 | volatile uint64_t *lockptr = &(node->lock); 35 | while(unlikely((*lockptr != 0) || 36 | !__sync_bool_compare_and_swap(lockptr,0,1))){ } 37 | if(node->seq >= seq){ 38 | *lockptr = 0; 39 | return -2; 40 | } 41 | uint64_t *&val_ptr = node->value; 42 | if(val_ptr == NULL){ 43 | val_ptr = (uint64_t*)malloc(vlen); 44 | } 45 | memcpy((char*)val_ptr, val, vlen); 46 | 47 | node->seq = seq; 48 | 49 | *lockptr = 0; 50 | return 0; 51 | } 52 | 53 | }; 54 | 55 | } 56 | } 57 | } 58 | 59 | 60 | 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /sys/drtmh/src/app/tpce/egen/flat/egen_flat_in/Charge.txt: -------------------------------------------------------------------------------- 1 | TMB 1 5 2 | TMB 2 4.5 3 | TMB 3 2.5 4 | TMS 1 5 5 | TMS 2 4.5 6 | TMS 3 2.5 7 | TSL 1 6.5 8 | TSL 2 5.5 9 | TSL 3 3.5 10 | TLS 1 6 11 | TLS 2 5 12 | TLS 3 3 13 | TLB 1 6 14 | TLB 2 5 15 | TLB 3 3 16 | -------------------------------------------------------------------------------- /sys/drtmh/src/app/tpce/egen/flat/egen_flat_in/CompanySPRate.txt: -------------------------------------------------------------------------------- 1 | 1 A 2 | 1 B 3 | 1 C 4 | 1 AA 5 | 1 AB 6 | 1 AC 7 | 1 BA 8 | 1 BB 9 | 1 BC 10 | 1 CA 11 | 1 CB 12 | 1 CC 13 | 1 AAA 14 | 1 AAB 15 | 1 AAC 16 | 1 ABA 17 | 1 ABB 18 | 1 ABC 19 | 1 ACA 20 | 1 ACB 21 | 1 ACC 22 | 1 BAA 23 | 1 BAB 24 | 1 BAC 25 | 1 BBA 26 | 1 BBB 27 | 1 BBC 28 | 1 BCA 29 | 1 BCB 30 | 1 BCC 31 | 1 CAA 32 | 1 CAB 33 | 1 CAC 34 | 1 CBA 35 | 1 CBB 36 | 1 CBC 37 | 1 CCA 38 | 1 CCB 39 | 1 CCC 40 | -------------------------------------------------------------------------------- /sys/drtmh/src/app/tpce/egen/flat/egen_flat_in/Exchange.txt: -------------------------------------------------------------------------------- 1 | NYSE New York Stock Exchange 0930 1600 Simulates the New York Stock Exchange 1 2 | NASDAQ NASDAQ (National Association of Security Dealers and Quotations) 0930 1600 Simulates the NASDAQ 2 3 | AMEX American Stock Exchange 0930 1600 Simulates the American Stock Exchange 3 4 | PCX Pacific Exchange 0930 1600 Simulates the Pacific Exchange 4 5 | -------------------------------------------------------------------------------- /sys/drtmh/src/app/tpce/egen/flat/egen_flat_in/NonTaxableAccountName.txt: -------------------------------------------------------------------------------- 1 | Traditional IRA 2 | Roth IRA 3 | IRA-SEP 4 | 401(k) 5 | Pension Account 6 | Rollover IRA 7 | Retirement Fund 8 | Roth 401(K) 9 | Flexible Spending 10 | Health Savings 11 | Non-Taxable Trust 12 | -------------------------------------------------------------------------------- /sys/drtmh/src/app/tpce/egen/flat/egen_flat_in/Sector.txt: -------------------------------------------------------------------------------- 1 | BM Basic Materials 2 | CG Capital Goods 3 | CO Conglomerates 4 | CC Consumer Cyclical 5 | CN Consumer Non-Cyclical 6 | EN Energy 7 | FN Financial 8 | HC Healthcare 9 | SV Services 10 | TC Technology 11 | TR Transportation 12 | UT Utilities 13 | -------------------------------------------------------------------------------- /sys/drtmh/src/app/tpce/egen/flat/egen_flat_in/StatusType.txt: -------------------------------------------------------------------------------- 1 | CMPT Completed 2 | ACTV Active 3 | SBMT Submitted 4 | PNDG Pending 5 | CNCL Canceled 6 | -------------------------------------------------------------------------------- /sys/drtmh/src/app/tpce/egen/flat/egen_flat_in/StreetSuffix.txt: -------------------------------------------------------------------------------- 1 | 1 Street 2 | 1 Road 3 | 1 Court 4 | 1 Boulevard 5 | 1 Way 6 | 1 Lane 7 | 1 Crescent 8 | 1 Park 9 | 1 Avenue 10 | 1 Rue 11 | 1 Drive 12 | 1 South 13 | 1 North 14 | 1 West 15 | 1 East 16 | 1 Upper 17 | 1 Lower 18 | -------------------------------------------------------------------------------- /sys/drtmh/src/app/tpce/egen/flat/egen_flat_in/TaxRatesCountry.txt: -------------------------------------------------------------------------------- 1 | 1 US1 U.S. Income Tax Bracket for the poor 0.15 2 | 1 US2 U.S. Income Tax Bracket for the huddled masses 0.275 3 | 1 US3 U.S. Income Tax Bracket for the masses 0.305 4 | 1 US4 U.S. Income Tax Bracket for the well to do 0.355 5 | 1 US5 U.S. Income Tax Bracket for the filthy rich 0.391 6 | 2 CN1 Canadian Income Tax for the poor 0.16 7 | 2 CN2 Canadian Income Tax for the huddled masses 0.22 8 | 2 CN3 Canadian Income Tax for the well to do 0.26 9 | 2 CN4 Canadian Income Tax for the filthy rich 0.29 10 | -------------------------------------------------------------------------------- /sys/drtmh/src/app/tpce/egen/flat/egen_flat_in/TaxableAccountName.txt: -------------------------------------------------------------------------------- 1 | Emergency Expenses 2 | Vacation Account 3 | Healthcare Fund 4 | New Car Account 5 | House Money 6 | Individual Account 7 | Family Trust 8 | Custodial Account 9 | Joint Account 10 | Business Account 11 | College Fund 12 | Savings Account 13 | Play Money 14 | -------------------------------------------------------------------------------- /sys/drtmh/src/app/tpce/egen/flat/egen_flat_in/TradeType.txt: -------------------------------------------------------------------------------- 1 | TMB Market-Buy 0 1 2 | TMS Market-Sell 1 1 3 | TSL Stop-Loss 1 0 4 | TLS Limit-Sell 1 0 5 | TLB Limit-Buy 0 0 6 | -------------------------------------------------------------------------------- /sys/drtmh/src/app/tpce/tpce_constants.h: -------------------------------------------------------------------------------- 1 | #ifndef NOCC_OLTP_TPCE_CON_H 2 | #define NOCC_OLTP_TPCE_CON_H 3 | 4 | // This file defines the constants used by tpce benchmark 5 | namespace nocc { 6 | namespace oltp { 7 | namespace tpce { 8 | 9 | const int accountPerPartition = 5000; 10 | const int caPerPartition = accountPerPartition * 10; 11 | const int companyPerPartition = 500 * (accountPerPartition / 1000); 12 | const int brokerPerPartition = accountPerPartition / 100; 13 | }; 14 | }; 15 | }; 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /sys/drtmh/src/core/common.h: -------------------------------------------------------------------------------- 1 | #ifndef NOCC_COMMON_H 2 | #define NOCC_COMMON_H 3 | 4 | #define NOCC_DECLARE_typed_var(type, name) \ 5 | namespace nocc { \ 6 | extern type FLAGS_##name; \ 7 | } // namespace nocc 8 | 9 | 10 | namespace nocc { 11 | 12 | #define DISABLE_COPY_AND_ASSIGN(classname) \ 13 | private: \ 14 | classname(const classname&) = delete; \ 15 | classname& operator=(const classname&) = delete 16 | 17 | 18 | #define unlikely(x) __builtin_expect(!!(x), 0) 19 | #define likely(x) __builtin_expect(!!(x), 1) 20 | 21 | #define ALWAYS_INLINE __attribute__((always_inline)) 22 | 23 | }; 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /sys/drtmh/src/core/logging.cc: -------------------------------------------------------------------------------- 1 | #include "logging.h" 2 | 3 | #include 4 | 5 | using namespace std; 6 | 7 | namespace nocc { 8 | 9 | // control flags for color 10 | #define R_BLACK 39 11 | #define R_RED 31 12 | #define R_GREEN 32 13 | #define R_YELLOW 33 14 | #define R_BLUE 34 15 | #define R_MAGENTA 35 16 | #define R_CYAN 36 17 | #define R_WHITE 37 18 | 19 | std::string StripBasename(const std::string &full_path) { 20 | const char kSeparator = '/'; 21 | size_t pos = full_path.rfind(kSeparator); 22 | if (pos != std::string::npos) { 23 | return full_path.substr(pos + 1, std::string::npos); 24 | } else { 25 | return full_path; 26 | } 27 | } 28 | 29 | inline string EndcolorFlag() { 30 | char flag[7]; 31 | snprintf(flag,7, "%c[0m", 0x1B); 32 | return string(flag); 33 | } 34 | 35 | const int RTX_DEBUG_LEVEL_COLOR[] = {R_BLACK,R_YELLOW,R_BLACK,R_GREEN,R_MAGENTA,R_RED,R_RED}; 36 | 37 | MessageLogger::MessageLogger(const char *file, int line, int level) 38 | :level_(level) { 39 | if(level_ < ROCC_LOG_LEVEL) 40 | return; 41 | stream_ << "[" << StripBasename(std::string(file)) << ":" << line << "] "; 42 | } 43 | 44 | 45 | MessageLogger::~MessageLogger() { 46 | if(level_ >= ROCC_LOG_LEVEL) { 47 | stream_ << "\n"; 48 | std::cout << "\033[" << RTX_DEBUG_LEVEL_COLOR[std::min(level_,6)] << "m" 49 | << stream_.str() << EndcolorFlag(); 50 | if(level_ >= LOG_FATAL) 51 | abort(); 52 | } 53 | } 54 | 55 | } // namespace nocc 56 | -------------------------------------------------------------------------------- /sys/drtmh/src/core/rworker_yield_impl.hpp: -------------------------------------------------------------------------------- 1 | namespace nocc { 2 | namespace oltp { 3 | 4 | // class nocc_worker 5 | inline ALWAYS_INLINE 6 | void RWorker::indirect_yield(yield_func_t &yield) { 7 | // make a simple check to avoid yield, if possible 8 | if(unlikely(rdma_sched_->pending_counts_[cor_id_] == 0 9 | && !rpc_->has_pending_reqs(cor_id_))) { 10 | return; 11 | } 12 | indirect_must_yield(yield); 13 | } 14 | 15 | inline ALWAYS_INLINE 16 | void RWorker::indirect_must_yield(yield_func_t &yield) { 17 | 18 | int next = routine_meta_->next_->id_; 19 | cor_id_ = next; 20 | auto cur = routine_meta_; 21 | routine_meta_ = cur->next_; 22 | change_ctx(cor_id_); 23 | cur->yield_from_routine_list(yield); 24 | 25 | change_ctx(cor_id_); 26 | } 27 | 28 | 29 | inline ALWAYS_INLINE 30 | void RWorker::yield_next(yield_func_t &yield) { 31 | // yield to the next routine 32 | int next = routine_meta_->next_->id_; 33 | routine_meta_ = routine_meta_->next_; 34 | cor_id_ = next; 35 | change_ctx(cor_id_); 36 | 37 | routine_meta_->yield_to(yield); 38 | 39 | change_ctx(cor_id_); 40 | assert(cor_id_ == routine_meta_->id_); 41 | } 42 | 43 | // end class nocc_worker 44 | 45 | } // 46 | } // namespace nocc 47 | -------------------------------------------------------------------------------- /sys/drtmh/src/core/tcp_adapter.cc: -------------------------------------------------------------------------------- 1 | #include "tcp_adapter.hpp" 2 | 3 | // a dummy cc file for static member's allocations 4 | namespace nocc { 5 | 6 | /** 7 | * Global poller for TCP based communication 8 | */ 9 | zmq::context_t recv_context(1); 10 | zmq::context_t send_context(1); 11 | AdapterPoller *poller = NULL; 12 | std::vector local_comm_queues; 13 | 14 | std::vector Adapter::sockets; 15 | std::vector Adapter::locks; 16 | 17 | 18 | }; // namespace nocc 19 | -------------------------------------------------------------------------------- /sys/drtmh/src/core/utils/amd64.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The code is part of our project called DrTM, which leverages HTM and RDMA for speedy distributed 3 | * in-memory transactions. 4 | * 5 | * 6 | * Copyright (C) 2015 Institute of Parallel and Distributed Systems (IPADS), Shanghai Jiao Tong University 7 | * All rights reserved. 8 | * 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * 21 | * For more about this software, visit: http://ipads.se.sjtu.edu.cn/drtm.html 22 | * 23 | */ 24 | 25 | #ifndef _AMD64_H_ 26 | #define _AMD64_H_ 27 | 28 | #include "macros.h" 29 | #include 30 | 31 | inline ALWAYS_INLINE void 32 | nop_pause() 33 | { 34 | __asm volatile("pause" : :); 35 | } 36 | 37 | #endif /* _AMD64_H_ */ 38 | -------------------------------------------------------------------------------- /sys/drtmh/src/core/utils/count_vector.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace nocc { 6 | 7 | // a vector class to store count data 8 | template 9 | class CountVector : public std::vector { 10 | public: 11 | CountVector() : 12 | std::vector() 13 | { 14 | } 15 | 16 | double average() { 17 | 18 | if(std::vector::size() == 0) 19 | return 0.0; 20 | 21 | T sum = 0; 22 | for(auto it = std::vector::begin();it != std::vector::end();++it) { 23 | sum += *it; 24 | } 25 | double res = static_cast(sum) / std::vector::size(); 26 | return res; 27 | } 28 | 29 | // erase the first ratio% and last ratio% items 30 | void erase(double ratio) { 31 | 32 | // If there are too less elements in the vector, not erase items 33 | if(std::vector::size() < 5) 34 | return; 35 | 36 | int temp_size = std::vector::size(); 37 | int idx = std::floor(std::vector::size() * ratio); 38 | std::vector::erase(std::vector::begin() + temp_size - idx,std::vector::end()); 39 | std::vector::erase(std::vector::begin(),std::vector::begin() + idx); 40 | } 41 | 42 | void sort() { 43 | std::sort(std::vector::begin(),std::vector::end()); 44 | } 45 | }; 46 | 47 | } // namespace nocc 48 | -------------------------------------------------------------------------------- /sys/drtmh/src/core/utils/varint.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * The code is part of our project called DrTM, which leverages HTM and RDMA for speedy distributed 3 | * in-memory transactions. 4 | * 5 | * 6 | * Copyright (C) 2015 Institute of Parallel and Distributed Systems (IPADS), Shanghai Jiao Tong University 7 | * All rights reserved. 8 | * 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * 21 | * For more about this software, visit: http://ipads.se.sjtu.edu.cn/drtm.html 22 | * 23 | */ 24 | 25 | #include 26 | 27 | #include "varint.h" 28 | #include "macros.h" 29 | #include "util.h" 30 | 31 | using namespace std; 32 | using namespace nocc::util; 33 | 34 | static void 35 | do_test(uint32_t v) 36 | { 37 | uint8_t buf[5]; 38 | uint8_t *p = &buf[0]; 39 | p = write_uvint32(p, v); 40 | ALWAYS_ASSERT(size_t(p - &buf[0]) == size_uvint32(v)); 41 | 42 | const uint8_t *p0 = &buf[0]; 43 | uint32_t v0 = 0; 44 | p0 = read_uvint32(p0, &v0); 45 | ALWAYS_ASSERT(v == v0); 46 | ALWAYS_ASSERT(p == p0); 47 | } 48 | 49 | void 50 | varint::Test() 51 | { 52 | fast_random r(2043859); 53 | for (int i = 0; i < 1000; i++) 54 | do_test(r.next_u32()); 55 | cerr << "varint tests passed" << endl; 56 | } 57 | -------------------------------------------------------------------------------- /sys/drtmh/src/db/config.h: -------------------------------------------------------------------------------- 1 | #ifndef NOCC_DB_CONFIG_H 2 | #define NOCC_DB_CONFIG_H 3 | 4 | #define COMMIT_NAIVE 0 5 | #define ATOMIC_LOCK 0 6 | #define ONE_WRITE 0 7 | #define LONG_KEY 1 8 | #define NO_EXE_ABORT 0 9 | #define LOCAL_LOCK_USE_RDMA 0 10 | 11 | #define TX_NAIVE 0 12 | 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /sys/drtmh/src/db/db_logger_wrapper.h: -------------------------------------------------------------------------------- 1 | #include "all.h" 2 | #include "db_logger.hpp" 3 | 4 | namespace nocc { 5 | namespace db { 6 | 7 | typedef LogHelper LogHelperSpecific; 8 | }; 9 | }; 10 | -------------------------------------------------------------------------------- /sys/drtmh/src/db/forkset.h: -------------------------------------------------------------------------------- 1 | #ifndef NOCC_TX_FORK_SET 2 | #define NOCC_TX_FORK_SET 3 | 4 | /* This file is used to helpe transactions fork many requests to many servers */ 5 | #include "all.h" 6 | #include "memstore/memstore.h" 7 | 8 | #include "core/rrpc.h" 9 | 10 | namespace nocc { 11 | 12 | using namespace oltp; // framework 13 | 14 | namespace db { 15 | 16 | class ForkSet { 17 | public: 18 | ForkSet(RRpc *rpc,int cid = 0) ; 19 | ~ForkSet(); 20 | /* start some initlization work*/ 21 | void reset(); 22 | void clear(); 23 | char* do_fork(int sizeof_header ); 24 | void do_fork(); 25 | 26 | char* add(int pid,int sizeof_payload); 27 | void add(int pid); 28 | int fork(int id,int type = RRpc::Y_REQ); 29 | int fork(int id,char *val,int size,int type = RRpc::Y_REQ); 30 | char *get_reply() { return reply_buf_;} 31 | int get_server_num() { return server_num_;} 32 | 33 | char *reply_buf_; 34 | private: 35 | RRpc *rpc_; 36 | 37 | char *msg_buf_start_; 38 | char *msg_buf_end_; 39 | 40 | std::set server_set_; 41 | int server_lists_[MAX_SERVER_TO_SENT]; 42 | int server_num_; 43 | int cor_id_; 44 | }; 45 | }; 46 | }; 47 | #endif 48 | -------------------------------------------------------------------------------- /sys/drtmh/src/db/forkset.h : -------------------------------------------------------------------------------- 1 | #ifndef NOCC_TX_FORK_SET 2 | #define NOCC 3 | 4 | -------------------------------------------------------------------------------- /sys/drtmh/src/db/txs/db_2pl.h: -------------------------------------------------------------------------------- 1 | #ifndef NOCC_TX_2PL 2 | #define NOCC_TX_2PL 3 | 4 | #include "tx_handler.h" 5 | #include "db/remote_set.h" 6 | #include "memstore/memdb.h" 7 | 8 | #include 9 | 10 | #define META_LENGTH 16 11 | 12 | 13 | using namespace nocc::db; 14 | 15 | namespace nocc { 16 | namespace db { 17 | 18 | class DBLock : public TXHandler { 19 | 20 | public: 21 | 22 | 23 | }; // end class 2pl 24 | 25 | }; 26 | }; 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /sys/drtmh/src/framework/backup_worker.h: -------------------------------------------------------------------------------- 1 | #ifndef NOCC_OLTP_BENCH_BACKUP_H 2 | #define NOCC_OLTP_BENCH_BACKUP_H 3 | 4 | //#include "framework.h" 5 | 6 | #include "all.h" 7 | #include "db/db_logger.h" 8 | #include "core/utils/thread.h" 9 | #include "util/util.h" 10 | 11 | #include "view_manager.h" 12 | #include "log_cleaner.h" 13 | 14 | #include 15 | 16 | using namespace std; 17 | using namespace rdmaio; 18 | 19 | extern size_t backup_nthreads; 20 | 21 | namespace nocc { 22 | 23 | using namespace db; 24 | using namespace util; 25 | 26 | namespace oltp { 27 | 28 | const uint32_t LOG_THRSHOLD = THREAD_BUF_SIZE / 8; 29 | 30 | class BackupBenchWorker : public ndb_thread { 31 | public: 32 | BackupBenchWorker(unsigned worker_id); 33 | ~BackupBenchWorker(); 34 | void run(); 35 | 36 | char* check_log_completion(volatile char* ptr, uint64_t &msg_size); 37 | 38 | void clean_log(char* log_ptr, char* tailer_ptr); 39 | 40 | char *base_ptr_; // ptr to start of logger memory 41 | uint64_t node_area_size_; 42 | 43 | uint64_t **feedback_offsets_; 44 | uint64_t **head_offsets_; 45 | uint64_t **tail_offsets_; 46 | 47 | 48 | unsigned int start_tid_; 49 | unsigned int final_tid_; 50 | unsigned int thread_gap_; 51 | 52 | RdmaCtrl *cm_; 53 | unsigned int worker_id_; 54 | unsigned int thread_id_; 55 | 56 | 57 | private: 58 | bool initilized_; 59 | int num_nodes_; 60 | 61 | std::vector qp_vec_; 62 | 63 | void thread_local_init(); 64 | void create_qps(); 65 | }; 66 | 67 | } 68 | 69 | } 70 | 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /sys/drtmh/src/framework/bench_reporter.h: -------------------------------------------------------------------------------- 1 | #ifndef RTX_BENCH_REPORTER 2 | #define RTX_BENCH_REPORTER 3 | 4 | #include "bench_worker.h" 5 | 6 | namespace nocc { 7 | 8 | namespace oltp { 9 | 10 | class BenchReporter { // not thread safe 11 | public: 12 | virtual void init(const std::vector *workers); 13 | virtual void merge_data(char *,int id); 14 | virtual void report_data(uint64_t epoch,std::ofstream &log_file); 15 | virtual void collect_data(char *data,struct timespec &start_t); // the data is stored in *data 16 | virtual size_t data_len(); 17 | virtual void end(); 18 | 19 | private: 20 | double throughput; 21 | double aborts; 22 | double abort_ratio; 23 | 24 | std::vector prev_commits_; 25 | std::vector prev_aborts_; 26 | std::vector prev_abort_ratio_; 27 | public: 28 | const std::vector *workers_; 29 | 30 | // helper functions 31 | uint64_t calculate_commits(std::vector &prevs); 32 | uint64_t calculate_aborts(std::vector &prevs); 33 | double calculate_abort_ratio(std::vector &prevs); 34 | double calculate_execute_ratio(); 35 | 36 | std::vector throughputs; 37 | }; 38 | 39 | } // end namespace oltp 40 | 41 | } // end namespace nocc 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /sys/drtmh/src/framework/config.h: -------------------------------------------------------------------------------- 1 | #ifndef NOCC_FRAMEWORK_CONFIG_H_ 2 | #define NOCC_FRAMEWORK_CONFIG_H_ 3 | 4 | #define MASTER_EPOCH 25// runtime of test 5 | 6 | // rdma related stuffs 7 | #define HUGE_PAGE 1 8 | #define USE_UD_MSG 1 9 | #define USE_TCP_MSG 0 10 | #define SINGLE_MR 0 11 | #define BUF_SIZE 10480 // RDMA buffer size registered, in a small setting 12 | //#define BUF_SIZE 512 13 | 14 | // rpc related stuffs 15 | //#define RPC_TIMEOUT_FLAG 16 | #define RPC_TIMEOUT_TIME 10000000 17 | //#define RPC_CHECKSUM 18 | #define MAX_INFLIGHT_REPLY 256 19 | //#define MAX_INFLIGHT_REQS 768 // for TPC-C, smallbank usage 20 | #define MAX_INFLIGHT_REQS 128 21 | //#define MAX_INFLIGHT_REQS 16 22 | 23 | 24 | // print statements 25 | #define LOG_RESULTS // log results to a file 26 | #define LISTENER_PRINT_PERF 1 // print the results to the screen 27 | #define PER_THREAD_LOG 0 // per thread detailed log 28 | #define POLL_CYCLES 0 // print the polling cycle 29 | #define CALCULATE_LAT 1 30 | #define LATENCY 0 // 1: global latency report; 0: workload specific report 31 | 32 | #if USE_TCP_MSG == 1 33 | #undef USE_UD_MSG 34 | #define USE_UD_MSG 0 35 | #endif 36 | 37 | 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /sys/drtmh/src/framework/log_cleaner.cc: -------------------------------------------------------------------------------- 1 | #include "log_cleaner.h" 2 | #include "core/rworker.h" 3 | 4 | 5 | /* global config constants */ 6 | extern size_t nthreads; 7 | extern size_t scale_factor; 8 | extern size_t current_partition; 9 | extern size_t total_partition; 10 | 11 | namespace nocc{ 12 | 13 | namespace oltp{ 14 | 15 | extern View* my_view; // replication setting of the data 16 | 17 | LogCleaner::LogCleaner() {} 18 | 19 | void LogCleaner::add_backup_store(MemDB *backup_store){ 20 | int num_backups, backups[MAX_BACKUP_NUM]; 21 | num_backups = my_view->is_backup(current_partition, backups); 22 | assert(num_backups <= MAX_BACKUP_NUM); 23 | for(int i = 0; i < num_backups; i++){ 24 | auto iter = backup_stores_.find(backups[i]); 25 | if(iter == backup_stores_.end()){ 26 | printf("LogCleaner: %d backup_store[%d] added\n", i,backups[i]); 27 | backup_stores_.insert(std::pair(backups[i], backup_store)); 28 | break; 29 | } 30 | } 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /sys/drtmh/src/framework/log_cleaner.h: -------------------------------------------------------------------------------- 1 | #ifndef NOCC_OLTP_LOG_CLEANER_H 2 | #define NOCC_OLTP_LOG_CLEANER_H 3 | 4 | #include "memstore/memdb.h" 5 | 6 | #include "view_manager.h" 7 | #include 8 | 9 | namespace nocc{ 10 | 11 | namespace oltp { 12 | 13 | // the abstract class for cleaning the log entry 14 | // be called after the receive each log entries 15 | class LogCleaner { 16 | public: 17 | 18 | LogCleaner(); 19 | // should be 0 on success,-1 on error 20 | virtual int clean_log(int table_id, uint64_t key, uint64_t seq, char *val,int length) = 0; 21 | 22 | void add_backup_store(MemDB *backup_store); 23 | 24 | std::map backup_stores_; 25 | 26 | }; 27 | 28 | 29 | } 30 | } 31 | 32 | 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /sys/drtmh/src/framework/req_buf_allocator.h: -------------------------------------------------------------------------------- 1 | #ifndef NOCC_DB_MEM_ALLOCATOR 2 | #define NOCC_DB_MEM_ALLOCATOR 3 | 4 | #include "all.h" 5 | #include "ralloc.h" 6 | #include "config.h" 7 | #include "./config.h" 8 | #include "rpc.h" 9 | 10 | #include 11 | #include 12 | 13 | namespace nocc { 14 | 15 | namespace oltp { 16 | 17 | // RPC memory allocator 18 | class RPCMemAllocator { 19 | public: 20 | 21 | RPCMemAllocator() { 22 | RThreadLocalInit(); 23 | for(int i = 0;i < MAX_INFLIGHT_REQS;++i) { 24 | #if 1 25 | buf_pools_[i] = (char *)Rmalloc(MAX_MSG_SIZE + Rpc::reserved_payload()) + Rpc::reserved_payload(); 26 | // check for alignment 27 | assert( ((uint64_t)(buf_pools_[i])) % 8 == 0); 28 | if(buf_pools_[i] != NULL) 29 | memset(buf_pools_[i],0,MAX_MSG_SIZE); 30 | else 31 | assert(false); 32 | #endif 33 | } 34 | current_buf_slot_ = 0; 35 | } 36 | 37 | inline char * operator[] (int id) const{ 38 | return buf_pools_[id]; 39 | } 40 | 41 | inline void rollback_buf() { 42 | current_buf_slot_ = current_buf_slot_ - 1; 43 | } 44 | 45 | inline char * get_req_buf() { 46 | 47 | uint16_t buf_idx = (current_buf_slot_++) % MAX_INFLIGHT_REQS; 48 | assert(buf_idx >= 0 && buf_idx < MAX_INFLIGHT_REQS); 49 | // fetch the buf 50 | char *res = buf_pools_[buf_idx]; 51 | return res; 52 | } 53 | 54 | inline char *post_buf(int num = 1) { 55 | current_freed_slot_ += num; 56 | } 57 | 58 | private: 59 | char *buf_pools_[MAX_INFLIGHT_REQS]; 60 | uint64_t current_buf_slot_; 61 | uint64_t current_freed_slot_; 62 | }; 63 | } // namespace db 64 | }; // namespace nocc 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /sys/drtmh/src/framework/tpc_msg.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SJTU-IPADS/librdpma/5216d108dd5496e8428c473134012c12dae54f5c/sys/drtmh/src/framework/tpc_msg.h -------------------------------------------------------------------------------- /sys/drtmh/src/framework/utils/amd64.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The code is part of our project called DrTM, which leverages HTM and RDMA for speedy distributed 3 | * in-memory transactions. 4 | * 5 | * 6 | * Copyright (C) 2015 Institute of Parallel and Distributed Systems (IPADS), Shanghai Jiao Tong University 7 | * All rights reserved. 8 | * 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * 21 | * For more about this software, visit: http://ipads.se.sjtu.edu.cn/drtm.html 22 | * 23 | */ 24 | 25 | #ifndef _AMD64_H_ 26 | #define _AMD64_H_ 27 | 28 | #include "macros.h" 29 | #include 30 | 31 | inline ALWAYS_INLINE void 32 | nop_pause() 33 | { 34 | __asm volatile("pause" : :); 35 | } 36 | 37 | #endif /* _AMD64_H_ */ 38 | -------------------------------------------------------------------------------- /sys/drtmh/src/framework/utils/varint.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * The code is part of our project called DrTM, which leverages HTM and RDMA for speedy distributed 3 | * in-memory transactions. 4 | * 5 | * 6 | * Copyright (C) 2015 Institute of Parallel and Distributed Systems (IPADS), Shanghai Jiao Tong University 7 | * All rights reserved. 8 | * 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * 21 | * For more about this software, visit: http://ipads.se.sjtu.edu.cn/drtm.html 22 | * 23 | */ 24 | 25 | #include 26 | 27 | #include "varint.h" 28 | #include "macros.h" 29 | #include "util.h" 30 | 31 | using namespace std; 32 | using namespace nocc::util; 33 | 34 | static void 35 | do_test(uint32_t v) 36 | { 37 | uint8_t buf[5]; 38 | uint8_t *p = &buf[0]; 39 | p = write_uvint32(p, v); 40 | ALWAYS_ASSERT(size_t(p - &buf[0]) == size_uvint32(v)); 41 | 42 | const uint8_t *p0 = &buf[0]; 43 | uint32_t v0 = 0; 44 | p0 = read_uvint32(p0, &v0); 45 | ALWAYS_ASSERT(v == v0); 46 | ALWAYS_ASSERT(p == p0); 47 | } 48 | 49 | void 50 | varint::Test() 51 | { 52 | fast_random r(2043859); 53 | for (int i = 0; i < 1000; i++) 54 | do_test(r.next_u32()); 55 | cerr << "varint tests passed" << endl; 56 | } 57 | -------------------------------------------------------------------------------- /sys/drtmh/src/memstore/cluster_chaining_remote_op.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "framework/bench_worker.h" 4 | #include "cluster_chaining.hpp" 5 | 6 | namespace nocc { 7 | 8 | extern __thread oltp::BenchWorker* worker; 9 | 10 | namespace drtm { 11 | 12 | template 13 | void ClusterHash::fetch_node(Qp *qp,uint64_t off,char *buf,int size) { 14 | qp->rc_post_send(IBV_WR_RDMA_READ,buf,size,off,IBV_SEND_SIGNALED); 15 | auto res = qp->poll_completion(); 16 | if(res != Qp::IO_SUCC) { 17 | assert(false); 18 | } 19 | } 20 | 21 | template 22 | void ClusterHash::fetch_node(Qp *qp,uint64_t off,char *buf,int size, 23 | nocc::oltp::RScheduler *sched,yield_func_t &yield) { 24 | int flag = IBV_SEND_SIGNALED; 25 | if(size < 64) flag |= IBV_SEND_INLINE; 26 | 27 | sched->post_send(qp,worker->cor_id(), 28 | IBV_WR_RDMA_READ,buf,size,off,flag); 29 | worker->indirect_yield(yield); 30 | } 31 | 32 | }; // namespace drtm 33 | 34 | }; // namespace nocc 35 | -------------------------------------------------------------------------------- /sys/drtmh/src/memstore/memstore.cc: -------------------------------------------------------------------------------- 1 | #include "memstore.h" 2 | 3 | #if RECORD_STALE 4 | std_time_t_ MemNode::init_time; 5 | #endif 6 | -------------------------------------------------------------------------------- /sys/drtmh/src/memstore/memstore_hash.cc: -------------------------------------------------------------------------------- 1 | #include "memstore/memstore_hash.h" 2 | 3 | namespace leveldb { 4 | __thread MemstoreHashTable::HashNode *MemstoreHashTable::dummynode_ = NULL; 5 | } 6 | -------------------------------------------------------------------------------- /sys/drtmh/src/memstore/simple_cache.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "util/util.h" 4 | 5 | namespace nocc { 6 | 7 | class SimpleCache { 8 | public: 9 | SimpleCache(int size) : size_(size) 10 | { 11 | if(size != 0) { 12 | content_ = (uint64_t *)malloc_huge_pages(size,HUGE_PAGE_SZ,true); 13 | assert(content_ != NULL); 14 | } 15 | } 16 | 17 | void put(uint64_t key,uint64_t off) { 18 | assert(key < size_ / sizeof(uint64_t)); 19 | content_[key] = off; 20 | } 21 | 22 | inline uint64_t get(uint64_t key) { 23 | return content_[key]; 24 | } 25 | private: 26 | uint64_t *content_ = NULL; 27 | int size_; 28 | }; 29 | 30 | }; // namespace nocc 31 | -------------------------------------------------------------------------------- /sys/drtmh/src/port/README: -------------------------------------------------------------------------------- 1 | This directory contains interfaces and implementations that isolate the 2 | rest of the package from platform details. 3 | 4 | Code in the rest of the package includes "port.h" from this directory. 5 | "port.h" in turn includes a platform specific "port_.h" file 6 | that provides the platform specific implementation. 7 | 8 | See port_posix.h for an example of what must be provided in a platform 9 | specific header file. 10 | 11 | -------------------------------------------------------------------------------- /sys/drtmh/src/port/port.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 The LevelDB Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. See the AUTHORS file for names of contributors. 4 | 5 | #ifndef STORAGE_LEVELDB_PORT_PORT_H_ 6 | #define STORAGE_LEVELDB_PORT_PORT_H_ 7 | 8 | #include 9 | 10 | // Include the appropriate platform specific file below. If you are 11 | // porting to a new platform, see "port_example.h" for documentation 12 | // of what the new port_.h file must provide. 13 | #if defined(LEVELDB_PLATFORM_POSIX) 14 | # include "port/port_posix.h" 15 | #elif defined(LEVELDB_PLATFORM_CHROMIUM) 16 | # include "port/port_chromium.h" 17 | #endif 18 | 19 | #endif // STORAGE_LEVELDB_PORT_PORT_H_ 20 | -------------------------------------------------------------------------------- /sys/drtmh/src/port/thread_annotations.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012 The LevelDB Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. See the AUTHORS file for names of contributors. 4 | 5 | #ifndef STORAGE_LEVELDB_PORT_THREAD_ANNOTATIONS_H 6 | 7 | // Some environments provide custom macros to aid in static thread-safety 8 | // analysis. Provide empty definitions of such macros unless they are already 9 | // defined. 10 | 11 | #ifndef EXCLUSIVE_LOCKS_REQUIRED 12 | #define EXCLUSIVE_LOCKS_REQUIRED(...) 13 | #endif 14 | 15 | #ifndef SHARED_LOCKS_REQUIRED 16 | #define SHARED_LOCKS_REQUIRED(...) 17 | #endif 18 | 19 | #ifndef LOCKS_EXCLUDED 20 | #define LOCKS_EXCLUDED(...) 21 | #endif 22 | 23 | #ifndef LOCK_RETURNED 24 | #define LOCK_RETURNED(x) 25 | #endif 26 | 27 | #ifndef LOCKABLE 28 | #define LOCKABLE 29 | #endif 30 | 31 | #ifndef SCOPED_LOCKABLE 32 | #define SCOPED_LOCKABLE 33 | #endif 34 | 35 | #ifndef EXCLUSIVE_LOCK_FUNCTION 36 | #define EXCLUSIVE_LOCK_FUNCTION(...) 37 | #endif 38 | 39 | #ifndef SHARED_LOCK_FUNCTION 40 | #define SHARED_LOCK_FUNCTION(...) 41 | #endif 42 | 43 | #ifndef EXCLUSIVE_TRYLOCK_FUNCTION 44 | #define EXCLUSIVE_TRYLOCK_FUNCTION(...) 45 | #endif 46 | 47 | #ifndef SHARED_TRYLOCK_FUNCTION 48 | #define SHARED_TRYLOCK_FUNCTION(...) 49 | #endif 50 | 51 | #ifndef UNLOCK_FUNCTION 52 | #define UNLOCK_FUNCTION(...) 53 | #endif 54 | 55 | #ifndef NO_THREAD_SAFETY_ANALYSIS 56 | #define NO_THREAD_SAFETY_ANALYSIS 57 | #endif 58 | 59 | #endif // STORAGE_LEVELDB_PORT_THREAD_ANNOTATIONS_H 60 | -------------------------------------------------------------------------------- /sys/drtmh/src/port/win/stdint.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 The LevelDB Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. See the AUTHORS file for names of contributors. 4 | 5 | // MSVC didn't ship with this file until the 2010 version. 6 | 7 | #ifndef STORAGE_LEVELDB_PORT_WIN_STDINT_H_ 8 | #define STORAGE_LEVELDB_PORT_WIN_STDINT_H_ 9 | 10 | #if !defined(_MSC_VER) 11 | #error This file should only be included when compiling with MSVC. 12 | #endif 13 | 14 | // Define C99 equivalent types. 15 | typedef signed char int8_t; 16 | typedef signed short int16_t; 17 | typedef signed int int32_t; 18 | typedef signed long long int64_t; 19 | typedef unsigned char uint8_t; 20 | typedef unsigned short uint16_t; 21 | typedef unsigned int uint32_t; 22 | typedef unsigned long long uint64_t; 23 | 24 | #endif // STORAGE_LEVELDB_PORT_WIN_STDINT_H_ 25 | -------------------------------------------------------------------------------- /sys/drtmh/src/rocc_config.h.in: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // whether to use RDMA as a communication primitive 4 | #cmakedefine USE_RDMA @USE_RDMA@ 5 | #ifndef USE_RDMA 6 | #define USE_RDMA 1 // by default use RDMA 7 | #endif 8 | 9 | #cmakedefine ROCC_RBUF_SIZE_M @ROCC_RBUF_SIZE_M@ // rdma registered buf size 10 | #ifndef ROCC_RBUF_SIZE_M 11 | #define ROCC_RBUF_SIZE_M 10240 // default size: 10G 12 | #endif 13 | 14 | static_assert( 15 | ROCC_RBUF_SIZE_M <= 20240 && ROCC_RBUF_SIZE_M > 0, 16 | "RDMA registered buf size too large or too small!"); 17 | -------------------------------------------------------------------------------- /sys/drtmh/src/rtx/global_vars.cc: -------------------------------------------------------------------------------- 1 | #include "global_vars.h" 2 | 3 | namespace nocc { 4 | namespace rtx { 5 | 6 | SymmetricView *global_view = NULL; 7 | 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /sys/drtmh/src/rtx/global_vars.h: -------------------------------------------------------------------------------- 1 | #ifndef GLOBAL_VARS_H_ 2 | #define GLOBAL_VARS_H_ 3 | 4 | #include "view.h" 5 | 6 | namespace nocc { 7 | 8 | namespace rtx { 9 | 10 | /** 11 | * New meta data for each record 12 | */ 13 | struct RdmaValHeader { 14 | uint64_t lock; 15 | uint64_t seq; 16 | }; 17 | 18 | 19 | extern SymmetricView *global_view; 20 | 21 | } // namespace rtx 22 | } // namespace nocc 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /sys/drtmh/src/rtx/log_cleaner.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "core/rrpc.h" 4 | #include "log_store_manager.hpp" 5 | 6 | namespace nocc { 7 | 8 | namespace rtx { 9 | 10 | using namespace oltp; 11 | 12 | // The cleaner leverages log_store_manager to access backup stores 13 | class LogCleaner : public LogStoreManager { 14 | public: 15 | explicit LogCleaner(int num) : LogStoreManager(num) { 16 | 17 | } 18 | 19 | // the register_callback is used to register *clean_log* 20 | virtual void register_callback(int id,RRpc *rpc) = 0; 21 | 22 | virtual void clean_log(int nid,int cid,char *log,void *) = 0; 23 | }; 24 | 25 | }; // namespace rtx 26 | }; // namespace nocc 27 | -------------------------------------------------------------------------------- /sys/drtmh/src/rtx/log_store_manager.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "memstore/cluster_chaining.hpp" 4 | #include "memstore/memdb.h" 5 | 6 | namespace nocc { 7 | namespace rtx { 8 | 9 | #define RTX_BACKUP_MAX 4 // maxinum backups stored at this server 10 | 11 | class LogStoreManager { 12 | typedef drtm::ClusterHash store_map_t; 13 | public: 14 | explicit LogStoreManager(int expected_backup_num = RTX_BACKUP_MAX) 15 | :backup_stores_(expected_backup_num) 16 | { 17 | } 18 | 19 | // add a particular store to a specific DB 20 | void add_backup_store(int id,MemDB *db) { 21 | assert(backup_stores_.get(id) == NULL); 22 | auto new_val_p = backup_stores_.get_with_insert(id); 23 | *new_val_p = db; 24 | } 25 | 26 | MemDB *get_backed_store(int id) { 27 | return (*backup_stores_.get(id)); 28 | } 29 | 30 | protected: 31 | store_map_t backup_stores_; 32 | }; 33 | 34 | }; // namespace rtx 35 | 36 | }; 37 | 38 | -------------------------------------------------------------------------------- /sys/drtmh/src/rtx/msg_format.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // This header contains common msg definiation used in RTX 4 | 5 | namespace nocc { 6 | 7 | namespace rtx { 8 | 9 | enum req_type_t { 10 | RTX_REQ_READ = 0, 11 | RTX_REQ_READ_LOCK, 12 | RTX_REQ_INSERT 13 | }; 14 | 15 | // header of the requests message 16 | struct RTXRequestHeader { 17 | uint8_t cor_id; 18 | int8_t num; // num TX items in the message 19 | uint64_t padding; // a padding is left for user-defined entries 20 | } __attribute__ ((aligned (8))); 21 | 22 | struct RTXReadItem { 23 | req_type_t type; 24 | uint8_t pid; 25 | uint64_t key; 26 | uint8_t tableid; 27 | uint16_t idx; 28 | uint16_t len; 29 | inline RTXReadItem(req_type_t type,uint8_t pid,uint64_t key,uint8_t tableid,uint16_t len,uint8_t idx) 30 | :type(type),pid(pid),key(key),tableid(tableid),len(len),idx(idx) 31 | { 32 | } 33 | } __attribute__ ((aligned (8))); 34 | 35 | // entries of the request message 36 | struct RTXRemoteWriteItem { 37 | uint8_t pid; 38 | union { 39 | MemNode *node; 40 | uint64_t key; 41 | }; 42 | uint16_t payload; 43 | uint8_t tableid; 44 | } __attribute__ ((aligned (8))); 45 | 46 | struct RtxWriteItem { 47 | uint8_t pid; 48 | uint8_t tableid; 49 | uint64_t key; 50 | uint16_t len; 51 | RtxWriteItem(int pid,int tableid,uint64_t key,int len) : 52 | pid(pid),tableid(tableid),key(key),len(len) { 53 | 54 | } 55 | } __attribute__ ((aligned (8))); 56 | 57 | 58 | }; // namespace rtx 59 | }; // namespace nocc 60 | -------------------------------------------------------------------------------- /sys/drtmh/src/rtx/occ_statistics.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file should be included in occ.h 3 | */ 4 | 5 | LAT_VARS(lock); 6 | LAT_VARS(validate); 7 | LAT_VARS(commit); 8 | LAT_VARS(log); 9 | LAT_VARS(temp); 10 | 11 | #if NOCC_STATICS 12 | CountVector lock_; 13 | CountVector validate_; 14 | CountVector commit_; 15 | CountVector log_; 16 | CountVector temp_; 17 | 18 | void report_statics(uint64_t one_second) { 19 | 20 | lock_.erase(0.1); 21 | //validate_.erase(0.1); 22 | commit_.erase(0.1); 23 | log_.erase(0.1); 24 | temp_.erase(0.1); 25 | 26 | LOG(4) << "lock time: " << util::BreakdownTimer::rdtsc_to_ms(lock_.average(),one_second) << "ms"; 27 | LOG(4) << "logging time: " << util::BreakdownTimer::rdtsc_to_ms(log_.average(),one_second) << "ms"; 28 | LOG(4) << "commit time: " << util::BreakdownTimer::rdtsc_to_ms(commit_.average(),one_second) << "ms"; 29 | LOG(4) << "temp time: " << temp_.average() << "cycle"; 30 | } 31 | 32 | void record() { 33 | double res; 34 | REPORT_V(lock,res); 35 | lock_.push_back(res); 36 | 37 | REPORT_V(log,res); 38 | log_.push_back(res); 39 | 40 | REPORT_V(commit,res); 41 | commit_.push_back(res); 42 | 43 | REPORT_V(temp,res); 44 | temp_.push_back(res); 45 | } 46 | 47 | #else 48 | // no counting, return null 49 | void report_statics(uint64_t) { 50 | 51 | } 52 | 53 | void record() { 54 | 55 | } 56 | #endif 57 | -------------------------------------------------------------------------------- /sys/drtmh/src/rtx/op_test.cxx: -------------------------------------------------------------------------------- 1 | #include "gtest/gtest.h" 2 | 3 | #include "tx_operator.hpp" 4 | 5 | 6 | using namespace nocc::rtx; 7 | 8 | 9 | TEST(tx_test,get_op_test) { 10 | 11 | TXOpBase op_set; 12 | char buf[1024]; 13 | 14 | struct TestStruct { 15 | int x; 16 | int y; 17 | inline TestStruct(int x,int y): x(x),y(y) {} 18 | }; 19 | 20 | op_set.remote_rpc_op(0,buf,NULL,12,14); 21 | TestStruct *s = (TestStruct *)buf; 22 | ASSERT_EQ(s->x,12); 23 | ASSERT_EQ(s->y,14); 24 | 25 | op_set.remote_rpc_op(0,buf + sizeof(TestStruct),NULL,50,64); 26 | ASSERT_EQ(s[1].x,50); 27 | ASSERT_EQ(s[1].y,64); 28 | } 29 | -------------------------------------------------------------------------------- /sys/drtmh/src/rtx/opt_config.hh: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace nocc { 4 | 5 | namespace rtx { 6 | 7 | #define USE_NVM 1 8 | 9 | #define OPT_NT 1 10 | #define OPT_NT_ALIGN 0 11 | #define DRAM_LOCK 0 12 | 13 | #define SZ_OPT 0 14 | #define SZ_OPT_256 0 15 | #define NUMA_OPT 1 16 | 17 | #define PERSIST 0 18 | #define FLUSH_OPT 0 19 | 20 | 21 | } // namespace rtx 22 | } // namespace nocc 23 | -------------------------------------------------------------------------------- /sys/drtmh/src/rtx/qp_selection_helper.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is included in the *class definiation file*. 3 | * It provides utilities to help select RC qp for the remote servers. 4 | * We use this file to help using multiple QPs to connection to the same server. 5 | * 6 | * Pre-assumptions: 7 | * The class should contains a qp_vec_, which is type std::vector to store RC qps. 8 | */ 9 | // QP vector to store all QPs 10 | std::vector qp_vec_; 11 | uint qp_idx_[16]; 12 | 13 | #if LARGE_CONNECTION 14 | // FIXME: now only use 16 machines 15 | 16 | // Use a large number of connections 17 | inline __attribute__((always_inline)) 18 | rdmaio::Qp* get_qp(int pid){ 19 | int idx = (qp_idx_[pid]++) % QP_NUMS; 20 | Qp *qp = qp_vec_[pid * QP_NUMS + idx]; 21 | ASSERT(qp->nid == pid); 22 | return qp; 23 | } 24 | 25 | #else 26 | 27 | inline __attribute__((always_inline)) 28 | rdmaio::Qp* get_qp(int pid) { 29 | return qp_vec_[pid]; 30 | } 31 | 32 | #endif 33 | 34 | 35 | void fill_qp_vec(rdmaio::RdmaCtrl *cm,int wid) { 36 | 37 | assert(qp_vec_.size() == 0); 38 | // get rc qps 39 | auto num_nodes = cm->get_num_nodes(); 40 | for(uint i = 0;i < num_nodes;++i) { 41 | for(uint j = 0;j < QP_NUMS; j++){ 42 | rdmaio::Qp *qp = cm->get_rc_qp(wid,i,j); 43 | assert(qp != NULL); 44 | qp_vec_.push_back(qp); 45 | } 46 | } 47 | #if LARGE_CONNECTION 48 | // init the first QP idx to 0 49 | memset(qp_idx_,0,sizeof(qp_idx_)); 50 | #endif 51 | } 52 | 53 | // snaity checks 54 | static_assert(QP_NUMS >= 1,"Each mac requires at least one QP!"); 55 | #if !LARGE_CONNECTION 56 | static_assert(QP_NUMS == 1,"If not use a large connection, we should use exactly one QP to link to another node."); 57 | #endif 58 | -------------------------------------------------------------------------------- /sys/drtmh/src/rtx/rdma_op_impl.hpp: -------------------------------------------------------------------------------- 1 | #include "tx_config.h" 2 | 3 | namespace nocc { 4 | namespace rtx { 5 | 6 | inline __attribute__((always_inline)) 7 | uint64_t TXOpBase::rdma_lookup_op(int pid,int tableid,uint64_t key,char *val, 8 | yield_func_t &yield,int meta_len) { 9 | //Qp* qp = qp_vec_[pid]; 10 | Qp *qp = get_qp(pid); 11 | assert(qp != NULL); 12 | // MemNode will be stored in val, if necessary 13 | auto off = db_->stores_[tableid]->RemoteTraverse(key,qp,scheduler_,yield,val); 14 | return off; 15 | } 16 | 17 | inline __attribute__ ((always_inline)) 18 | uint64_t TXOpBase::rdma_read_val(int pid,int tableid,uint64_t key,int len,char *val,yield_func_t &yield,int meta_len) { 19 | auto data_off = pending_rdma_read_val(pid,tableid,key,len,val,yield,meta_len); 20 | worker_->indirect_yield(yield); // yield for waiting for NIC's completion 21 | return data_off; 22 | } 23 | 24 | inline __attribute__ ((always_inline)) 25 | uint64_t TXOpBase::pending_rdma_read_val(int pid,int tableid,uint64_t key,int len,char *val,yield_func_t &yield,int meta_len) { 26 | // store the memnode in val 27 | auto off = rdma_lookup_op(pid,tableid,key,val,yield,meta_len); 28 | MemNode *node = (MemNode *)val; 29 | 30 | auto data_off = off; 31 | #if !RDMA_CACHE 32 | data_off = node->off; // fetch the offset from the content 33 | #endif 34 | 35 | // fetch the content 36 | //Qp* qp = qp_vec_[pid]; 37 | Qp *qp = get_qp(pid); 38 | scheduler_->post_send(qp,worker_->cor_id(), 39 | IBV_WR_RDMA_READ,val,len + meta_len,data_off, IBV_SEND_SIGNALED); 40 | 41 | if(unlikely(qp->rc_need_poll())) { 42 | worker_->indirect_yield(yield); 43 | } 44 | 45 | return data_off; 46 | } 47 | 48 | } // namespace rtx 49 | 50 | } // namespace nocc 51 | -------------------------------------------------------------------------------- /sys/drtmh/src/rtx/view.cc: -------------------------------------------------------------------------------- 1 | #include "core/logging.h" 2 | #include "view.h" 3 | 4 | namespace nocc { 5 | 6 | namespace rtx { 7 | 8 | void SymmetricView::assign_backups(int total) { 9 | ASSERT(rep_factor_ <= RTX_MAX_BACKUP) << "Too many backups supported."; 10 | LOG(2) << "total " << total <<" backups to assign"; 11 | for(uint i = 0;i < total;++i) { 12 | mapping_.emplace_back(rep_factor_); 13 | assign_one(i,total); 14 | } 15 | } 16 | 17 | void SymmetricView::assign_one(int idx,int total) { 18 | 19 | ASSERT(total > rep_factor_) << "Cannot assign backups properly. Total mac " << total 20 | << "; rep factor " << rep_factor_; 21 | for(uint i = 0;i < rep_factor_;++i) { 22 | // uses static mapping. 23 | // maybe we can use a random strategy 24 | mapping_[idx][i] = (idx + i + 1) % (total); 25 | } 26 | } 27 | 28 | void SymmetricView::print() { 29 | for(uint i = 0;i < mapping_.size();++i) { 30 | LOG(2) << "Mac [" << i << "] backed by " << mapping_[i]; 31 | } 32 | } 33 | 34 | } // namespace rtx 35 | 36 | } // namespace nocc 37 | -------------------------------------------------------------------------------- /sys/drtmh/src/util/Makefile: -------------------------------------------------------------------------------- 1 | name = rdtsc 2 | 3 | rdtsc: 4 | g++ -o $(name) rdtsc_converter.cxx -std=c++0x 5 | 6 | clean: 7 | rm $(name) 8 | -------------------------------------------------------------------------------- /sys/drtmh/src/util/msg_buf_allocator.h: -------------------------------------------------------------------------------- 1 | #ifndef NOCC_UTIL_BUF_ALLOCATOR 2 | #define NOCC_UTIL_BUF_ALLOCATOR 3 | 4 | 5 | namespace nocc { 6 | 7 | namespace util { 8 | 9 | class MsgBufAllocator { 10 | 11 | }; // end class 12 | 13 | }; 14 | 15 | }; 16 | 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /sys/drtmh/src/util/rdtsc_converter.cxx: -------------------------------------------------------------------------------- 1 | #include "util.h" 2 | 3 | #include 4 | #include 5 | 6 | 7 | int main(int argc,char **argv) { 8 | 9 | assert(argc > 1); 10 | 11 | double cycles = atof(argv[1]); 12 | auto one_second_cycle = Breakdown_Timer::get_one_second_cycle(); 13 | 14 | double converted = cycles / one_second_cycle; 15 | 16 | fprintf(stdout,"one second cycles %lu\n",one_second_cycle); 17 | fprintf(stdout,"Takes %f us.\n",converted * 1000000); 18 | 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /sys/drtmh/src/util/rtm.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * The code is part of our project called DrTM, which leverages HTM and RDMA for speedy distributed 3 | * in-memory transactions. 4 | * 5 | * 6 | * Copyright (C) 2015 Institute of Parallel and Distributed Systems (IPADS), Shanghai Jiao Tong University 7 | * All rights reserved. 8 | * 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * 21 | * For more about this software, visit: http://ipads.se.sjtu.edu.cn/drtm.html 22 | * 23 | */ 24 | 25 | #include "rtm.h" 26 | 27 | //define the static member here 28 | SpinLock RTMScope::fblock; 29 | RTMProfile RTMTX::localprofile; 30 | __thread bool RTMTX::owner = false; 31 | -------------------------------------------------------------------------------- /sys/drtmh/src/util/simple_logger.h: -------------------------------------------------------------------------------- 1 | #ifndef SIMPLE_LOG 2 | #define SIMPLE_LOG 3 | 4 | 5 | // This is a simple wrapper to help manage debug infors 6 | 7 | #include "mapped_log.h" 8 | 9 | 10 | namespace simple_log { 11 | 12 | class SimpleLogger { 13 | 14 | // assert the results, if the assertion fails, print the message and exit 15 | void inline debug_assert(bool expression, xxx) { 16 | 17 | } 18 | }; 19 | }; 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /sys/drtmh/src/util/spinlock.h: -------------------------------------------------------------------------------- 1 | #ifndef LEVELDB_SPINLOCK_H 2 | #define LEVELDB_SPINLOCK_H 3 | 4 | #include 5 | #include "port/atomic.h" 6 | 7 | /* The counter should be initialized to be 0. */ 8 | class SpinLock { 9 | 10 | public: 11 | //0: free, 1: busy 12 | //occupy an exclusive cache line 13 | volatile uint8_t padding1[32]; 14 | volatile uint16_t lock; 15 | volatile uint8_t padding2[32]; 16 | public: 17 | 18 | SpinLock(){ lock = 0;} 19 | 20 | inline void Lock() { 21 | while (1) { 22 | if (!xchg16((uint16_t *)&lock, 1)) return; 23 | 24 | while (lock) cpu_relax(); 25 | } 26 | } 27 | 28 | inline void Unlock() 29 | { 30 | barrier(); 31 | lock = 0; 32 | } 33 | 34 | 35 | inline uint16_t Trylock() 36 | { 37 | return xchg16((uint16_t *)&lock, 1); 38 | } 39 | 40 | inline uint16_t IsLocked(){return lock;} 41 | 42 | 43 | }; 44 | 45 | #endif /* _RWLOCK_H */ 46 | -------------------------------------------------------------------------------- /sys/drtmh/third_party/gflags/.gitattributes: -------------------------------------------------------------------------------- 1 | # treat all files in this repository as text files 2 | # and normalize them to LF line endings when committed 3 | * text 4 | -------------------------------------------------------------------------------- /sys/drtmh/third_party/gflags/.gitignore: -------------------------------------------------------------------------------- 1 | /xcode/ 2 | /build/ 3 | /builds/ 4 | /build-*/ 5 | /_build/ 6 | .DS_Store 7 | CMakeCache.txt 8 | DartConfiguration.tcl 9 | Makefile 10 | CMakeFiles/ 11 | /Testing/ 12 | /include/gflags/config.h 13 | /include/gflags/gflags_completions.h 14 | /include/gflags/gflags_declare.h 15 | /include/gflags/gflags.h 16 | /lib/ 17 | /test/gflags_unittest_main.cc 18 | /test/gflags_unittest-main.cc 19 | /packages/ 20 | CMakeLists.txt.user 21 | /bazel-bin 22 | /bazel-genfiles 23 | /bazel-gflags 24 | /bazel-out 25 | /bazel-testlogs 26 | -------------------------------------------------------------------------------- /sys/drtmh/third_party/gflags/.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "doc"] 2 | path = doc 3 | url = https://github.com/gflags/gflags.git 4 | branch = gh-pages 5 | -------------------------------------------------------------------------------- /sys/drtmh/third_party/gflags/.travis.yml: -------------------------------------------------------------------------------- 1 | # Ubuntu 14.04 Trusty support, to get newer cmake and compilers. 2 | sudo: required 3 | dist: trusty 4 | 5 | language: cpp 6 | 7 | os: 8 | - linux 9 | - osx 10 | 11 | compiler: 12 | - clang 13 | - gcc 14 | 15 | env: 16 | - CONFIG=Release 17 | - CONFIG=Debug 18 | 19 | script: 20 | - mkdir out && cd out && cmake -D CMAKE_BUILD_TYPE=$CONFIG -D GFLAGS_BUILD_SHARED_LIBS=ON -D GFLAGS_BUILD_STATIC_LIBS=ON -D GFLAGS_BUILD_TESTING=ON .. && cmake --build . --config $CONFIG && ctest 21 | -------------------------------------------------------------------------------- /sys/drtmh/third_party/gflags/AUTHORS.txt: -------------------------------------------------------------------------------- 1 | google-gflags@googlegroups.com 2 | 3 | -------------------------------------------------------------------------------- /sys/drtmh/third_party/gflags/BUILD: -------------------------------------------------------------------------------- 1 | # Bazel (http://bazel.io/) BUILD file for gflags. 2 | # 3 | # See INSTALL.md for instructions for adding gflags to a Bazel workspace. 4 | 5 | licenses(["notice"]) 6 | 7 | exports_files(["src/gflags_completions.sh", "COPYING.txt"]) 8 | 9 | config_setting( 10 | name = "x64_windows", 11 | values = {"cpu": "x64_windows"}, 12 | ) 13 | 14 | load(":bazel/gflags.bzl", "gflags_sources", "gflags_library") 15 | 16 | (hdrs, srcs) = gflags_sources(namespace=["gflags", "google"]) 17 | gflags_library(hdrs=hdrs, srcs=srcs, threads=0) 18 | gflags_library(hdrs=hdrs, srcs=srcs, threads=1) 19 | -------------------------------------------------------------------------------- /sys/drtmh/third_party/gflags/COPYING.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2006, Google Inc. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above 11 | copyright notice, this list of conditions and the following disclaimer 12 | in the documentation and/or other materials provided with the 13 | distribution. 14 | * Neither the name of Google Inc. nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /sys/drtmh/third_party/gflags/GPATH: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SJTU-IPADS/librdpma/5216d108dd5496e8428c473134012c12dae54f5c/sys/drtmh/third_party/gflags/GPATH -------------------------------------------------------------------------------- /sys/drtmh/third_party/gflags/GRTAGS: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SJTU-IPADS/librdpma/5216d108dd5496e8428c473134012c12dae54f5c/sys/drtmh/third_party/gflags/GRTAGS -------------------------------------------------------------------------------- /sys/drtmh/third_party/gflags/GTAGS: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SJTU-IPADS/librdpma/5216d108dd5496e8428c473134012c12dae54f5c/sys/drtmh/third_party/gflags/GTAGS -------------------------------------------------------------------------------- /sys/drtmh/third_party/gflags/WORKSPACE: -------------------------------------------------------------------------------- 1 | # Copyright 2006 Google Inc. All Rights Reserved. 2 | # Use of this source code is governed by a BSD-style 3 | # license that can be found in the COPYING.txt file. 4 | 5 | # Bazel (http://bazel.io/) WORKSPACE file for gflags. 6 | workspace(name="com_github_gflags_gflags") 7 | -------------------------------------------------------------------------------- /sys/drtmh/third_party/gflags/appveyor.yml: -------------------------------------------------------------------------------- 1 | # Configuration for continuous integration service at appveyor.com 2 | 3 | version: '{build}' 4 | 5 | os: Visual Studio 2015 6 | 7 | environment: 8 | matrix: 9 | - Toolset: v140 10 | - Toolset: v120 11 | - Toolset: v110 12 | - Toolset: v100 13 | - Toolset: v90 14 | 15 | platform: 16 | - Win32 17 | - x64 18 | 19 | configuration: 20 | - Release 21 | 22 | matrix: 23 | exclude: 24 | - Toolset: v90 25 | platform: x64 26 | - Toolset: v100 27 | platform: x64 28 | 29 | build: 30 | verbosity: minimal 31 | 32 | before_build: 33 | - ps: | 34 | Write-Output "Configuration: $env:CONFIGURATION" 35 | Write-Output "Platform: $env:PLATFORM" 36 | $generator = switch ($env:TOOLSET) 37 | { 38 | "v140" {"Visual Studio 14 2015"} 39 | "v120" {"Visual Studio 12 2013"} 40 | "v110" {"Visual Studio 11 2012"} 41 | "v100" {"Visual Studio 10 2010"} 42 | "v90" {"Visual Studio 9 2008"} 43 | } 44 | if ($env:PLATFORM -eq "x64") 45 | { 46 | $generator = "$generator Win64" 47 | } 48 | 49 | build_script: 50 | - ps: | 51 | md _build -Force | Out-Null 52 | cd _build 53 | 54 | & cmake -G "$generator" -D CMAKE_CONFIGURATION_TYPES="Debug;Release" -D GFLAGS_BUILD_TESTING=ON -D GFLAGS_BUILD_SHARED_LIBS=ON -D GFLAGS_BUILD_STATIC_LIBS=ON .. 55 | if ($LastExitCode -ne 0) { 56 | throw "Exec: $ErrorMessage" 57 | } 58 | & cmake --build . --config $env:CONFIGURATION 59 | if ($LastExitCode -ne 0) { 60 | throw "Exec: $ErrorMessage" 61 | } 62 | 63 | test_script: 64 | - ps: | 65 | & ctest -C $env:CONFIGURATION --output-on-failure 66 | if ($LastExitCode -ne 0) { 67 | throw "Exec: $ErrorMessage" 68 | } 69 | -------------------------------------------------------------------------------- /sys/drtmh/third_party/gflags/cmake/README_runtime.txt: -------------------------------------------------------------------------------- 1 | This package contains runtime libraries only which are required 2 | by applications that use these libraries for the commandline flags 3 | processing. If you want to develop such application, download 4 | and install the development package instead. 5 | -------------------------------------------------------------------------------- /sys/drtmh/third_party/gflags/cmake/cmake_uninstall.cmake.in: -------------------------------------------------------------------------------- 1 | if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") 2 | message(FATAL_ERROR "Cannot find install manifest: @CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") 3 | endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") 4 | 5 | if (NOT DEFINED CMAKE_INSTALL_PREFIX) 6 | set (CMAKE_INSTALL_PREFIX "@CMAKE_INSTALL_PREFIX@") 7 | endif () 8 | message(${CMAKE_INSTALL_PREFIX}) 9 | 10 | file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) 11 | string(REGEX REPLACE "\n" ";" files "${files}") 12 | foreach(file ${files}) 13 | message(STATUS "Uninstalling $ENV{DESTDIR}${file}") 14 | if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") 15 | exec_program( 16 | "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" 17 | OUTPUT_VARIABLE rm_out 18 | RETURN_VALUE rm_retval 19 | ) 20 | if(NOT "${rm_retval}" STREQUAL 0) 21 | message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}") 22 | endif(NOT "${rm_retval}" STREQUAL 0) 23 | else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") 24 | message(STATUS "File $ENV{DESTDIR}${file} does not exist.") 25 | endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") 26 | endforeach(file) 27 | -------------------------------------------------------------------------------- /sys/drtmh/third_party/gflags/cmake/package.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@CMAKE_INSTALL_PREFIX@ 2 | exec_prefix=${prefix} 3 | bindir=${prefix}/@RUNTIME_INSTALL_DIR@ 4 | libdir=${prefix}/@LIBRARY_INSTALL_DIR@ 5 | includedir=${prefix}/@INCLUDE_INSTALL_DIR@ 6 | 7 | Name: @PACKAGE_NAME@ 8 | Version: @PACKAGE_VERSION@ 9 | Description: @PACKAGE_DESCRIPTION@ 10 | URL: @PACKAGE_URL@ 11 | Requires: 12 | Libs: -L${libdir} -lgflags 13 | Libs.private: -lpthread 14 | Cflags: -I${includedir} 15 | -------------------------------------------------------------------------------- /sys/drtmh/third_party/gflags/cmake/version.cmake.in: -------------------------------------------------------------------------------- 1 | ## gflags CMake configuration version file 2 | 3 | # ----------------------------------------------------------------------------- 4 | # library version 5 | set (PACKAGE_VERSION "@PACKAGE_VERSION@") 6 | 7 | # ----------------------------------------------------------------------------- 8 | # check compatibility 9 | 10 | # Perform compatibility check here using the input CMake variables. 11 | # See example in http://www.cmake.org/Wiki/CMake_2.6_Notes. 12 | 13 | set (PACKAGE_VERSION_COMPATIBLE TRUE) 14 | set (PACKAGE_VERSION_UNSUITABLE FALSE) 15 | 16 | if ("${PACKAGE_FIND_VERSION_MAJOR}" EQUAL "@PACKAGE_VERSION_MAJOR@" AND 17 | "${PACKAGE_FIND_VERSION_MINOR}" EQUAL "@PACKAGE_VERSION_MINOR@") 18 | set (PACKAGE_VERSION_EXACT TRUE) 19 | else () 20 | set (PACKAGE_VERSION_EXACT FALSE) 21 | endif () 22 | -------------------------------------------------------------------------------- /sys/drtmh/third_party/gflags/src/defines.h.in: -------------------------------------------------------------------------------- 1 | /* Generated from defines.h.in during build configuration using CMake. */ 2 | 3 | // Note: This header file is only used internally. It is not part of public interface! 4 | // Any cmakedefine is defined using the -D flag instead when Bazel is used. 5 | // For Bazel, this file is thus not used to avoid a private file in $(GENDIR). 6 | 7 | #ifndef GFLAGS_DEFINES_H_ 8 | #define GFLAGS_DEFINES_H_ 9 | 10 | 11 | // Define if you build this library for a MS Windows OS. 12 | #cmakedefine OS_WINDOWS 13 | 14 | // Define if you have the header file. 15 | #cmakedefine HAVE_STDINT_H 16 | 17 | // Define if you have the header file. 18 | #cmakedefine HAVE_SYS_TYPES_H 19 | 20 | // Define if you have the header file. 21 | #cmakedefine HAVE_INTTYPES_H 22 | 23 | // Define if you have the header file. 24 | #cmakedefine HAVE_SYS_STAT_H 25 | 26 | // Define if you have the header file. 27 | #cmakedefine HAVE_UNISTD_H 28 | 29 | // Define if you have the header file. 30 | #cmakedefine HAVE_FNMATCH_H 31 | 32 | // Define if you have the header file (Windows 2000/XP). 33 | #cmakedefine HAVE_SHLWAPI_H 34 | 35 | // Define if you have the strtoll function. 36 | #cmakedefine HAVE_STRTOLL 37 | 38 | // Define if you have the strtoq function. 39 | #cmakedefine HAVE_STRTOQ 40 | 41 | // Define if you have the header file. 42 | #cmakedefine HAVE_PTHREAD 43 | 44 | // Define if your pthread library defines the type pthread_rwlock_t 45 | #cmakedefine HAVE_RWLOCK 46 | 47 | 48 | #endif // GFLAGS_DEFINES_H_ 49 | -------------------------------------------------------------------------------- /sys/drtmh/third_party/gflags/test/config/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ## gflags package configuration tests 2 | 3 | cmake_minimum_required (VERSION 2.8.12 FATAL_ERROR) 4 | 5 | project (gflags_${TEST_NAME}) 6 | 7 | find_package (gflags REQUIRED) 8 | 9 | add_executable (foo main.cc) 10 | target_link_libraries (foo gflags::gflags) 11 | -------------------------------------------------------------------------------- /sys/drtmh/third_party/gflags/test/config/main.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | DEFINE_string(message, "Hello World!", "The message to print"); 5 | 6 | static bool ValidateMessage(const char* flagname, const std::string &message) 7 | { 8 | return !message.empty(); 9 | } 10 | DEFINE_validator(message, ValidateMessage); 11 | 12 | int main(int argc, char **argv) 13 | { 14 | gflags::SetUsageMessage("Test CMake configuration of gflags library (gflags-config.cmake)"); 15 | gflags::SetVersionString("0.1"); 16 | gflags::ParseCommandLineFlags(&argc, &argv, true); 17 | std::cout << FLAGS_message << std::endl; 18 | gflags::ShutDownCommandLineFlags(); 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /sys/drtmh/third_party/gflags/test/flagfile.1: -------------------------------------------------------------------------------- 1 | --version -------------------------------------------------------------------------------- /sys/drtmh/third_party/gflags/test/flagfile.2: -------------------------------------------------------------------------------- 1 | --foo=bar 2 | --nounused_bool -------------------------------------------------------------------------------- /sys/drtmh/third_party/gflags/test/flagfile.3: -------------------------------------------------------------------------------- 1 | --flagfile=flagfile.2 -------------------------------------------------------------------------------- /sys/drtmh/third_party/gflags/test/gflags_build.py.in: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import os 4 | import sys 5 | import subprocess 6 | import shutil 7 | 8 | CMAKE = '@CMAKE_COMMAND@' 9 | CMAKE_BUILD_TYPE = '@CMAKE_BUILD_TYPE@' 10 | TMPDIR = '@TMPDIR@' 11 | SRCDIR = '@SRCDIR@' 12 | GFLAGS_DIR = '@gflags_BINARY_DIR@' 13 | 14 | if __name__ == "__main__": 15 | if len(sys.argv) != 4: 16 | sys.stderr.write(' '.join(['usage:', sys.argv[0], ' \n'])) 17 | sys.exit(1) 18 | test_name = sys.argv[1] 19 | srcdir = sys.argv[2] 20 | expect_fail = (sys.argv[3].lower() in ['true', 'yes', 'on', '1']) 21 | bindir = os.path.join(TMPDIR, test_name) 22 | if TMPDIR == '': 23 | sys.stderr.write('Temporary directory not set!\n') 24 | sys.exit(1) 25 | # create build directory 26 | if os.path.isdir(bindir): shutil.rmtree(bindir) 27 | os.makedirs(bindir) 28 | # configure the build tree 29 | if subprocess.call([CMAKE, '-DCMAKE_BUILD_TYPE:STRING='+CMAKE_BUILD_TYPE, 30 | '-Dgflags_DIR:PATH='+GFLAGS_DIR, 31 | '-DTEST_NAME:STRING='+test_name, srcdir], cwd=bindir) != 0: 32 | sys.stderr.write('Failed to configure the build tree!\n') 33 | sys.exit(1) 34 | # build the test project 35 | exit_code = subprocess.call([CMAKE, '--build', bindir, '--config', CMAKE_BUILD_TYPE], cwd=bindir) 36 | if expect_fail == True: 37 | if exit_code == 0: 38 | sys.stderr.write('Build expected to fail, but it succeeded!\n') 39 | sys.exit(1) 40 | else: 41 | sys.stderr.write('Build failed as expected\n') 42 | exit_code = 0 43 | sys.exit(exit_code) 44 | -------------------------------------------------------------------------------- /sys/drtmh/third_party/gflags/test/gflags_declare_flags.cc: -------------------------------------------------------------------------------- 1 | #define GFLAGS_DLL_DECLARE_FLAG 2 | 3 | #include 4 | #include 5 | 6 | DECLARE_string(message); // in gflags_delcare_test.cc 7 | 8 | void print_message(); 9 | void print_message() 10 | { 11 | std::cout << FLAGS_message << std::endl; 12 | } 13 | -------------------------------------------------------------------------------- /sys/drtmh/third_party/gflags/test/gflags_declare_test.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | DEFINE_string(message, "", "The message to print"); 4 | void print_message(); // in gflags_declare_flags.cc 5 | 6 | int main(int argc, char **argv) 7 | { 8 | GFLAGS_NAMESPACE::SetUsageMessage("Test compilation and use of gflags_declare.h"); 9 | GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); 10 | print_message(); 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /sys/drtmh/third_party/gflags/test/gflags_strip_flags_test.cmake: -------------------------------------------------------------------------------- 1 | if (NOT BINARY) 2 | message (FATAL_ERROR "BINARY file to check not specified!") 3 | endif () 4 | file (STRINGS "${BINARY}" strings REGEX "This text should be stripped out") 5 | if (strings) 6 | message (FATAL_ERROR "Text not stripped from binary like it should be: ${BINARY}") 7 | endif () 8 | -------------------------------------------------------------------------------- /sys/drtmh/third_party/gflags/test/gflags_unittest_flagfile: -------------------------------------------------------------------------------- 1 | --test_flag=1 2 | --test_flag=2 3 | -------------------------------------------------------------------------------- /sys/drtmh/third_party/gflags/test/nc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ## gflags negative compilation tests 2 | 3 | cmake_minimum_required (VERSION 2.8.12 FATAL_ERROR) 4 | 5 | if (NOT TEST_NAME) 6 | message (FATAL_ERROR "Missing TEST_NAME CMake flag") 7 | endif () 8 | string (TOUPPER ${TEST_NAME} TEST_NAME_UPPER) 9 | 10 | project (gflags_${TEST_NAME}) 11 | 12 | find_package (gflags REQUIRED) 13 | include_directories ("${CMAKE_CURRENT_SOURCE_DIR}/..") 14 | add_definitions (-DTEST_${TEST_NAME_UPPER}) 15 | add_executable (gflags_${TEST_NAME} gflags_nc.cc) 16 | target_link_libraries(gflags_${TEST_NAME} gflags) 17 | -------------------------------------------------------------------------------- /sys/drtmh/third_party/micautil/hash.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef MICA_UTIL_HASH_H_ 3 | #define MICA_UTIL_HASH_H_ 4 | 5 | #include "citycrc_mod.h" 6 | 7 | namespace mica { 8 | namespace util { 9 | template 10 | static uint64_t hash(const T* key, size_t len) { 11 | return CityHash64(reinterpret_cast(key), len); 12 | } 13 | } 14 | } 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /sys/drtmh/third_party/micautil/table/fixedtable_impl/del.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef MICA_TABLE_FIXED_TABLE_IMPL_DEL_H_ 3 | #define MICA_TABLE_FIXED_TABLE_IMPL_DEL_H_ 4 | 5 | namespace mica { 6 | namespace table { 7 | template 8 | Result FixedTable::del(uint32_t caller_id, uint64_t key_hash, 9 | ft_key_t key) { 10 | // Can be called at both primary and backup datastores 11 | uint32_t bucket_index = calc_bucket_index(key_hash); 12 | Bucket* bucket = get_bucket(bucket_index); 13 | 14 | // We must be holding the lock on this bucket at primaries. 15 | if(is_primary) { 16 | assert(is_locked(bucket->timestamp)); 17 | assert(bucket->locker_id == caller_id); 18 | } 19 | 20 | Bucket* located_bucket; 21 | size_t item_index = find_item_index(bucket, key, &located_bucket); 22 | 23 | // The key must exist - we checked this when we acquired the bucket lock 24 | // at the primary 25 | assert(item_index < StaticConfig::kBucketCap); 26 | 27 | // If we are here, the key exists 28 | located_bucket->key_arr[item_index] = kFtInvalidKey; 29 | stat_dec(&Stats::count); 30 | 31 | fill_hole(located_bucket, item_index); 32 | 33 | // Coordinators acquire bucket locks at primary. No need to unlock at backups. 34 | if(is_primary) { 35 | // unlock_bucket_ptr() will only release the lock that was previously 36 | // acquired at the primary for this key's deletion. Other locks acquired by 37 | // @caller_id on this bucket are still held. 38 | unlock_bucket_ptr(caller_id, bucket); 39 | } 40 | 41 | stat_inc(&Stats::delete_found); 42 | return Result::kSuccess; 43 | } 44 | } 45 | } 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /sys/drtmh/third_party/micautil/table/fixedtable_impl/item.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef MICA_TABLE_FIXED_TABLE_IMPL_ITEM_H_ 3 | #define MICA_TABLE_FIXED_TABLE_IMPL_ITEM_H_ 4 | 5 | namespace mica { 6 | namespace table { 7 | 8 | template 9 | void FixedTable::set_item(Bucket *located_bucket, 10 | size_t item_index, ft_key_t key, 11 | const char* value) { 12 | located_bucket->key_arr[item_index] = key; 13 | uint8_t *_val = get_value(located_bucket, item_index); 14 | ::mica::util::memcpy(_val, value, val_size); 15 | } 16 | } 17 | } 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /sys/drtmh/third_party/micautil/table/fixedtable_impl/lock_bkt.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef MICA_TABLE_FIXED_TABLE_IMPL_LOCK_BKT_H_ 3 | #define MICA_TABLE_FIXED_TABLE_IMPL_LOCK_BKT_H_ 4 | 5 | // This is a datapath API function exposed to users. The internal locking 6 | // function @lock_bucket_ptr() is not exposed to users. 7 | namespace mica { 8 | namespace table { 9 | template 10 | Result FixedTable::lock_bucket_hash(uint32_t caller_id, 11 | uint64_t key_hash) { 12 | assert(is_primary); 13 | 14 | uint32_t bucket_index = calc_bucket_index(key_hash); 15 | Bucket* bucket = get_bucket(bucket_index); 16 | 17 | bool res = lock_bucket_ptr(caller_id, bucket); 18 | 19 | return res ? Result::kSuccess : Result::kLocked; 20 | } 21 | } 22 | } 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /sys/drtmh/third_party/micautil/table/fixedtable_impl/lock_bkt_and_get.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef MICA_TABLE_FIXED_TABLE_IMPL_LOCK_BKT_AND_GET_H_ 3 | #define MICA_TABLE_FIXED_TABLE_IMPL_LOCK_BKT_AND_GET_H_ 4 | 5 | namespace mica { 6 | namespace table { 7 | 8 | template 9 | Result FixedTable::lock_bkt_and_get(uint32_t caller_id, 10 | uint64_t key_hash, ft_key_t key, uint64_t *out_timestamp, char *value) { 11 | assert(is_primary); 12 | 13 | uint32_t bucket_index = calc_bucket_index(key_hash); 14 | Bucket* bucket = get_bucket(bucket_index); 15 | 16 | bool lock_success = lock_bucket_ptr(caller_id, bucket); 17 | if(lock_success) { 18 | // We acquired the lock, or we were already holding it for @caller_id 19 | Bucket* located_bucket; 20 | size_t item_index = find_item_index(bucket, key, &located_bucket); 21 | 22 | if (item_index < StaticConfig::kBucketCap) { 23 | // The key exists 24 | *out_timestamp = bucket->timestamp; 25 | uint64_t *_val = (uint64_t *) get_value(located_bucket, item_index); 26 | ::mica::util::memcpy(value, _val, val_size); 27 | return Result::kSuccess; 28 | } 29 | 30 | // The key does not exist, i.e., we failed. unlock_bucket_ptr() will only 31 | // release the lock that this function acquired. Other locks acquired 32 | // by @caller_id on this bucket are still held. 33 | unlock_bucket_ptr(caller_id, bucket); 34 | return Result::kNotFound; 35 | } else { 36 | return Result::kLocked; 37 | } 38 | 39 | } 40 | } 41 | } 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /sys/drtmh/third_party/micautil/table/fixedtable_impl/lock_bkt_for_ins.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef MICA_TABLE_FIXED_TABLE_IMPL_LOCK_BKT_FOR_INS_ 3 | #define MICA_TABLE_FIXED_TABLE_IMPL_LOCK_BKT_FOR_INS_ 4 | 5 | namespace mica { 6 | namespace table { 7 | 8 | template 9 | Result FixedTable::lock_bkt_for_ins(uint32_t caller_id, 10 | uint64_t key_hash, ft_key_t key, uint64_t *out_timestamp) { 11 | assert(is_primary); 12 | 13 | uint32_t bucket_index = calc_bucket_index(key_hash); 14 | Bucket* bucket = get_bucket(bucket_index); 15 | 16 | bool lock_success = lock_bucket_ptr(caller_id, bucket); 17 | if(lock_success) { 18 | // We acquired the lock, or we were already holding it for @caller_id 19 | Bucket* located_bucket; 20 | size_t item_index = find_item_index(bucket, key, &located_bucket); 21 | 22 | if (item_index == StaticConfig::kBucketCap) { 23 | // The key does not exist 24 | *out_timestamp = bucket->timestamp; 25 | return Result::kSuccess; 26 | } 27 | 28 | // The key exists, i.e., we failed. unlock_bucket_ptr() will only release 29 | // the lock that was previously acquired by this function. Other locks 30 | // acquired by @caller_id on this bucket are still held. 31 | unlock_bucket_ptr(caller_id, bucket); 32 | return Result::kExists; 33 | } else { 34 | return Result::kLocked; 35 | } 36 | 37 | } 38 | } 39 | } 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /sys/drtmh/third_party/micautil/table/fixedtable_impl/prefetch.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef MICA_TABLE_FIXED_TABLE_IMPL_PREFETCH_H_ 3 | #define MICA_TABLE_FIXED_TABLE_IMPL_PREFETCH_H_ 4 | 5 | namespace mica { 6 | namespace table { 7 | template 8 | void FixedTable::prefetch_table(uint64_t key_hash) const { 9 | uint32_t bucket_index = calc_bucket_index(key_hash); 10 | const Bucket* bucket = get_bucket(bucket_index); 11 | 12 | // bucket address is already 64-byte aligned 13 | 14 | // When value size is 16B, we need to prefetch 3 cache lines. For larger 15 | // values, we may need to prefetch more cache lines, but it does not seem to 16 | // improve performance. 17 | __builtin_prefetch(bucket, 0, 0); 18 | __builtin_prefetch(reinterpret_cast(bucket) + 64, 0, 0); 19 | __builtin_prefetch(reinterpret_cast(bucket) + 128, 0, 0); 20 | 21 | } 22 | 23 | } 24 | } 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /sys/drtmh/third_party/micautil/table/fixedtable_impl/set_spinlock.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef MICA_TABLE_FIXED_TABLE_IMPL_SET_LOCKED_H_ 3 | #define MICA_TABLE_FIXED_TABLE_IMPL_SET_LOCKED_H_ 4 | 5 | namespace mica { 6 | namespace table { 7 | template 8 | Result FixedTable::set_spinlock(uint32_t caller_id, 9 | uint64_t key_hash, ft_key_t key, const char* value) { 10 | // Can be called *locally* at both primary and backup datastores 11 | uint32_t bucket_index = calc_bucket_index(key_hash); 12 | Bucket* bucket = get_bucket(bucket_index); 13 | 14 | while(!lock_bucket_ptr(caller_id, bucket)) { 15 | // Spin on the bucket lock 16 | } 17 | 18 | Bucket* located_bucket; 19 | size_t item_index = find_item_index(bucket, key, &located_bucket); 20 | 21 | if (item_index == StaticConfig::kBucketCap) { 22 | // The key does not exist in the table 23 | item_index = get_empty(bucket, &located_bucket); 24 | if (item_index == StaticConfig::kBucketCap) { 25 | // no more space 26 | unlock_bucket_ptr(caller_id, bucket); 27 | return Result::kInsufficientSpaceIndex; // This should be fatal 28 | } 29 | 30 | stat_inc(&Stats::set_new); 31 | } 32 | 33 | // Here, @located_bucket either contains @key at index @item_index, or is 34 | // empty at this slot. 35 | set_item(located_bucket, item_index, key, value); 36 | unlock_bucket_ptr(caller_id, bucket); 37 | return Result::kSuccess; 38 | } 39 | } 40 | } 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /sys/drtmh/third_party/micautil/table/fixedtable_impl/unlock_bkt.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef MICA_TABLE_FIXED_TABLE_IMPL_UNLOCK_BKT_H_ 3 | #define MICA_TABLE_FIXED_TABLE_IMPL_UNLOCK_BKT_H_ 4 | 5 | namespace mica { 6 | namespace table { 7 | template 8 | // This is a datapath API function exposed to users. The internal locking 9 | // function @lock_bucket_ptr() is not exposed to users. 10 | Result FixedTable::unlock_bucket_hash(uint32_t caller_id, 11 | uint64_t key_hash) { 12 | assert(is_primary); 13 | 14 | uint32_t bucket_index = calc_bucket_index(key_hash); 15 | Bucket* bucket = get_bucket(bucket_index); 16 | 17 | // unlock_bucket_ptr() will only release one lock if @caller_id holds multiple 18 | // locks on this bucket. It will also do sanity checks. 19 | unlock_bucket_ptr(caller_id, bucket); 20 | return Result::kSuccess; 21 | } 22 | } 23 | } 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /sys/drtmh/third_party/micautil/table/ltable_impl/del.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef MICA_TABLE_LTABLE_IMPL_DEL_H_ 3 | #define MICA_TABLE_LTABLE_IMPL_DEL_H_ 4 | 5 | namespace mica { 6 | namespace table { 7 | template 8 | Result LTable::del(uint64_t key_hash, const char* key, 9 | size_t key_length) { 10 | assert(key_length <= kMaxKeyLength); 11 | 12 | uint32_t bucket_index = calc_bucket_index(key_hash); 13 | uint16_t tag = calc_tag(key_hash); 14 | 15 | Bucket* bucket = buckets_ + bucket_index; 16 | 17 | lock_bucket(bucket); 18 | 19 | Bucket* located_bucket; 20 | size_t item_index = 21 | find_item_index(bucket, key_hash, tag, key, key_length, &located_bucket); 22 | if (item_index == StaticConfig::kBucketSize) { 23 | unlock_bucket(bucket); 24 | stat_inc(&Stats::delete_notfound); 25 | return Result::kNotFound; 26 | } 27 | 28 | pool_->release(get_item_offset(located_bucket->item_vec[item_index])); 29 | 30 | located_bucket->item_vec[item_index] = 0; 31 | stat_dec(&Stats::count); 32 | 33 | fill_hole(located_bucket, item_index); 34 | 35 | unlock_bucket(bucket); 36 | 37 | stat_inc(&Stats::delete_found); 38 | return Result::kSuccess; 39 | } 40 | } 41 | } 42 | 43 | #endif -------------------------------------------------------------------------------- /sys/drtmh/third_party/micautil/table/ltable_impl/prefetch.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef MICA_TABLE_LTABLE_IMPL_PREFETCH_H_ 3 | #define MICA_TABLE_LTABLE_IMPL_PREFETCH_H_ 4 | 5 | namespace mica { 6 | namespace table { 7 | template 8 | void LTable::prefetch_table(uint64_t key_hash) const { 9 | uint32_t bucket_index = calc_bucket_index(key_hash); 10 | const Bucket* bucket = buckets_ + bucket_index; 11 | 12 | // bucket address is already 64-byte aligned 13 | __builtin_prefetch(bucket, 0, 0); 14 | 15 | if (StaticConfig::kBucketSize > 7) 16 | __builtin_prefetch(reinterpret_cast(bucket) + 64, 0, 0); 17 | 18 | // XXX: prefetch extra buckets, too? 19 | } 20 | 21 | template 22 | void LTable::prefetch_pool(uint64_t key_hash) const { 23 | uint32_t bucket_index = calc_bucket_index(key_hash); 24 | const Bucket* bucket = buckets_ + bucket_index; 25 | 26 | uint16_t tag = calc_tag(key_hash); 27 | 28 | size_t item_index; 29 | for (item_index = 0; item_index < StaticConfig::kBucketSize; item_index++) { 30 | uint64_t item_vec = bucket->item_vec[item_index]; 31 | if (get_tag(item_vec) != tag) continue; 32 | 33 | pool_->prefetch_item(get_item_offset(item_vec)); 34 | } 35 | } 36 | } 37 | } 38 | 39 | #endif -------------------------------------------------------------------------------- /sys/drtmh/third_party/micautil/table/ltable_impl/test.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef MICA_TABLE_LTABLE_IMPL_TEST_H_ 3 | #define MICA_TABLE_LTABLE_IMPL_TEST_H_ 4 | 5 | namespace mica { 6 | namespace table { 7 | template 8 | Result LTable::test(uint64_t key_hash, const char* key, 9 | size_t key_length) const { 10 | assert(key_length <= kMaxKeyLength); 11 | 12 | uint32_t bucket_index = calc_bucket_index(key_hash); 13 | uint16_t tag = calc_tag(key_hash); 14 | 15 | const Bucket* bucket = buckets_ + bucket_index; 16 | 17 | while (true) { 18 | uint32_t version_start = read_version_begin(bucket); 19 | 20 | const Bucket* located_bucket; 21 | size_t item_index = find_item_index(bucket, key_hash, tag, key, key_length, 22 | &located_bucket); 23 | 24 | if (version_start != read_version_end(bucket)) continue; 25 | 26 | if (item_index != StaticConfig::kBucketSize) { 27 | stat_inc(&Stats::test_found); 28 | return Result::kSuccess; 29 | } else { 30 | stat_inc(&Stats::test_notfound); 31 | return Result::kNotFound; 32 | } 33 | } 34 | // Not reachable. 35 | } 36 | } 37 | } 38 | 39 | #endif -------------------------------------------------------------------------------- /sys/drtmh/third_party/micautil/table/table.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef MICA_TABLE_TABLE_H_ 3 | #define MICA_TABLE_TABLE_H_ 4 | 5 | #include "mica/common.h" 6 | #include "mica/table/types.h" 7 | 8 | namespace mica { 9 | namespace table { 10 | class TableInterface { 11 | public: 12 | void reset(); 13 | 14 | Result del(uint64_t key_hash, const char* key, size_t key_length); 15 | 16 | Result get(uint64_t key_hash, const char* key, size_t key_length, 17 | char* out_value, size_t in_value_length, size_t* out_value_length, 18 | bool allow_mutation) const; 19 | 20 | Result increment(uint64_t key_hash, const char* key, size_t key_length, 21 | uint64_t increment, uint64_t* out_value); 22 | 23 | Result set(uint64_t key_hash, const char* key, size_t key_length, 24 | const char* value, size_t value_length, bool overwrite); 25 | 26 | Result test(uint64_t key_hash, const char* key, size_t key_length) const; 27 | 28 | void prefetch_table(uint64_t key_hash) const; 29 | void prefetch_pool(uint64_t key_hash) const; 30 | 31 | void print_buckets() const; 32 | void print_stats() const; 33 | void reset_stats(bool reset_count); 34 | }; 35 | } 36 | } 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /sys/drtmh/third_party/micautil/table/types.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef MICA_TABLE_TYPES_H_ 3 | #define MICA_TABLE_TYPES_H_ 4 | 5 | #include 6 | #include "mica/common.h" 7 | 8 | namespace mica { 9 | namespace table { 10 | enum class Result { 11 | kSuccess = 0, 12 | kLocked, 13 | kError, 14 | kInsufficientSpacePool, 15 | kInsufficientSpaceIndex, 16 | kExists, 17 | kNotEven, 18 | kNotFound, 19 | kPartialValue, 20 | kNotProcessed, 21 | kNotSupported, 22 | kTimedOut, 23 | kRejected, 24 | }; 25 | 26 | static std::string ResultString(enum Result r) 27 | { 28 | switch(r) { 29 | case Result::kSuccess: 30 | return std::string("Success"); 31 | case Result::kLocked: 32 | return std::string("Locked"); 33 | case Result::kError: 34 | return std::string("Error"); 35 | case Result::kInsufficientSpacePool: 36 | return std::string("Insufficient space in pool"); 37 | case Result::kInsufficientSpaceIndex: 38 | return std::string("Insufficient space in index"); 39 | case Result::kExists: 40 | return std::string("Exists"); 41 | case Result::kNotEven: 42 | return std::string("Value not even (F&A)"); 43 | case Result::kNotFound: 44 | return std::string("Not found"); 45 | case Result::kPartialValue: 46 | return std::string("Partial value"); 47 | case Result::kNotProcessed: 48 | return std::string("Not processed"); 49 | case Result::kNotSupported: 50 | return std::string("Not supported"); 51 | case Result::kTimedOut: 52 | return std::string("Timed out"); 53 | case Result::kRejected: 54 | return std::string("Rejected"); 55 | default: 56 | return std::string("Invalid ::mica::table Result type"); 57 | }; 58 | } 59 | 60 | } 61 | } 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /sys/octopus/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SJTU-IPADS/librdpma/5216d108dd5496e8428c473134012c12dae54f5c/sys/octopus/.DS_Store -------------------------------------------------------------------------------- /sys/octopus/.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "third_party/r2"] 2 | path = third_party/r2 3 | url = https://github.com/wxdwfc/r2.git 4 | [submodule "third_party/rlib"] 5 | path = third_party/rlib 6 | url = https://github.com/wxdwfc/rlibv2.git 7 | -------------------------------------------------------------------------------- /sys/octopus/cmake/FindCrypto.cmake: -------------------------------------------------------------------------------- 1 | # - Try to find the Crypto libcrypto library 2 | # Once done this will define 3 | # 4 | # CRYPTO_FOUND - system has the Crypto libcrypto library 5 | # CRYPTO_INCLUDE_DIR - the Crypto libcrypto include directory 6 | # CRYPTO_LIBRARIES - The libraries needed to use Crypto libcrypto 7 | 8 | # Copyright (c) 2009, Matteo Panella, 9 | # Copyright (c) 2006, Alexander Neundorf, 10 | # 11 | # Redistribution and use is allowed according to the terms of the BSD license. 12 | # For details see the accompanying COPYING-CMAKE-SCRIPTS file. 13 | 14 | 15 | IF(CRYPTO_LIBRARIES) 16 | SET(Crypto_FIND_QUIETLY TRUE) 17 | ENDIF(CRYPTO_LIBRARIES) 18 | 19 | IF(SSL_EAY_DEBUG AND SSL_EAY_RELEASE) 20 | SET(LIB_FOUND 1) 21 | ENDIF(SSL_EAY_DEBUG AND SSL_EAY_RELEASE) 22 | 23 | FIND_PATH(CRYPTO_INCLUDE_DIR openssl/crypto.h ) 24 | FIND_LIBRARY(CRYPTO_LIBRARIES NAMES crypto ) 25 | 26 | IF(CRYPTO_INCLUDE_DIR AND CRYPTO_LIBRARIES) 27 | SET(CRYPTO_FOUND TRUE) 28 | ELSE(CRYPTO_INCLUDE_DIR AND CRYPTO_LIBRARIES) 29 | SET(CRYPTO_FOUND FALSE) 30 | ENDIF (CRYPTO_INCLUDE_DIR AND CRYPTO_LIBRARIES) 31 | 32 | LIST(APPEND CRYPTO_LIBRARIES "libcryptopp.so") 33 | 34 | IF (CRYPTO_FOUND) 35 | IF (NOT Crypto_FIND_QUIETLY) 36 | MESSAGE(STATUS "Found libcrypto: ${CRYPTO_LIBRARIES}") 37 | ENDIF (NOT Crypto_FIND_QUIETLY) 38 | ELSE (CRYPTO_FOUND) 39 | IF (Crypto_FIND_REQUIRED) 40 | MESSAGE(FATAL_ERROR "Could NOT find libcrypto") 41 | ENDIF (Crypto_FIND_REQUIRED) 42 | ENDIF (CRYPTO_FOUND) 43 | 44 | MARK_AS_ADVANCED(CRYPTO_INCLUDE_DIR CRYPTO_LIBRARIES) 45 | 46 | -------------------------------------------------------------------------------- /sys/octopus/conf.xml: -------------------------------------------------------------------------------- 1 | 2 |
3 | 4 | 1 5 | 192.168.13.155 6 | 7 |
8 | -------------------------------------------------------------------------------- /sys/octopus/include/Configuration.hpp: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | * 3 | * 4 | * Tsinghua Univ, 2016 5 | * 6 | ***********************************************************************/ 7 | #ifndef CONFIGURATION_HEADER 8 | #define CONFIGURATION_HEADER 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | using namespace std; 18 | using namespace boost::property_tree; 19 | 20 | class Configuration { 21 | private: 22 | ptree pt; 23 | unordered_map id2ip; 24 | unordered_map ip2id; 25 | int ServerCount; 26 | public: 27 | Configuration(); 28 | ~Configuration(); 29 | string getIPbyID(uint16_t id); 30 | uint16_t getIDbyIP(string ip); 31 | unordered_map getInstance(); 32 | int getServerCount(); 33 | }; 34 | 35 | #endif -------------------------------------------------------------------------------- /sys/octopus/include/RPCClient.hpp: -------------------------------------------------------------------------------- 1 | #ifndef RPCCLINET_HREADER 2 | #define RPCCLINET_HREADER 3 | #include 4 | #include "RdmaSocket.hpp" 5 | #include "Configuration.hpp" 6 | #include "mempool.hpp" 7 | #include "global.h" 8 | 9 | using namespace std; 10 | class RPCClient { 11 | private: 12 | Configuration *conf; 13 | RdmaSocket *socket; 14 | MemoryManager *mem; 15 | bool isServer; 16 | uint32_t taskID; 17 | public: 18 | uint64_t mm; 19 | RPCClient(Configuration *conf, RdmaSocket *socket, MemoryManager *mem, uint64_t mm); 20 | RPCClient(); 21 | ~RPCClient(); 22 | RdmaSocket* getRdmaSocketInstance(); 23 | Configuration* getConfInstance(); 24 | bool RdmaCall(uint16_t DesNodeID, char *bufferSend, uint64_t lengthSend, char *bufferReceive, uint64_t lengthReceive); 25 | uint64_t ContractSendBuffer(GeneralSendBuffer *send); 26 | }; 27 | 28 | #endif -------------------------------------------------------------------------------- /sys/octopus/include/RPCServer.hpp: -------------------------------------------------------------------------------- 1 | #ifndef RPCSERVER_HREADER 2 | #define RPCSERVER_HREADER 3 | #include 4 | #include 5 | #include 6 | 7 | #include "TxManager.hpp" 8 | 9 | #include "RdmaSocket.hpp" 10 | #include "Configuration.hpp" 11 | #include "RPCClient.hpp" 12 | #include "mempool.hpp" 13 | #include "global.h" 14 | #include "filesystem.hpp" 15 | 16 | using namespace std; 17 | 18 | typedef unordered_map Thread2ID; 19 | 20 | typedef struct { 21 | uint64_t send; 22 | uint16_t NodeID; 23 | uint16_t offset; 24 | } RPCTask; 25 | 26 | class RPCServer { 27 | private: 28 | thread *wk; 29 | Configuration *conf; 30 | RdmaSocket *socket; 31 | MemoryManager *mem; 32 | uint64_t mm; 33 | TxManager *tx; 34 | RPCClient *client; 35 | int ServerCount; 36 | FileSystem *fs; 37 | int cqSize; 38 | Thread2ID th2id; 39 | vector tasks; 40 | bool UnlockWait; 41 | void Worker(int id); 42 | void ProcessRequest(GeneralSendBuffer *send, uint16_t NodeID, uint16_t offset); 43 | void ProcessQueueRequest(); 44 | public: 45 | RPCServer(int cqSize); 46 | RdmaSocket* getRdmaSocketInstance(); 47 | MemoryManager* getMemoryManagerInstance(); 48 | RPCClient* getRPCClientInstance(); 49 | TxManager* getTxManagerInstance(); 50 | uint64_t ContractReceiveBuffer(GeneralSendBuffer *send, GeneralReceiveBuffer *recv); 51 | void RequestPoller(int id); 52 | int getIDbyTID(); 53 | ~RPCServer(); 54 | }; 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /sys/octopus/include/TxManager.hpp: -------------------------------------------------------------------------------- 1 | #ifndef TXMANAGER_HEADER 2 | #define TXMANAGER_HEADER 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | using namespace std; 9 | 10 | #define CACHELINE_SIZE (64) 11 | 12 | inline void _mm_clflush(void *addr) { 13 | asm volatile("clflush %0" : "+m"(*(volatile char *)(addr))); 14 | } 15 | //#define _mm_clflush(addr) asm volatile("clflush %0" : "+m" (*(volatile char *)(addr))) 16 | 17 | typedef struct { 18 | uint64_t TxID; 19 | bool begin; 20 | bool prepare; 21 | bool commit; 22 | } __attribute__((packed)) DistributedLogEntry; 23 | 24 | typedef struct { 25 | uint64_t TxID; 26 | bool begin; 27 | char logData[4086]; 28 | bool commit; 29 | } __attribute__((packed)) LocalLogEntry; 30 | 31 | class TxManager { 32 | private: 33 | uint64_t LocalLogAddress; 34 | uint64_t DistributedLogAddress; 35 | uint64_t LocalLogIndex; 36 | uint64_t DistributedLogIndex; 37 | mutex LocalMutex; 38 | mutex DisMutex; 39 | public: 40 | TxManager(uint64_t LocalLogAddress, uint64_t DistributedLogAddress); 41 | ~TxManager(); 42 | void FlushData(uint64_t address, uint64_t size); 43 | uint64_t TxLocalBegin(); 44 | void TxWriteData(uint64_t TxID, uint64_t address, uint64_t size); 45 | uint64_t getTxWriteDataAddress(uint64_t txID); 46 | void TxLocalCommit(uint64_t TxID, bool action); 47 | uint64_t TxDistributedBegin(); 48 | void TxDistributedPrepare(uint64_t TxID, bool action); 49 | void TxDistributedCommit(uint64_t TxID, bool action); 50 | }; 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /sys/octopus/include/bitmap.hpp: -------------------------------------------------------------------------------- 1 | /*** Bitmap header. ***/ 2 | 3 | /** Version 1 + modification for table class. **/ 4 | 5 | /** Redundance check. **/ 6 | #ifndef BITMAP_HEADER 7 | #define BITMAP_HEADER 8 | 9 | /** Included files. **/ 10 | #include /* Standard integers. E.g. uint8_t */ 11 | #include /* Standard library for memory allocation and exit function. */ 12 | #include /* Standard I/O operations. E.g. fprintf() */ 13 | #include /* Header for memory operations. E.g. memset() */ 14 | 15 | /** Classes. **/ 16 | class Bitmap 17 | { 18 | private: 19 | uint8_t *bytes; /* Byte array to hold bitmap. */ 20 | uint64_t varCountFree; /* Count variable of free bits. */ 21 | uint64_t varCountTotal; /* Count variable of total bits. */ 22 | 23 | public: 24 | bool get(uint64_t pos, bool *status); /* Get status of a bit. */ 25 | bool set(uint64_t pos); /* Set a bit. */ 26 | bool clear(uint64_t pos); /* Clear a bit. */ 27 | bool findFree(uint64_t *pos); /* Find first free bit. */ 28 | uint64_t countFree(); /* Count of free bits. */ 29 | uint64_t countTotal(); /* Count of total bits. */ 30 | Bitmap(uint64_t count, char *buffer); /* Constructor of bitmap. Read buffer to initialize current status. */ 31 | ~Bitmap(); /* Destructor of bitmap. Do not free buffer. */ 32 | }; 33 | 34 | /** Redundance check. **/ 35 | #endif -------------------------------------------------------------------------------- /sys/octopus/include/debug.hpp: -------------------------------------------------------------------------------- 1 | /*** Debug header. ***/ 2 | 3 | /** Version 1 + Functional Model Modification **/ 4 | /** Redundance check. **/ 5 | #ifndef DEBUG_HEADER 6 | #define DEBUG_HEADER 7 | 8 | /** Included files. **/ 9 | #include /* Standard I/O operations. E.g. vprintf() */ 10 | #include /* Standard argument operations. E.g. va_list */ 11 | #include /* Time functions. E.g. gettimeofday() */ 12 | 13 | /** Defninitions. **/ 14 | #define MAX_FORMAT_LEN 255 15 | #define ODEBUG false 16 | #define TITLE false 17 | #define TIMER false 18 | #define CUR false 19 | /** Classes. **/ 20 | class Debug 21 | { 22 | private: 23 | static long startTime; /* Last start time in milliseconds. */ 24 | 25 | public: 26 | static void debugTitle(const char *str); /* Print debug title string. */ 27 | static void debugItem(const char *format, ...); /* Print debug item string. */ 28 | static void debugCur(const char *format, ...); /* Print debug item string. */ 29 | static void notifyInfo(const char *format, ...); /* Print normal notification. */ 30 | static void notifyError(const char *format, ...); /* Print error information. */ 31 | static void startTimer(const char*); /* Start timer and display information. */ 32 | static void endTimer(); /* End timer and display information. */ 33 | }; 34 | 35 | /** Redundance check. **/ 36 | #endif 37 | -------------------------------------------------------------------------------- /sys/octopus/include/lock.h: -------------------------------------------------------------------------------- 1 | #ifndef LOCK_HEADER 2 | #define LOCK_HEADER 3 | 4 | #include 5 | #include 6 | 7 | class LockService { 8 | private: 9 | uint16_t WriteID; 10 | uint16_t ReadID; 11 | uint64_t MetaDataBaseAddress; 12 | public: 13 | LockService(uint64_t MetaDataBaseAddress); 14 | ~LockService(); 15 | uint64_t WriteLock(uint16_t NodeID, uint64_t Address); 16 | bool WriteUnlock(uint64_t key, uint16_t NodeID, uint64_t Address); 17 | uint64_t ReadLock(uint16_t NodeID, uint64_t Address); 18 | bool ReadUnlock(uint64_t key, uint16_t NodeID, uint64_t Address); 19 | }; 20 | 21 | #endif -------------------------------------------------------------------------------- /sys/octopus/include/sha256.h: -------------------------------------------------------------------------------- 1 | /********************************************************************* 2 | * Filename: sha256.h 3 | * Author: Brad Conte (brad AT bradconte.com) 4 | * Copyright: 5 | * Disclaimer: This code is presented "as is" without any guarantees. 6 | * Details: Defines the API for the corresponding SHA1 implementation. 7 | *********************************************************************/ 8 | 9 | #ifndef SHA256_H 10 | #define SHA256_H 11 | 12 | /*************************** HEADER FILES ***************************/ 13 | #include 14 | 15 | /****************************** MACROS ******************************/ 16 | #define SHA256_BLOCK_SIZE 32 // SHA256 outputs a 32 byte digest 17 | 18 | /**************************** DATA TYPES ****************************/ 19 | typedef unsigned char BYTE; // 8-bit byte 20 | typedef unsigned int WORD; // 32-bit word, change to "long" for 16-bit machines 21 | 22 | typedef struct { 23 | BYTE data[64]; 24 | WORD datalen; 25 | unsigned long long bitlen; 26 | WORD state[8]; 27 | } SHA256_CTX; 28 | 29 | /*********************** FUNCTION DECLARATIONS **********************/ 30 | void sha256_init(SHA256_CTX *ctx); 31 | void sha256_update(SHA256_CTX *ctx, const BYTE data[], size_t len); 32 | void sha256_final(SHA256_CTX *ctx, BYTE hash[]); 33 | 34 | #endif // SHA256_H 35 | -------------------------------------------------------------------------------- /sys/octopus/scripts/build.toml: -------------------------------------------------------------------------------- 1 | [[pass]] 2 | host = "r740" 3 | path = '~/projects/octopus/build' 4 | cmd = 'cmake .. ; make dmfs -j12;' 5 | 6 | [[pass]] 7 | host = "val20" 8 | path = '~/projects/octopus/' 9 | cmd = 'cmake . ; make mpitest -j12; make mpibw;' 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /sys/octopus/scripts/run.toml: -------------------------------------------------------------------------------- 1 | [[sync]] 2 | source = "wxd@val20:~/projects/octopus/mpitest" 3 | targets = ["wxd@val20:~/temp", "wxd@val19:~/temp", "wxd@val21:~/temp", "wxd@val22:~/temp"] 4 | 5 | [[sync]] 6 | source = "wxd@val20:~/projects/octopus/mpibw" 7 | targets = ["wxd@val20:~/temp"] 8 | 9 | [[sync]] 10 | source = "wxd@r740:~/projects/octopus-rdma-nvm/conf.xml" 11 | targets = ["wxd@val20:~", "wxd@val19:~", "wxd@val21:~", "wxd@val22:~"] 12 | 13 | [[pass]] 14 | host = "r740" 15 | path = '~/projects/octopus/build' 16 | cmd = 'sudo su -c "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/octopus/deps/install/lib; ./dmfs" ' 17 | 18 | [[pass]] 19 | host = "val20" 20 | path = 'temp' 21 | cmd = 'export LD_LIBRARY_PATH=/home/wxd/octopus/deps/install/lib:$LD_LIBRARY_PATH; ./mpitest' 22 | 23 | [[pass]] 24 | host = "val19" 25 | path = 'temp' 26 | cmd = 'export LD_LIBRARY_PATH=/home/wxd/octopus/deps/install/lib:$LD_LIBRARY_PATH; ./mpitest' 27 | 28 | [[pass]] 29 | host = "val21" 30 | path = 'temp' 31 | cmd = 'export LD_LIBRARY_PATH=/home/wxd/octopus/deps/install/lib:$LD_LIBRARY_PATH; ./mpitest' 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /sys/octopus/scripts/run_bd.toml: -------------------------------------------------------------------------------- 1 | [[sync]] 2 | source = "wxd@val20:~/projects/octopus/mpibw" 3 | targets = ["wxd@val20:~/temp", "wxd@val19:~/temp", "wxd@val21:~/temp", "wxd@val22:~/temp"] 4 | 5 | [[sync]] 6 | source = "wxd@r740:~/projects/octopus-rdma-nvm/conf.xml" 7 | targets = ["wxd@val20:~", "wxd@val19:~", "wxd@val21:~", "wxd@val22:~"] 8 | 9 | [[pass]] 10 | host = "r740" 11 | path = '~/projects/octopus/build' 12 | cmd = 'sudo su -c "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/octopus/deps/install/lib; ./dmfs" ' 13 | 14 | [[pass]] 15 | host = "val19" 16 | path = 'temp' 17 | cmd = 'export PATH=/home/wxd/octopus/deps/install/bin:$PATH; export LD_LIBRARY_PATH=/home/wxd/octopus/deps/install/lib:$LD_LIBRARY_PATH; mpiexec -n 5 ./mpibw 1024 100000' 18 | 19 | [[pass]] 20 | host = "r740" 21 | path = '~/projects/rocc_nvm' 22 | cmd = 'sudo ./scripts/nvm_server --host=localhost --port=6666 -use_nvm=true -touch_mem=false --nvm_sz=10 --nvm_file=/dev/dax0.1 --numa_node=1' 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /sys/octopus/src/dummy.cpp: -------------------------------------------------------------------------------- 1 | #include "RPCServer.hpp" 2 | 3 | RPCServer *server; 4 | -------------------------------------------------------------------------------- /sys/octopus/src/fs/dmfs.cpp: -------------------------------------------------------------------------------- 1 | #include "RPCServer.hpp" 2 | #include 3 | #include 4 | 5 | #include "./nvm_region.hh" 6 | 7 | using namespace nvm; 8 | 9 | RPCServer *server; 10 | 11 | /* Catch ctrl-c and destruct. */ 12 | void Stop (int signo) { 13 | delete server; 14 | Debug::notifyInfo("DMFS is terminated, Bye."); 15 | _exit(0); 16 | } 17 | int main() { 18 | signal(SIGINT, Stop); 19 | server = new RPCServer(10); 20 | char *p = (char *)server->getMemoryManagerInstance()->getDataAddress(); 21 | while (true) { 22 | getchar(); 23 | printf("storage addr = %lx\n", (long)p); 24 | for (int i = 0; i < 12; i++) { 25 | printf("%c", p[i]); 26 | } 27 | printf("\n"); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /sys/octopus/src/fs/huge_region.hh: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "./memory_region.hh" 6 | 7 | namespace nvm { 8 | 9 | using namespace rdmaio; 10 | 11 | /*! 12 | Malloc huge pages in 2M huge pages 13 | */ 14 | class HugeRegion : public MemoryRegion { 15 | static u64 align_to_sz(const u64 &x, const usize &align_sz) { 16 | return (((x) + align_sz - 1) / align_sz * align_sz); 17 | } 18 | 19 | public: 20 | static ::rdmaio::Option> create(const u64 &sz, const usize &align_sz = (2 << 20)) { 21 | auto region = std::make_shared(sz,align_sz); 22 | if (region->valid()) 23 | return region; 24 | return {}; 25 | } 26 | 27 | explicit HugeRegion(const u64 &sz, const usize &align_sz = (2 << 20)) { 28 | 29 | this->sz = align_to_sz(sz + align_sz, align_sz); 30 | char *ptr = (char *)mmap( 31 | nullptr, this->sz, PROT_READ | PROT_WRITE, 32 | MAP_PRIVATE | MAP_ANONYMOUS | MAP_POPULATE | MAP_HUGETLB, -1, 0); 33 | 34 | if (ptr == MAP_FAILED) { 35 | this->addr = nullptr; 36 | RDMA_LOG(4) << "error allocating huge page wiht sz: " << this->sz 37 | << " aligned with: " << align_sz 38 | << "; with error: " << strerror(errno); 39 | } else { 40 | //RDMA_LOG(4) << "alloc huge page size: " << this->sz; 41 | this->addr = ptr; 42 | } 43 | } 44 | }; 45 | 46 | } // namespace nvm 47 | -------------------------------------------------------------------------------- /sys/octopus/src/fs/lock.cpp: -------------------------------------------------------------------------------- 1 | #include "lock.h" 2 | #include "RPCServer.hpp" 3 | extern RPCServer *server; 4 | LockService::LockService(uint64_t _MetaDataBaseAddress) 5 | : MetaDataBaseAddress(_MetaDataBaseAddress){} 6 | 7 | LockService::~LockService(){} 8 | 9 | uint64_t LockService::WriteLock(uint16_t NodeID, uint64_t Address) { 10 | int workerid = server->getIDbyTID(); 11 | uint16_t ID = __sync_fetch_and_add(&WriteID, 1ULL); 12 | uint64_t key = (uint64_t)NodeID; 13 | uint64_t LockAddress = MetaDataBaseAddress + Address; 14 | key = key << 16; 15 | key += ID; 16 | key = key << 32; 17 | while (true) { 18 | if (__sync_bool_compare_and_swap((uint64_t *)LockAddress, 0ULL, key)) 19 | break; 20 | //if (workerid == 0) { 21 | server->RequestPoller(workerid); 22 | //} 23 | } 24 | return key; 25 | } 26 | 27 | bool LockService::WriteUnlock(uint64_t key, uint16_t NodeID, uint64_t Address) { 28 | uint64_t LockAddress = MetaDataBaseAddress + Address; 29 | uint32_t *p = (uint32_t *)(LockAddress + 4); 30 | *p = 0; 31 | return true; 32 | } 33 | 34 | uint64_t LockService::ReadLock(uint16_t NodeID, uint64_t Address) { 35 | uint64_t LockAddress = MetaDataBaseAddress + Address; 36 | uint64_t preNumber = __sync_fetch_and_add((uint64_t*)LockAddress, 1ULL); 37 | preNumber = preNumber >> 32; 38 | if (preNumber == 0) { 39 | return 1; 40 | } else { 41 | while (true) { 42 | if (__sync_bool_compare_and_swap((uint32_t*)(LockAddress + 4), 0, 0)) 43 | break; 44 | usleep(1); 45 | } 46 | } 47 | return 1; 48 | } 49 | 50 | bool LockService::ReadUnlock(uint64_t key, uint16_t NodeID, uint64_t Address) { 51 | uint64_t LockAddress = MetaDataBaseAddress + Address; 52 | __sync_fetch_and_sub((uint64_t *)LockAddress, 1); 53 | return true; 54 | } 55 | -------------------------------------------------------------------------------- /sys/octopus/src/fs/memory_region.hh: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | // use some utilities (i.e., Option) defined in RLib 6 | #include "rlib/core/common.hh" 7 | #include "rlib/core/rmem/mem.hh" 8 | 9 | namespace nvm { 10 | 11 | using namespace rdmaio; 12 | 13 | struct MemoryRegion { 14 | u64 sz; // total region size 15 | 16 | void *addr = nullptr; // region 17 | 18 | void *start_ptr() const { return addr; } 19 | 20 | u64 size() const { return sz; } 21 | 22 | MemoryRegion() = default; 23 | 24 | MemoryRegion(const u64 &sz, void *addr) : sz(sz), addr(addr) {} 25 | 26 | virtual bool valid() { return addr != nullptr; } 27 | 28 | ::rdmaio::Option> convert_to_rmem() { 29 | if (!valid()) 30 | return {}; 31 | return std::make_shared(sz, [this](u64 s) { return addr; }, 32 | [](rmem::RMem::raw_ptr_t p) {}); 33 | } 34 | }; 35 | 36 | class DRAMRegion : public MemoryRegion { 37 | public: 38 | explicit DRAMRegion(const u64 &sz) : MemoryRegion(sz, malloc(sz)) { 39 | RDMA_ASSERT(this->addr != nullptr); 40 | } 41 | 42 | DRAMRegion(const u64 &sz, const int &numa_node) : MemoryRegion(sz, numa_alloc_onnode(sz, numa_node)) { 43 | RDMA_ASSERT(this->addr != nullptr); 44 | 45 | } 46 | 47 | static ::rdmaio::Option> create(const u64 &sz) { 48 | return std::make_shared(sz); 49 | } 50 | 51 | static ::rdmaio::Option> create(const u64 &sz,const int &numa) { 52 | return std::make_shared(sz,numa); 53 | } 54 | }; 55 | } // namespace nvm 56 | -------------------------------------------------------------------------------- /sys/octopus/src/net/Configuration.cpp: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | * 3 | * 4 | * Tsinghua Univ, 2016 5 | * 6 | ***********************************************************************/ 7 | 8 | #include "Configuration.hpp" 9 | #include "debug.hpp" 10 | 11 | using namespace std; 12 | 13 | Configuration::Configuration() { 14 | ServerCount = 0; 15 | read_xml("../conf.xml", pt); 16 | ptree child = pt.get_child("address"); 17 | for(BOOST_AUTO(pos,child.begin()); pos != child.end(); ++pos) 18 | { 19 | id2ip[(uint16_t)(pos->second.get("id"))] = pos->second.get("ip"); 20 | ip2id[pos->second.get("ip")] = pos->second.get("id"); 21 | Debug::notifyInfo("get ip: %s; id: %d\n",id2ip[1].c_str(), (uint16_t)(pos->second.get("id"))); 22 | ServerCount += 1; 23 | } 24 | } 25 | 26 | Configuration::~Configuration() { 27 | Debug::notifyInfo("Configuration is closed successfully."); 28 | } 29 | 30 | string Configuration::getIPbyID(uint16_t id) { 31 | return id2ip[id]; 32 | } 33 | 34 | uint16_t Configuration::getIDbyIP(string ip) { 35 | return ip2id[ip]; 36 | } 37 | 38 | unordered_map Configuration::getInstance() { 39 | return id2ip; 40 | } 41 | 42 | int Configuration::getServerCount() { 43 | return ServerCount; 44 | } 45 | -------------------------------------------------------------------------------- /third_party/rlib/.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | *.exe 3 | *.swp 4 | *.DS_Store 5 | build/ 6 | .vs/ 7 | .vscode/ 8 | .git/ 9 | .settings/ 10 | .cproject 11 | .project 12 | 13 | -------------------------------------------------------------------------------- /third_party/rlib/.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | before_script: 2 | - python -V # Print out python version for debugging 3 | - git config --global user.email "wxdwfc@gmail.com" 4 | - git config --global user.name "wxd" 5 | - git submodule sync 6 | - git submodule update --init 7 | 8 | # run tests using the binary built before 9 | build: 10 | stage: build 11 | tags: 12 | - rdma 13 | script: 14 | - cmake .; make ; 15 | 16 | test: 17 | stage: test 18 | tags: 19 | - rdma 20 | script: 21 | - cmake .; make coretest; ./coretest; 22 | 23 | example: 24 | stage : deploy 25 | tags: 26 | - rdma 27 | script: 28 | - cmake .; 29 | - make pclient; make pserver; 30 | - ./pserver & 31 | - ./pclient 32 | 33 | bench: 34 | stage : deploy 35 | tags: 36 | - rdma 37 | script: 38 | - cmake .; 39 | - make bench_client; make bench_server; 40 | 41 | 42 | -------------------------------------------------------------------------------- /third_party/rlib/.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "examples/gflags"] 2 | path = examples/gflags 3 | url = https://github.com/gflags/gflags.git 4 | [submodule "tests/googletest"] 5 | path = tests/googletest 6 | url = https://github.com/google/googletest.git 7 | -------------------------------------------------------------------------------- /third_party/rlib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8) 2 | 3 | add_definitions(-std=c++14) 4 | 5 | set(CMAKE_INCLUDE_CURRENT_DIR ON) 6 | set(CMAKE_CXX_COMPILER /usr/bin/g++) 7 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g") 8 | 9 | ## tests 10 | enable_testing() 11 | 12 | add_test(NAME test COMMAND coretest) 13 | add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --verbose 14 | DEPENDS coretest) 15 | 16 | include(tests/tests.cmake) 17 | 18 | ## for examples 19 | set(ggflags_DIR "${CMAKE_SOURCE_DIR}/examples/gflags") 20 | add_subdirectory(${CMAKE_SOURCE_DIR}/examples/gflags) 21 | 22 | include(examples/exp.cmake) 23 | 24 | project (rlib) 25 | 26 | -------------------------------------------------------------------------------- /third_party/rlib/benchs/README.md: -------------------------------------------------------------------------------- 1 | ### Benchmark files of RLib 2 | 3 | #### Build 4 | 5 | - `cmake .; make bench_naive; ` 6 | 7 | #### Benchmark workloads: 8 | 9 | TODO 10 | -------------------------------------------------------------------------------- /third_party/rlib/benchs/bench.cmake: -------------------------------------------------------------------------------- 1 | include_directories(./examples/gflags/include) 2 | 3 | add_executable(bench_client ./benchs/bench_client.cc) 4 | add_executable(bench_server ./benchs/bench_server.cc) 5 | add_executable(fly_client ./benchs/fly_bench/client.cc) 6 | add_executable(or_client ./benchs/or_bench/client.cc) 7 | add_executable(db_client ./benchs/db_bench/client.cc) 8 | 9 | 10 | set(benchs 11 | bench_client bench_server 12 | fly_client or_client db_client) 13 | 14 | foreach(b ${benchs}) 15 | target_link_libraries(${b} pthread ibverbs gflags) 16 | endforeach(b) -------------------------------------------------------------------------------- /third_party/rlib/benchs/bench_main.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | #include "../core/nicinfo.hh" 6 | #include "../core/rctrl.hh" 7 | 8 | #include "./thread.hh" 9 | 10 | #include "./reporter.hh" 11 | 12 | using namespace rdmaio; // warning: should not use it in a global space often 13 | 14 | using Thread_t = bench::Thread; 15 | 16 | DEFINE_int64(port, 8888, "Listener port."); 17 | DEFINE_int64(threads, 1, "#Threads used."); 18 | 19 | usize worker_fn(const usize &worker_id, Statics *); 20 | 21 | bool volatile running = true; 22 | 23 | int main(int argc, char **argv) { 24 | gflags::ParseCommandLineFlags(&argc, &argv, true); 25 | 26 | RCtrl ctrl(FLAGS_port); 27 | RDMA_LOG(4) << "(UD) Pingping server listenes at localhost:" << FLAGS_port; 28 | 29 | std::vector workers; 30 | std::vector worker_statics(FLAGS_threads); 31 | 32 | for (uint i = 0; i < FLAGS_threads; ++i) { 33 | workers.push_back( 34 | new Thread_t(std::bind(worker_fn, i, &(worker_statics[i])))); 35 | } 36 | 37 | // start the workers 38 | for (auto w : workers) { 39 | w->start(); 40 | } 41 | 42 | Reporter::report_thpt(worker_statics, 10); // report for 10 seconds 43 | running = false; // stop workers 44 | 45 | // wait for workers to join 46 | for (auto w : workers) { 47 | w->join(); 48 | } 49 | 50 | RDMA_LOG(4) << "done"; 51 | } 52 | 53 | usize worker_fn(const usize &worker_id, Statics *s) { 54 | RDMA_LOG(4) << "Bench worker: " << worker_id << " started"; 55 | 56 | while (running) { 57 | compile_fence(); 58 | sleep(1); 59 | s->increment(); // finish one request 60 | } 61 | return 0; 62 | } 63 | -------------------------------------------------------------------------------- /third_party/rlib/benchs/statics.hh: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../core/common.hh" 4 | 5 | namespace rdmaio { 6 | 7 | /*! 8 | * Statictics used for multi-thread reporting. 9 | * The structure is 128-byte padded and aligned to avoid false sharing. 10 | */ 11 | struct alignas(128) Statics { 12 | 13 | typedef struct { 14 | u64 counter = 0; 15 | u64 counter1 = 0; 16 | u64 counter2 = 0; 17 | u64 counter3 = 0; 18 | double lat = 0; 19 | } data_t; 20 | data_t data; 21 | 22 | char pad[128 - sizeof(data)]; 23 | 24 | void increment(int d = 1) { data.counter += d; } 25 | 26 | void increment_gap_1(u64 d) { data.counter1 += d; } 27 | }; 28 | 29 | } // namespace rdmaio 30 | -------------------------------------------------------------------------------- /third_party/rlib/benchs/thread.hh: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../core/common.hh" 4 | 5 | #include 6 | #include 7 | 8 | namespace bench { 9 | 10 | /*! 11 | This is a simple wrapper over pthread, which uses a more abstracted way to 12 | create threads. T: the return type of the thread. 13 | 14 | Example: 15 | To create one thread using the function `fn run() -> T`, one can use the 16 | following way: auto t = Thread([]() -> T { T res; return res; 17 | }); 18 | t.start(); // really run the thread 19 | t.join(); // wait for it to stop 20 | */ 21 | template class alignas(128) Thread { 22 | using thread_body_t = std::function; 23 | 24 | thread_body_t core_func; 25 | T res; 26 | pthread_t pid; // pthread id 27 | 28 | public: 29 | explicit Thread(const thread_body_t &b) : core_func(b) {} 30 | 31 | void start() { 32 | pthread_attr_t attr; 33 | RDMA_ASSERT(pthread_attr_init(&attr) == 0); 34 | RDMA_ASSERT(pthread_create(&pid, &attr, pthread_bootstrap, (void *)this) == 0); 35 | RDMA_ASSERT(pthread_attr_destroy(&attr) == 0); 36 | } 37 | 38 | T join() { 39 | RDMA_ASSERT(pthread_join(pid, nullptr) == 0); 40 | return get_res(); 41 | } 42 | 43 | T get_res() const { return res; } 44 | 45 | private: 46 | // TODO: what if the sizeof(T) is very large? 47 | static_assert(sizeof(T) < (128 - sizeof(thread_body_t) - sizeof(pthread_t)), 48 | "xx"); 49 | char padding[128 - (sizeof(thread_body_t) + sizeof(T) + sizeof(pthread_t))]; 50 | 51 | static void *pthread_bootstrap(void *p) { 52 | Thread *self = static_cast(p); 53 | self->res = self->core_func(); 54 | return nullptr; 55 | } 56 | }; 57 | 58 | } // namespace r2 59 | -------------------------------------------------------------------------------- /third_party/rlib/core/bootstrap/multi_msg_iter.hh: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "./multi_msg.hh" 4 | 5 | namespace rdmaio { 6 | 7 | namespace bootstrap { 8 | 9 | /*! 10 | MsgsIter provides a means to help iterating through the batched msg. 11 | Return a pointer and the size of the Msg. 12 | 13 | Example usage of an unsafe version (but without string copy): 14 | ` 15 | MultiMsg<1024> msgs; 16 | for (MsgsIter iter(msgs); iter.valid();iter.next()) { 17 | auto msg = iter.cur(); 18 | auto msg_ptr = std::get<0>(msg); 19 | auto msg_sz = std::get<1>(msg); 20 | } 21 | ` 22 | 23 | Example usage of a safe version: 24 | ` 25 | MultiMsg<1024> msgs; 26 | for (MsgsIter iter(msgs); iter.valid();iter.next()) { 27 | auto msg = iter.cur_msg(); 28 | // To use ... 29 | } 30 | ` 31 | */ 32 | template 33 | class MsgsIter { 34 | const Msgs *msgs_p; 35 | usize cur_idx = 0; 36 | 37 | public: 38 | explicit MsgsIter(const Msgs &msgs) : msgs_p(&msgs) {} 39 | 40 | bool valid() const { 41 | return cur_idx < msgs_p->num_msg(); 42 | } 43 | 44 | void next() { 45 | cur_idx += 1; 46 | } 47 | 48 | std::pair cur() const { 49 | RDMA_ASSERT(valid()); 50 | MsgEntry &entry = msgs_p->header->entries[cur_idx]; 51 | 52 | char *data_ptr = nullptr; 53 | { 54 | // unsafe code 55 | data_ptr = (char *)(msgs_p->buf->data() + entry.offset); 56 | } 57 | return std::make_pair(data_ptr,static_cast(entry.sz)); 58 | } 59 | 60 | // a safe (but with memcpy) version of cur() 61 | ByteBuffer cur_msg() const { 62 | auto msg = cur(); 63 | return ByteBuffer(std::get<0>(msg),std::get<1>(msg)); 64 | } 65 | }; 66 | } 67 | } // namespace rdmaio 68 | -------------------------------------------------------------------------------- /third_party/rlib/core/common.hh: -------------------------------------------------------------------------------- 1 | /** 2 | * This file provides common utilities and definiation of RLib 3 | */ 4 | 5 | #pragma once 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include "./utils/logging.hh" 13 | #include "./utils/option.hh" 14 | 15 | #include "./result.hh" 16 | 17 | namespace rdmaio { 18 | 19 | // some handy integer defines 20 | using u64 = uint64_t; 21 | using u32 = uint32_t; 22 | using u16 = uint16_t; 23 | using i64 = int64_t; 24 | using u8 = uint8_t; 25 | using i8 = int8_t; 26 | using usize = unsigned int; 27 | 28 | // some handy alias for smart pointer 29 | template 30 | using Arc = std::shared_ptr; 31 | 32 | #ifndef DISABLE_COPY_AND_ASSIGN 33 | #define DISABLE_COPY_AND_ASSIGN(classname) \ 34 | private: \ 35 | classname(const classname &) = delete; \ 36 | classname &operator=(const classname &) = delete 37 | #endif 38 | 39 | #ifndef unlikely 40 | #define unlikely(x) __builtin_expect(!!(x), 0) 41 | #endif 42 | 43 | #ifndef likely 44 | #define likely(x) __builtin_expect(!!(x), 1) 45 | #endif 46 | 47 | } // namespace rdmaio 48 | -------------------------------------------------------------------------------- /third_party/rlib/core/naming.hh: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "./common.hh" 6 | 7 | namespace rdmaio { 8 | 9 | /*! 10 | */ 11 | using HostId = std::tuple; // TCP host host,port 12 | 13 | /*! 14 | DevIdx is a handy way to identify the RNIC. 15 | A NIC is identified by a dev_id, while each device has several ports. 16 | */ 17 | struct DevIdx { 18 | usize dev_id; 19 | usize port_id; 20 | 21 | friend std::ostream &operator<<(std::ostream &os, const DevIdx &i) { 22 | return os << "{" << i.dev_id << ":" << i.port_id << "}"; 23 | } 24 | }; 25 | 26 | /*! 27 | Internal network address used by the driver 28 | */ 29 | struct __attribute__((packed)) RAddress { 30 | u64 subnet_prefix; 31 | u64 interface_id; 32 | u32 local_id; 33 | }; 34 | 35 | 36 | } // namespace rdmaio 37 | -------------------------------------------------------------------------------- /third_party/rlib/core/nicinfo.hh: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "nic.hh" 6 | 7 | namespace rdmaio { 8 | 9 | class RNicInfo { 10 | public: 11 | /*! 12 | Query all available RNic on the host machine. 13 | Return a vector of all their index used by RLib, 14 | so one can open a device handler using RNic, as follows: 15 | ` 16 | auto dev_idxs = RNicInfo::query_dev_names(); 17 | if(dev_idxs.size() > 0) { 18 | RNic nic(dev_idxs[0]); 19 | } 20 | ` 21 | */ 22 | static std::vector query_dev_names() { 23 | 24 | std::vector res; 25 | 26 | int num_devices; 27 | struct ibv_device **dev_list = ibv_get_device_list(&num_devices); 28 | 29 | for (uint i = 0; i < num_devices; ++i) { 30 | RNic rnic({.dev_id = i, .port_id = 73 /* a dummy value*/}); 31 | if (rnic.valid()) { 32 | ibv_device_attr attr; 33 | auto rc = ibv_query_device(rnic.get_ctx(), &attr); 34 | 35 | if (rc) 36 | continue; 37 | for (uint port_id = 1; port_id <= attr.phys_port_cnt; ++port_id) { 38 | res.push_back({.dev_id = i, .port_id = port_id}); 39 | } 40 | } else 41 | RDMA_ASSERT(false); 42 | } 43 | if (dev_list != nullptr) 44 | ibv_free_device_list(dev_list); 45 | return res; 46 | } 47 | }; // end class RNicInfo 48 | 49 | } // namespace rdmaio 50 | -------------------------------------------------------------------------------- /third_party/rlib/core/qps/abs_recv_allocator.hh: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../rmem/handler.hh" 4 | 5 | namespace rdmaio { 6 | 7 | namespace qp { 8 | 9 | class AbsRecvAllocator { 10 | public: 11 | /*! 12 | allocate an RDMA recv buffer, 13 | which has (ptr, key) 14 | */ 15 | virtual Option> 16 | alloc_one(const usize &sz) = 0; 17 | 18 | virtual Option> 19 | alloc_one_for_remote(const usize &sz) = 0; 20 | }; 21 | 22 | } // namespace qp 23 | } // namespace rdmaio 24 | -------------------------------------------------------------------------------- /third_party/rlib/core/rmem/config.hh: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../common.hh" 4 | 5 | namespace rdmaio { 6 | 7 | namespace rmem { 8 | 9 | /*! 10 | class for manging registeration permission of RDMA registered memory. 11 | The detailed documentation of it can be found at the documentation of ibverbs. 12 | Example usage: (generate a flag which has local write and remote read permissions) 13 | ` 14 | MemoryFlags flags; 15 | flags.clear_flags().add_local_write().add_remote_read(); 16 | 17 | // use it: 18 | auto value = flags.get_value(); 19 | */ 20 | class MemoryFlags 21 | { 22 | int protection_flags = IBV_ACCESS_LOCAL_WRITE | IBV_ACCESS_REMOTE_READ | 23 | IBV_ACCESS_REMOTE_WRITE | IBV_ACCESS_REMOTE_ATOMIC; 24 | public: 25 | MemoryFlags() = default; 26 | 27 | MemoryFlags& set_flags(int flags) 28 | { 29 | protection_flags = flags; 30 | return *this; 31 | } 32 | 33 | int get_value() const { return protection_flags; } 34 | 35 | MemoryFlags& clear_flags() { return set_flags(0); } 36 | 37 | MemoryFlags& add_local_write() 38 | { 39 | protection_flags |= IBV_ACCESS_LOCAL_WRITE; 40 | return *this; 41 | } 42 | 43 | MemoryFlags& add_remote_write() 44 | { 45 | protection_flags |= IBV_ACCESS_REMOTE_WRITE; 46 | /* 47 | According to https://www.rdmamojo.com/2012/09/07/ibv_reg_mr/ 48 | local write must be set to enable remote write 49 | */ 50 | add_local_write(); 51 | return *this; 52 | } 53 | 54 | MemoryFlags& add_remote_read() 55 | { 56 | protection_flags |= IBV_ACCESS_REMOTE_READ; 57 | return *this; 58 | } 59 | }; 60 | 61 | } // end namespace rmem 62 | 63 | } 64 | -------------------------------------------------------------------------------- /third_party/rlib/core/rmem/mem.hh: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "../common.hh" 6 | 7 | namespace rdmaio { 8 | 9 | namespace rmem { 10 | 11 | /*! 12 | An abstract memory handler of registered RDMA memory 13 | usage: 14 | auto mem = Arc(1024); 15 | assert(mem->valid()); 16 | 17 | RNic rnic(...); 18 | // then use it to register a handler 19 | RegHandler reg(mem,rnic); 20 | Option attr = reg.get_reg_attr(); 21 | 22 | Note, we recommend to use Arc for RegHandler and RNic, 23 | so that resources can be automatically freed. 24 | */ 25 | struct RMem { // state for "R"egistered "Mem"ory 26 | using raw_ptr_t = void *; 27 | using alloc_fn_t = std::function; 28 | using dealloc_fn_t = std::function; 29 | 30 | /*! 31 | Fixme: hwo to automatically dealloc the memory ? 32 | */ 33 | raw_ptr_t raw_ptr; 34 | const u64 sz; 35 | 36 | dealloc_fn_t dealloc_fn; 37 | 38 | explicit RMem(const u64 &s, 39 | alloc_fn_t af = [](u64 s) -> raw_ptr_t { 40 | return (raw_ptr_t)malloc(s); 41 | }, 42 | dealloc_fn_t df = [](raw_ptr_t p) { free(p); }) 43 | : raw_ptr(af(s)), sz(s), dealloc_fn(df) {} 44 | 45 | bool valid() const { return raw_ptr != nullptr; } 46 | 47 | ~RMem() { 48 | dealloc_fn(raw_ptr); 49 | } 50 | }; 51 | 52 | } // namespace rmem 53 | 54 | } // namespace rdmaio 55 | -------------------------------------------------------------------------------- /third_party/rlib/core/utils/mod.hh: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "./timer.hh" 4 | #include 5 | 6 | namespace rdmaio { 7 | 8 | /*! 9 | A set of number utilities. 10 | */ 11 | /** 12 | * This nice code comes from 13 | * https://stackoverflow.com/questions/1392059/algorithm-to-generate-bit-mask 14 | */ 15 | template static constexpr R bitmask(unsigned int const onecount) { 16 | return static_cast(-(onecount != 0)) & 17 | (static_cast(-1) >> ((sizeof(R) * CHAR_BIT) - onecount)); 18 | } 19 | } // namespace rdmaio 20 | -------------------------------------------------------------------------------- /third_party/rlib/core/utils/option.hh: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #if __cplusplus > 201402L && defined(_HAS_CXX17) 4 | #include 5 | #else 6 | /** 7 | * Disable warning. 8 | * Basically optional is very useful. 9 | */ 10 | //#pragma GCC diagnostic push 11 | //#pragma GCC diagnostic ignored "-W#warnings" 12 | #include 13 | //#pragma GCC diagnostic pop 14 | #endif 15 | 16 | namespace rdmaio { 17 | #if __cplusplus > 201402L && defined(_HAS_CXX17) 18 | template 19 | using Option = std::optional; 20 | #else 21 | template 22 | using Option = std::experimental::optional; 23 | #endif 24 | } 25 | -------------------------------------------------------------------------------- /third_party/rlib/core/utils/timer.hh: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace rdmaio { 6 | 7 | /** 8 | * a simple wrapper over std::time API 9 | */ 10 | class Timer { 11 | std::chrono::time_point start_time_; 12 | 13 | public: 14 | static constexpr double no_timeout() { 15 | return std::numeric_limits::max(); 16 | } 17 | 18 | Timer(std::chrono::time_point t = 19 | std::chrono::steady_clock::now()) 20 | : start_time_(t) {} 21 | 22 | ~Timer() = default; 23 | 24 | template bool timeout(double count) const { 25 | return passed() >= count; 26 | } 27 | 28 | double passed_sec() const { return passed(); } 29 | 30 | double passed_msec() const { return passed(); } 31 | 32 | template double passed() const { 33 | return passed(std::chrono::steady_clock::now()); 34 | } 35 | 36 | template 37 | double passed(std::chrono::time_point tt) const { 38 | const auto elapsed = std::chrono::duration_cast(tt - start_time_); 39 | return elapsed.count(); 40 | } 41 | 42 | void reset() { start_time_ = std::chrono::steady_clock::now(); } 43 | 44 | Timer &operator=(Timer &) = default; 45 | }; 46 | 47 | } // namespace rdmaio 48 | -------------------------------------------------------------------------------- /third_party/rlib/examples/exp.cmake: -------------------------------------------------------------------------------- 1 | include_directories(./examples/gflags/include) 2 | 3 | add_executable(pclient "${CMAKE_SOURCE_DIR}/examples/rc_pingpong/client.cc") 4 | add_executable(pserver "${CMAKE_SOURCE_DIR}/examples/rc_pingpong/server.cc") 5 | 6 | add_executable(uclient "${CMAKE_SOURCE_DIR}/examples/ud_pingpong/client.cc") 7 | add_executable(userver "${CMAKE_SOURCE_DIR}/examples/ud_pingpong/server.cc") 8 | 9 | target_link_libraries(pclient -lpthread ibverbs gflags) 10 | target_link_libraries(pserver -lpthread ibverbs gflags) 11 | 12 | target_link_libraries(uclient -lpthread ibverbs gflags) 13 | target_link_libraries(userver -lpthread ibverbs gflags) 14 | -------------------------------------------------------------------------------- /third_party/rlib/examples/rnic.cc: -------------------------------------------------------------------------------- 1 | #include "rnic.hpp" 2 | #include "qp_config.hpp" 3 | 4 | using namespace rdmaio; 5 | 6 | /** 7 | * This example gives how to query the RNic information using RLib. 8 | */ 9 | int main() { 10 | 11 | RDMA_LOG(2) << "This example prints the RNIC information on this machine."; 12 | 13 | // print all avaliable Nic's name (including their ports)y 14 | auto res = RNicInfo::query_dev_names(); 15 | RDMA_LOG(2) << "port num: " << res.size(); 16 | for(auto i : res) { 17 | RDMA_LOG(2) << "get devs: " << i; 18 | } 19 | 20 | // open an RNic handler, which is used to create QP, register MR, etc 21 | RNic nic({.dev_id = 0,.port_id = 1}); 22 | RDMA_LOG(2) << "nic " << nic.id << " ready: " << nic.ready(); 23 | 24 | // set a configuration of a QP 25 | QPConfig config; 26 | config.clear_access_flags().add_access_read(); 27 | RDMA_LOG(2) << config.desc_access_flags(); 28 | 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /third_party/rlib/examples/simple_connect.cc: -------------------------------------------------------------------------------- 1 | #include "rdma_ctrl.hpp" 2 | #include "rnic.hpp" 3 | 4 | using namespace rdmaio; 5 | 6 | const int tcp_port = 8888; 7 | 8 | /** 9 | * This file shows an exmaple of how to fetch remote mr attributes using RdmaCtrl. 10 | */ 11 | int main() { 12 | 13 | { 14 | RdmaCtrl ctrl(tcp_port); 15 | char *test_buffer = new char[64]; 16 | 17 | RNic nic({.dev_id = 0,.port_id = 1}); 18 | RDMA_LOG(2) << "nic " << nic.id << " ready: " << nic.ready(); 19 | 20 | RDMA_LOG(2) << ctrl.mr_factory.register_mr(73,test_buffer,64,nic); 21 | 22 | RemoteMemory::Attr attr; 23 | 24 | // now we test the fetched MR 25 | auto ret = RMemoryFactory::fetch_remote_mr(73, 26 | std::make_tuple("localhost",tcp_port), 27 | attr); 28 | RDMA_ASSERT(ret == SUCC); 29 | RDMA_LOG(2) << "Check fetched MR: " << attr.key << " " << (const void *)attr.buf 30 | << "; test buffer: " << (const void *)test_buffer; 31 | RDMA_ASSERT(attr.buf == (uintptr_t)test_buffer); 32 | 33 | ctrl.mr_factory.deregister_mr(73); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /third_party/rlib/roadmap: -------------------------------------------------------------------------------- 1 | Refine list: 2 | - Different codes (done, good result code) 3 | - Marshalling lib (done) 4 | - Memory (done) 5 | - Memory registration + factory (done) 6 | - QPs 7 | - progress (done) 8 | - RC (done) 9 | - QP poll 10 | - QP factory 11 | - fetch op 12 | - Simple bootstrap RPC 13 | - timeout (done) 14 | - TCP (done) 15 | - RPC sender (done) 16 | - RPC receiver (done) 17 | - UDP (done) 18 | - connector () 19 | - QPs 20 | - UD -------------------------------------------------------------------------------- /third_party/rlib/scripts/bench.toml: -------------------------------------------------------------------------------- 1 | [[pass]] 2 | host = "val2" 3 | path = '' 4 | cmd = 'cd /cock/rlib; ./bench_naive --threads=4' -------------------------------------------------------------------------------- /third_party/rlib/scripts/benchs/rw_bench/make.toml: -------------------------------------------------------------------------------- 1 | [[pass]] 2 | host = "val09" 3 | path = '' 4 | cmd = 'cd rib/; cmake .; make bench_server;' 5 | 6 | [[pass]] 7 | host = "val08" 8 | path = '' 9 | cmd = 'cd rib/; cmake .; make bench_client;' 10 | 11 | [[pass]] 12 | host = "val10" 13 | path = '' 14 | cmd = 'cd rib/; cmake .; make bench_client;' -------------------------------------------------------------------------------- /third_party/rlib/scripts/benchs/rw_bench/run.toml: -------------------------------------------------------------------------------- 1 | [[pass]] 2 | host = "val09" 3 | path = '' 4 | cmd = 'cd rib/; ./bench_server' 5 | 6 | [[pass]] 7 | host = "val08" 8 | path = '' 9 | cmd = 'cd rib/; ./bench_client -client_name val08 -threads 12' 10 | 11 | [[pass]] 12 | host = "val10" 13 | path = '' 14 | cmd = 'cd rib/; ./bench_client -client_name val10 -threads 12' -------------------------------------------------------------------------------- /third_party/rlib/scripts/examples/rc_overflow/make.toml: -------------------------------------------------------------------------------- 1 | [[pass]] 2 | host = "val08" 3 | path = '' 4 | cmd = 'cd rib/; cmake .; make roclient;' 5 | 6 | [[pass]] 7 | host = "val09" 8 | path = '' 9 | cmd = 'cd rib/; cmake .; make roserver;' -------------------------------------------------------------------------------- /third_party/rlib/scripts/examples/rc_overflow/run.toml: -------------------------------------------------------------------------------- 1 | [[pass]] 2 | host = "val09" 3 | path = '' 4 | cmd = 'cd rib/; ./roserver' 5 | 6 | [[pass]] 7 | host = "val08" 8 | path = '' 9 | cmd = 'cd rib/; ./roclient -addr val09:8888' -------------------------------------------------------------------------------- /third_party/rlib/scripts/examples/ud_overflow/make.toml: -------------------------------------------------------------------------------- 1 | [[pass]] 2 | host = "val08" 3 | path = '' 4 | cmd = 'cd rib/; cmake .; make uoclient;' 5 | 6 | [[pass]] 7 | host = "val09" 8 | path = '' 9 | cmd = 'cd rib/; cmake .; make uoserver;' -------------------------------------------------------------------------------- /third_party/rlib/scripts/examples/ud_overflow/run.toml: -------------------------------------------------------------------------------- 1 | [[pass]] 2 | host = "val09" 3 | path = '' 4 | cmd = 'cd rib/; ./uoserver' 5 | 6 | [[pass]] 7 | host = "val08" 8 | path = '' 9 | cmd = 'cd rib/; ./uoclient -addr val09:8888' -------------------------------------------------------------------------------- /third_party/rlib/scripts/make.toml: -------------------------------------------------------------------------------- 1 | [[pass]] 2 | host = "val02" 3 | path = '' 4 | cmd = 'cd rib/; cmake .; make coretest' -------------------------------------------------------------------------------- /third_party/rlib/scripts/run.toml: -------------------------------------------------------------------------------- 1 | [[pass]] 2 | host = "val08" 3 | path = '' 4 | cmd = 'cd rib/; ./pserver' 5 | 6 | [[pass]] 7 | host = "val08" 8 | path = '' 9 | cmd = 'cd rib/; ./pclient' -------------------------------------------------------------------------------- /third_party/rlib/scripts/sync_to_server.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # this script will sync the project to the remote server 3 | 4 | user="wjq" 5 | target=("val08" "val09") 6 | 7 | for machine in ${target[*]} 8 | do 9 | rsync -i -rtuv \ 10 | $PWD/../core $PWD/../tests $PWD/../examples $PWD/../benchs $PWD/../CMakeLists.txt \ 11 | ${user}@${machine}:/home/${user}/rib 12 | done 13 | -------------------------------------------------------------------------------- /third_party/rlib/sync_to_server.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | #target="$1" 4 | target="wxd@cube1" 5 | ## this script will sync the project to the remote server 6 | rsync -i -rtuv \ 7 | $PWD/core $PWD/tests $PWD/examples $PWD/CMakeLists.txt $target:/raid/wxd/rlib/ 8 | -------------------------------------------------------------------------------- /third_party/rlib/tests/main.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(int argc, char **argv) { 4 | ::testing::InitGoogleTest(&argc, argv); 5 | return RUN_ALL_TESTS(); 6 | } 7 | -------------------------------------------------------------------------------- /third_party/rlib/tests/sample.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | TEST(RDMAIO,Sample) { 4 | ASSERT_EQ(1,1); 5 | } 6 | -------------------------------------------------------------------------------- /third_party/rlib/tests/test_common.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "../core/common.hh" 4 | 5 | TEST(RDMAIO, Common) { 6 | using namespace rdmaio; 7 | 8 | auto result = Ok(); 9 | ASSERT_EQ(result.code.c, IOCode::Ok); 10 | ASSERT_EQ(result.code.name(), "Ok"); 11 | auto res = (result.code == IOCode::Ok); 12 | ASSERT_TRUE(res); 13 | } 14 | -------------------------------------------------------------------------------- /third_party/rlib/tests/test_device.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "../core/qps/ud.hh" 4 | #include "../core/cm_cmd/mod.hh" 5 | 6 | namespace test { 7 | 8 | TEST(Device, Basic) { 9 | 10 | using namespace rdmaio::cmd; 11 | 12 | auto &dev = Device::get(); 13 | ASSERT_TRUE(dev.valid()); 14 | 15 | auto id0 = dev.alloc_handle().value(); 16 | RDMA_LOG(4) << "alloc id: " << id0; 17 | RDMA_LOG(4) << "alloc id2: " << dev.alloc_handle().value(); 18 | 19 | struct sockaddr_in sin; 20 | sin.sin_family = AF_INET; 21 | sin.sin_port = htons(8888); 22 | sin.sin_addr.s_addr = INADDR_ANY; 23 | 24 | dev.bind_addr(id0,sin); 25 | dev.query_addr(id0); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /third_party/rlib/tests/test_marshal.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "../core/utils/marshal.hh" 4 | 5 | using namespace rdmaio; 6 | 7 | TEST(Marshal,basic) { 8 | 9 | // init the test buffer 10 | usize test_sz = 12; 11 | 12 | ByteBuffer test_buf = Marshal::alloc(test_sz); 13 | for(u8 i = 0;i < test_sz;++i) { 14 | //Marshal::safe_set_byte(test_buf,i,i); 15 | test_buf[i] = i; 16 | } 17 | 18 | auto res = Marshal::forward(test_buf, 0); 19 | usize count = 0; 20 | while(res && count < test_sz) { 21 | 22 | ASSERT_EQ(res.value()[0],count); 23 | count += 1; 24 | 25 | res = Marshal::forward(res.value(), 1); 26 | } 27 | ASSERT_EQ(count, test_sz); 28 | } 29 | 30 | 31 | TEST(Marshal,dedump) { 32 | u64 test_val = 73; 33 | ByteBuffer buf = Marshal::dump(test_val); 34 | auto dedumped_val = Marshal::dedump(buf).value(); 35 | ASSERT_EQ(dedumped_val,test_val); 36 | } 37 | -------------------------------------------------------------------------------- /third_party/rlib/tests/test_nicinfo.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "../core/nicinfo.hh" 4 | 5 | TEST(RNic,Exists) { 6 | using namespace rdmaio; 7 | auto res = RNicInfo::query_dev_names(); 8 | ASSERT_FALSE(res.empty()); // there has to be NIC on the host machine 9 | } 10 | -------------------------------------------------------------------------------- /third_party/rlib/tests/test_qp_progress.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "../core/qps/mod.hh" 4 | #include "./fast_random.hh" 5 | 6 | namespace test { 7 | 8 | using namespace rdmaio; 9 | using namespace rdmaio::qp; 10 | 11 | TEST(QP, Progress) { 12 | 13 | auto limit = std::numeric_limits::max(); 14 | 15 | Progress progress; 16 | 17 | progress.forward(12); 18 | ASSERT_EQ(progress.pending_reqs(), 12); 19 | 20 | progress.done(12); 21 | ASSERT_EQ(progress.pending_reqs(), 0); 22 | 23 | // now we run a bunch of whole tests 24 | FastRandom rand(0xdeadbeaf); 25 | u64 sent = 0; 26 | u64 done = 0; 27 | 28 | u64 temp_done = 0; 29 | #if 0 // usually we donot do this test, since it's so time consuming 30 | Progress p2; 31 | 32 | while(sent <= 33 | static_cast(std::numeric_limits::max()) * 64) { 34 | int to_send = rand.rand_number(12, 4096); 35 | p2.forward(to_send); 36 | 37 | sent += to_send; 38 | ASSERT_EQ(p2.pending_reqs(),to_send); 39 | 40 | int to_recv = rand.rand_number(0,to_send); 41 | while(to_send > 0) { 42 | temp_done += to_recv; 43 | p2.done(temp_done); 44 | ASSERT(to_send >= to_recv) << "send: " << to_send <<";" 45 | << "recv: " << to_recv; 46 | ASSERT_EQ(p2.pending_reqs(),to_send - to_recv); 47 | to_send -= to_recv; 48 | 49 | to_recv = rand.rand_number(0, to_send); 50 | } 51 | } 52 | ASSERT_EQ(p2.pending_reqs(),0); 53 | #endif 54 | } 55 | 56 | } // namespace test 57 | -------------------------------------------------------------------------------- /third_party/rlib/tests/test_rpc.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "../core/bootstrap/srpc.hh" 4 | 5 | namespace test { 6 | 7 | using namespace rdmaio; 8 | using namespace rdmaio::bootstrap; 9 | 10 | TEST(RPC, Basic) { 11 | 12 | SRpc rpc("localhost:1111"); 13 | SRpcHandler handler(1111); 14 | 15 | for (uint i = 0; i < 12; ++i) { 16 | handler.register_handler(73 + i, [i](const ByteBuffer &b) -> ByteBuffer { 17 | RDMA_ASSERT(b.size() == i + 233) 18 | << "recv sz: " << b.size() << "; compare:" << 233 + i; 19 | RDMA_ASSERT(b.compare(ByteBuffer(i + 233, '3' + i)) == 0); 20 | return ByteBuffer(73 + i, '1' + i); 21 | }); 22 | } 23 | 24 | for (uint i = 0; i < 12; ++i) { 25 | 26 | // send the rpc 27 | auto res = rpc.call(73 + i, ByteBuffer(233 + i, '3' + i)); 28 | RDMA_ASSERT(res == IOCode::Ok) << "call error: " << res.desc; 29 | 30 | // wait for enough time so the msg must arrive at the target 31 | sleep(1); 32 | 33 | auto rpc_calls = handler.run_one_event_loop(); 34 | ASSERT_EQ(rpc_calls, 1); 35 | 36 | // wait for enough time so the reply must arrive at the sender 37 | sleep(1); 38 | 39 | auto res_reply = rpc.receive_reply(); 40 | RDMA_ASSERT(res_reply == IOCode::Ok); 41 | 42 | ASSERT_EQ(res_reply.desc.size(), 73 + i); 43 | } 44 | } 45 | 46 | } // namespace test 47 | -------------------------------------------------------------------------------- /third_party/rlib/tests/tests.cmake: -------------------------------------------------------------------------------- 1 | include_directories(./tests/googletest/googletest/include) 2 | 3 | set(ggtest_DIR "${CMAKE_SOURCE_DIR}/tests/googletest") 4 | add_subdirectory(${ggtest_DIR}) 5 | 6 | file(GLOB TSOURCES "tests/*.cc" ) 7 | add_executable(coretest ${TSOURCES} ) 8 | 9 | target_link_libraries(coretest gtest gtest_main ibverbs) 10 | --------------------------------------------------------------------------------