Skip to content
This repository has been archived by the owner on Oct 28, 2021. It is now read-only.

SIMD #4201

Closed
wants to merge 51 commits into from
Closed

SIMD #4201

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
d239486
Fix STATICCALL giving stipend
chfast Jun 23, 2017
6702b18
redesignd stack use to minimize impact of simd on remainer of code, i…
gcolvin Jun 26, 2017
f372161
fuzzHelper wants 615 opcodes
gcolvin Jun 26, 2017
18bc1c8
Update fuzzHelper.cpp
gcolvin Jun 26, 2017
cbe4b17
Fix STATICCALL forwarding call value
chfast Jun 26, 2017
5bca159
update tests
winsvega Jun 23, 2017
f17ed62
snark: Add ECADD and ECMUL benchmark tests
chfast Jun 20, 2017
8a68de6
Fix clang build issue
chfast Jun 26, 2017
e232db4
Update tests to include two new tests about staticcall not inheriting…
pirapira Jun 26, 2017
631c875
Merge branch 'develop' into fix-staticcall
pirapira Jun 26, 2017
e2c2a0a
Merge pull request #4178 from ethereum/snark-benchmarks
pirapira Jun 26, 2017
53be05a
Update tests
pirapira Jun 26, 2017
1809582
Update tests
pirapira Jun 27, 2017
5ad949e
Merge pull request #4200 from ethereum/fix-staticcall
winsvega Jun 27, 2017
7d0fae1
redesignd stack use to minimize impact of simd on remainer of code, i…
gcolvin Jun 26, 2017
cdf9b02
fuzzHelper wants 615 opcodes
gcolvin Jun 26, 2017
65cf38b
Andrei's suggestions
gcolvin Jun 28, 2017
30b996c
conflicts
gcolvin Jun 28, 2017
a4fcfc9
commit now or comments later
gcolvin Jun 28, 2017
b4bacee
more of Andrei's suggestions, more cleanup, get it all compiling again
gcolvin Jun 30, 2017
05a1e2e
redesignd stack use to minimize impact of simd on remainer of code, i…
gcolvin Jun 26, 2017
59250cc
fuzzHelper wants 615 opcodes
gcolvin Jun 26, 2017
77769e8
more of Andrei's suggestions, more cleanup, get it all compiling again
gcolvin Jun 30, 2017
7d2c989
get instruction configuration cleaned up and working on windows, othe…
gcolvin Jul 3, 2017
7136b98
conflicts
gcolvin Jul 3, 2017
d7cc1e9
conflicts still
gcolvin Jul 4, 2017
0e0d45d
construct in place rather than assign where destination is trash, oth…
gcolvin Jul 5, 2017
bbfeb5d
Check names of GeneralStateTest test fillers against filenames
pirapira Jun 30, 2017
45dbc24
EVMJIT: STATICCALL
chfast Jun 23, 2017
b242a2c
Fix Boost build on Gentoo
chfast Jul 3, 2017
d2201dd
travis_wait 80
winsvega Jul 3, 2017
4405261
travis_wait on `brew install llvm`, which takes more than 10 minutes
pirapira Jul 4, 2017
a860a9d
eth: Drop old interactive mode
chfast Jul 4, 2017
25e009e
logs: Simplify log output handling
chfast Jul 4, 2017
e17b1a5
common: Remove SpinLock class
chfast Jul 4, 2017
d14407e
eth: Remove obsolete command line options
chfast Jul 4, 2017
efb99c0
trace to logChannel in State and DB
winsvega Jun 27, 2017
4011184
general blockchain tests
winsvega Jun 27, 2017
0f3f057
bcExample
winsvega Jun 28, 2017
939832c
more debuginfo
winsvega Jun 30, 2017
4bfa739
bcForgedTest
winsvega Jun 30, 2017
47afcf2
fix style
winsvega Jul 2, 2017
883c8b4
fix GasPricer tests
winsvega Jul 3, 2017
bf1d1dd
limit mining threads to 1 for testeth
winsvega Jul 4, 2017
63fe8ba
fix style issues
winsvega Jul 4, 2017
7f78291
correct --fillchain option for new blockchain fillers
winsvega Jul 4, 2017
c9b3bfe
fixes and style update
winsvega Jul 5, 2017
e803179
change throw 1; to exit(1)
winsvega Jul 5, 2017
9e487a6
still trying to force github to accept push
gcolvin Jul 5, 2017
67ab2a7
yes, still trying to force github to accept push
gcolvin Jul 5, 2017
d2c2e80
why am I still messing with this branch?
gcolvin Jul 6, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,12 @@ cache:
# build external dependencies next build.
- $TRAVIS_BUILD_DIR/deps
install:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then clang --version; brew install llvm; $(brew --prefix llvm)/bin/clang --version; export PATH=$(brew --prefix llvm)/bin:$PATH; export CC=$(brew --prefix llvm)/bin/clang; export CXX=$(brew --prefix llvm)/bin/clang++; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then clang --version; travis_wait 80 brew install llvm; $(brew --prefix llvm)/bin/clang --version; export PATH=$(brew --prefix llvm)/bin:$PATH; export CC=$(brew --prefix llvm)/bin/clang; export CXX=$(brew --prefix llvm)/bin/clang++; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ./scripts/install_cmake.sh; fi
- ./scripts/install_deps.sh
before_script:
- ./scripts/prepare_ccache.sh
- ./scripts/build.sh $TRAVIS_BUILD_TYPE
- travis_wait 80 ./scripts/build.sh $TRAVIS_BUILD_TYPE
- ./scripts/cleanup_ccache.sh
script:
- cd $TRAVIS_BUILD_DIR/build && ../scripts/tests.sh $TRAVIS_TESTS
Expand Down
5 changes: 4 additions & 1 deletion cmake/ProjectBoost.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ ExternalProject_Add(boost
BUILD_IN_SOURCE 1
CONFIGURE_COMMAND ${BOOST_BOOTSTRAP_COMMAND}
LOG_CONFIGURE 1
BUILD_COMMAND ${BOOST_BUILD_TOOL} stage
BUILD_COMMAND
${BOOST_BUILD_TOOL}
--ignore-site-config
stage
${BOOST_CXXFLAGS}
threading=multi
link=static
Expand Down
93 changes: 0 additions & 93 deletions eth/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,6 @@ int main(int argc, char** argv)

/// General params for Node operation
NodeMode nodeMode = NodeMode::Full;
bool interactive = false;

int jsonRPCURL = -1;
bool adminViaHttp = false;
Expand Down Expand Up @@ -616,56 +615,6 @@ int main(int argc, char** argv)
chainParams = ChainParams(genesisInfo(eth::Network::MainNetwork), genesisStateRoot(eth::Network::MainNetwork));
else if (arg == "--ropsten" || arg == "--testnet")
chainParams = ChainParams(genesisInfo(eth::Network::Ropsten), genesisStateRoot(eth::Network::Ropsten));
else if (arg == "--oppose-dao-fork")
{
chainParams = ChainParams(genesisInfo(eth::Network::MainNetwork), genesisStateRoot(eth::Network::MainNetwork));
chainParams.otherParams["daoHardforkBlock"] = toHex(u256(-1) - 10, HexPrefix::Add);
}
else if (arg == "--support-dao-fork")
{
// default
}
else if (arg == "--bob")
{
cout << "Asking Bob for blocks (this should work in theoreum)..." << endl;
while (true)
{
u256 x(h256::random());
u256 c;
for (; x != 1; ++c)
{
x = (x & 1) == 0 ? x / 2 : 3 * x + 1;
cout << toHex(x) << endl;
this_thread::sleep_for(chrono::seconds(1));
}
cout << "Block number: " << hex << c << endl;
exit(0);
}
}
/* else if ((arg == "-B" || arg == "--block-fees") && i + 1 < argc)
{
try
{
blockFees = stof(argv[++i]);
}
catch (...)
{
cerr << "Bad " << arg << " option: " << argv[i] << endl;
return -1;
}
}
else if ((arg == "-e" || arg == "--ether-price") && i + 1 < argc)
{
try
{
etherPrice = stof(argv[++i]);
}
catch (...)
{
cerr << "Bad " << arg << " option: " << argv[i] << endl;
return -1;
}
}*/
else if (arg == "--ask" && i + 1 < argc)
{
try
Expand All @@ -690,28 +639,6 @@ int main(int argc, char** argv)
return -1;
}
}
/* else if ((arg == "-P" || arg == "--priority") && i + 1 < argc)
{
string m = boost::to_lower_copy(string(argv[++i]));
if (m == "lowest")
priority = TransactionPriority::Lowest;
else if (m == "low")
priority = TransactionPriority::Low;
else if (m == "medium" || m == "mid" || m == "default" || m == "normal")
priority = TransactionPriority::Medium;
else if (m == "high")
priority = TransactionPriority::High;
else if (m == "highest")
priority = TransactionPriority::Highest;
else
try {
priority = (TransactionPriority)(max(0, min(100, stoi(m))) * 8 / 100);
}
catch (...) {
cerr << "Unknown " << arg << " option: " << m << endl;
return -1;
}
}*/
else if ((arg == "-m" || arg == "--mining") && i + 1 < argc)
{
string m = argv[++i];
Expand Down Expand Up @@ -747,8 +674,6 @@ int main(int argc, char** argv)
alwaysConfirm = false;
else if (arg == "--import-presale" && i + 1 < argc)
presaleImports.push_back(argv[++i]);
else if (arg == "--old-interactive")
interactive = true;

else if ((arg == "-j" || arg == "--json-rpc"))
jsonRPCURL = jsonRPCURL == -1 ? SensibleHttpPort : jsonRPCURL;
Expand Down Expand Up @@ -954,24 +879,6 @@ int main(int argc, char** argv)

string logbuf;
std::string additional;
if (interactive)
g_logPost = [&](std::string const& a, char const*){
static SpinLock s_lock;
SpinGuard l(s_lock);

if (g_silence)
logbuf += a + "\n";
else
cout << "\r \r" << a << endl << additional << flush;

// helpful to use OutputDebugString on windows
#if defined(_WIN32)
{
OutputDebugStringA(a.data());
OutputDebugStringA("\n");
}
#endif
};

auto getPassword = [&](string const& prompt) {
bool s = g_silence;
Expand Down
12 changes: 0 additions & 12 deletions libdevcore/Guards.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,6 @@ struct GenericUnguardSharedBool
MutexType& m;
};

/** @brief Simple lock that waits for release without making context switch */
class SpinLock
{
public:
SpinLock() { m_lock.clear(); }
void lock() { while (m_lock.test_and_set(std::memory_order_acquire)) {} }
void unlock() { m_lock.clear(std::memory_order_release); }
private:
std::atomic_flag m_lock;
};
using SpinGuard = std::lock_guard<SpinLock>;

template <class N>
class Notified
{
Expand Down
22 changes: 2 additions & 20 deletions libdevcore/Log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,6 @@ string dev::ThreadContext::join(string const& _prior)
return g_logThreadContext.join(_prior);
}

// foward declare without all of Windows.h
#if defined(_WIN32)
extern "C" __declspec(dllimport) void __stdcall OutputDebugStringA(const char* lpOutputString);
#endif

string dev::getThreadName()
{
#if defined(__GLIBC__) || defined(__APPLE__)
Expand All @@ -190,20 +185,7 @@ void dev::setThreadName(string const& _n)
#endif
}

void dev::simpleDebugOut(std::string const& _s, char const*)
void dev::debugOut(std::string const& _s)
{
static SpinLock s_lock;
SpinGuard l(s_lock);

cerr << _s << endl << flush;

// helpful to use OutputDebugString on windows
#if defined(_WIN32)
{
OutputDebugStringA(_s.data());
OutputDebugStringA("\n");
}
#endif
cerr << _s << '\n';
}

std::function<void(std::string const&, char const*)> dev::g_logPost = simpleDebugOut;
9 changes: 3 additions & 6 deletions libdevcore/Log.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,11 @@ class NullOutputStream
};

/// A simple log-output function that prints log messages to stdout.
void simpleDebugOut(std::string const&, char const*);
void debugOut(std::string const& _s);

/// The logging system's current verbosity.
extern int g_logVerbosity;

/// The current method that the logging system uses to output the log messages. Defaults to simpleDebugOut().
extern std::function<void(std::string const&, char const*)> g_logPost;

class LogOverrideAux
{
protected:
Expand Down Expand Up @@ -264,8 +261,8 @@ class LogOutputStream: LogOutputStreamBase
/// If _term is true the the prefix info is terminated with a ']' character; if not it ends only with a '|' character.
LogOutputStream(): LogOutputStreamBase(Id::name(), &typeid(Id), Id::verbosity, _AutoSpacing) {}

/// Destructor. Posts the accrued log entry to the g_logPost function.
~LogOutputStream() { if (Id::verbosity <= g_logVerbosity) g_logPost(m_sstr.str(), Id::name()); }
/// Destructor. Posts the accrued log entry to the output stream.
~LogOutputStream() { if (Id::verbosity <= g_logVerbosity) debugOut(m_sstr.str()); }

LogOutputStream& operator<<(std::string const& _t) { if (Id::verbosity <= g_logVerbosity) { if (_AutoSpacing && m_sstr.str().size() && m_sstr.str().back() != ' ') m_sstr << " "; comment(_t); } return *this; }

Expand Down
2 changes: 1 addition & 1 deletion libdevcore/OverlayDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ h256 const EmptyTrie = sha3(rlp(""));
OverlayDB::~OverlayDB()
{
if (m_db.use_count() == 1 && m_db.get())
ctrace << "Closing state DB";
clog(DBDetail) << "Closing state DB";
}

class WriteBatchNoter: public ldb::WriteBatch::Handler
Expand Down
2 changes: 2 additions & 0 deletions libdevcore/OverlayDB.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
namespace dev
{

struct DBDetail: public LogChannel { static const char* name() { return "DBDetail"; } static const int verbosity = 14; };

class OverlayDB: public MemoryDB
{
public:
Expand Down
2 changes: 1 addition & 1 deletion libethashseal/Ethash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ void Ethash::verifyTransaction(ImportRequirements::value _ir, TransactionBase co
_t.checkChainId(-4);
}
if (_ir & ImportRequirements::TransactionBasic && _t.baseGasRequired(evmSchedule(_header.number())) > _t.gas())
BOOST_THROW_EXCEPTION(OutOfGasIntrinsic());
BOOST_THROW_EXCEPTION(OutOfGasIntrinsic() << RequirementError((bigint)(_t.baseGasRequired(evmSchedule(_header.number()))), (bigint)_t.gas()));

// Avoid transactions that would take us beyond the block gas limit.
if (_startGasUsed + (bigint)_t.gas() > _header.gasLimit())
Expand Down
1 change: 1 addition & 0 deletions libethereum/Block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ pair<TransactionReceipts, bool> Block::sync(BlockChain const& _bc, TransactionQu
if (got > m_currentBlock.gasLimit())
{
clog(StateTrace) << t.sha3() << "Dropping over-gassy transaction (gas > block's gas limit)";
clog(StateTrace) << "got: " << got << " required: " << m_currentBlock.gasLimit();
_tq.drop(t.sha3());
}
else
Expand Down
4 changes: 2 additions & 2 deletions libethereum/Executive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ void Executive::initialize(Transaction const& _transaction)
}
if (m_t.nonce() != nonceReq)
{
clog(ExecutiveWarnChannel) << "Invalid Nonce: Require" << nonceReq << " Got" << m_t.nonce();
clog(ExecutiveWarnChannel) << "Sender: " << m_t.sender().hex() << " Invalid Nonce: Require" << nonceReq << " Got" << m_t.nonce();
m_excepted = TransactionException::InvalidNonce;
BOOST_THROW_EXCEPTION(InvalidNonce() << RequirementError((bigint)nonceReq, (bigint)m_t.nonce()));
}
Expand All @@ -218,7 +218,7 @@ void Executive::initialize(Transaction const& _transaction)
{
clog(ExecutiveWarnChannel) << "Not enough cash: Require >" << totalCost << "=" << m_t.gas() << "*" << m_t.gasPrice() << "+" << m_t.value() << " Got" << m_s.balance(m_t.sender()) << "for sender: " << m_t.sender();
m_excepted = TransactionException::NotEnoughCash;
BOOST_THROW_EXCEPTION(NotEnoughCash() << RequirementError(totalCost, (bigint)m_s.balance(m_t.sender())) << errinfo_comment(m_t.sender().abridged()));
BOOST_THROW_EXCEPTION(NotEnoughCash() << RequirementError(totalCost, (bigint)m_s.balance(m_t.sender())) << errinfo_comment(m_t.sender().hex()));
}
m_gasCost = (u256)gasCost; // Convert back to 256-bit, safe now.
}
Expand Down
4 changes: 2 additions & 2 deletions libethereum/State.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ OverlayDB State::openDB(std::string const& _basePath, h256 const& _genesisHash,

if (_we == WithExisting::Kill)
{
cnote << "Killing state database (WithExisting::Kill).";
clog(StateDetail) << "Killing state database (WithExisting::Kill).";
boost::filesystem::remove_all(path + "/state");
}

Expand Down Expand Up @@ -119,7 +119,7 @@ OverlayDB State::openDB(std::string const& _basePath, h256 const& _genesisHash,
}
}

ctrace << "Opened state DB.";
clog(StateDetail) << "Opened state DB.";
return OverlayDB(db);
}

Expand Down
1 change: 1 addition & 0 deletions libevm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ set(SOURCES
VM.cpp
VMOpt.cpp
VMCalls.cpp
VMSIMD.cpp
VMValidate.cpp
VMFactory.cpp
)
Expand Down
20 changes: 11 additions & 9 deletions libevm/JitVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ void call(evm_result* o_result, evm_env* _opaqueEnv, evm_message const* _msg) no
params.codeAddress = fromEvmC(_msg->address);
params.receiveAddress = _msg->kind == EVM_CALL ? params.codeAddress : env.myAddress;
params.data = {_msg->input, _msg->input_size};
params.staticCall = (_msg->flags & EVM_STATIC) != 0;
params.onOp = {};

bool success = false;
Expand Down Expand Up @@ -315,24 +316,25 @@ class EVM
{
auto env = reinterpret_cast<evm_env*>(&_ext);
auto mode = JitVM::scheduleToMode(_ext.evmSchedule());
uint32_t flags = _ext.staticCall ? EVM_STATIC : 0;
evm_message msg = {toEvmC(_ext.myAddress), toEvmC(_ext.caller),
toEvmC(_ext.value), _ext.data.data(),
_ext.data.size(), toEvmC(_ext.codeHash), gas,
static_cast<int32_t>(_ext.depth), EVM_CALL};
static_cast<int32_t>(_ext.depth), EVM_CALL, flags};
return Result{m_instance->execute(
m_instance, env, mode, &msg, _ext.code.data(), _ext.code.size()
)};
}

bool isCodeReady(evm_mode _mode, h256 _codeHash)
bool isCodeReady(evm_mode _mode, uint32_t _flags, h256 _codeHash)
{
return m_instance->get_code_status(m_instance, _mode, toEvmC(_codeHash)) == EVM_READY;
return m_instance->get_code_status(m_instance, _mode, _flags, toEvmC(_codeHash)) == EVM_READY;
}

void compile(evm_mode _mode, bytesConstRef _code, h256 _codeHash)
void compile(evm_mode _mode, uint32_t _flags, bytesConstRef _code, h256 _codeHash)
{
m_instance->prepare_code(
m_instance, _mode, toEvmC(_codeHash), _code.data(), _code.size()
m_instance, _mode, _flags, toEvmC(_codeHash), _code.data(), _code.size()
);
}

Expand Down Expand Up @@ -392,14 +394,14 @@ evm_mode JitVM::scheduleToMode(EVMSchedule const& _schedule)
return _schedule.haveDelegateCall ? EVM_HOMESTEAD : EVM_FRONTIER;
}

bool JitVM::isCodeReady(evm_mode _mode, h256 _codeHash)
bool JitVM::isCodeReady(evm_mode _mode, uint32_t _flags, h256 _codeHash)
{
return getJit().isCodeReady(_mode, _codeHash);
return getJit().isCodeReady(_mode, _flags, _codeHash);
}

void JitVM::compile(evm_mode _mode, bytesConstRef _code, h256 _codeHash)
void JitVM::compile(evm_mode _mode, uint32_t _flags, bytesConstRef _code, h256 _codeHash)
{
getJit().compile(_mode, _code, _codeHash);
getJit().compile(_mode, _flags, _code, _codeHash);
}

}
Expand Down
4 changes: 2 additions & 2 deletions libevm/JitVM.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ class JitVM: public VMFace
owning_bytes_ref exec(u256& io_gas, ExtVMFace& _ext, OnOpFunc const& _onOp) override final;

static evm_mode scheduleToMode(EVMSchedule const& _schedule);
static bool isCodeReady(evm_mode _mode, h256 _codeHash);
static void compile(evm_mode _mode, bytesConstRef _code, h256 _codeHash);
static bool isCodeReady(evm_mode _mode, uint32_t _flags, h256 _codeHash);
static void compile(evm_mode _mode, uint32_t _flags, bytesConstRef _code, h256 _codeHash);
};


Expand Down
Loading