Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SPU: minor logging #7792

Merged
merged 3 commits into from Mar 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 13 additions & 13 deletions Utilities/File.h
Expand Up @@ -290,16 +290,16 @@ namespace fs
}

// Write POD unconditionally
template<typename T>
std::enable_if_t<std::is_pod<T>::value && !std::is_pointer<T>::value, const file&> write(const T& data) const
template <typename T>
std::enable_if_t<std::is_trivially_copyable_v<T> && !std::is_pointer_v<T>, const file&> write(const T& data) const
{
if (write(std::addressof(data), sizeof(T)) != sizeof(T)) xfail();
return *this;
}

// Write POD std::vector unconditionally
template<typename T>
std::enable_if_t<std::is_pod<T>::value && !std::is_pointer<T>::value, const file&> write(const std::vector<T>& vec) const
template <typename T>
std::enable_if_t<std::is_trivially_copyable_v<T> && !std::is_pointer_v<T>, const file&> write(const std::vector<T>& vec) const
{
if (write(vec.data(), vec.size() * sizeof(T)) != vec.size() * sizeof(T)) xfail();
return *this;
Expand All @@ -319,30 +319,30 @@ namespace fs
}

// Read POD, sizeof(T) is used
template<typename T>
std::enable_if_t<std::is_pod<T>::value && !std::is_pointer<T>::value, bool> read(T& data) const
template <typename T>
std::enable_if_t<std::is_trivially_copyable_v<T> && !std::is_pointer_v<T>, bool> read(T& data) const
{
return read(&data, sizeof(T)) == sizeof(T);
}

// Read POD std::vector, size must be set by resize() method
template<typename T>
std::enable_if_t<std::is_pod<T>::value && !std::is_pointer<T>::value, bool> read(std::vector<T>& vec) const
template <typename T>
std::enable_if_t<std::is_trivially_copyable_v<T> && !std::is_pointer_v<T>, bool> read(std::vector<T>& vec) const
{
return read(vec.data(), sizeof(T) * vec.size()) == sizeof(T) * vec.size();
}

// Read POD std::vector
template<typename T>
std::enable_if_t<std::is_pod<T>::value && !std::is_pointer<T>::value, bool> read(std::vector<T>& vec, std::size_t size) const
template <typename T>
std::enable_if_t<std::is_trivially_copyable_v<T> && !std::is_pointer_v<T>, bool> read(std::vector<T>& vec, std::size_t size) const
{
vec.resize(size);
return read(vec.data(), sizeof(T) * size) == sizeof(T) * size;
}

// Read POD (experimental)
template<typename T>
std::enable_if_t<std::is_pod<T>::value && !std::is_pointer<T>::value, T> read() const
template <typename T>
std::enable_if_t<std::is_trivially_copyable_v<T> && !std::is_pointer_v<T>, T> read() const
{
T result;
if (!read(result)) xfail();
Expand All @@ -360,7 +360,7 @@ namespace fs

// Read full file to std::vector
template<typename T>
std::enable_if_t<std::is_pod<T>::value && !std::is_pointer<T>::value, std::vector<T>> to_vector() const
std::enable_if_t<std::is_trivially_copyable_v<T> && !std::is_pointer_v<T>, std::vector<T>> to_vector() const
{
std::vector<T> result;
result.resize(size() / sizeof(T));
Expand Down
10 changes: 5 additions & 5 deletions Utilities/types.h
Expand Up @@ -822,19 +822,19 @@ struct alignas(A) any_pod

any_pod() = default;

template <typename T, typename T2 = TT<T>, typename = std::enable_if_t<std::is_pod<T2>::value && sizeof(T2) == S && alignof(T2) <= A>>
template <typename T, typename T2 = TT<T>, typename = std::enable_if_t<std::is_trivially_copyable_v<T> && sizeof(T2) == S && alignof(T2) <= A>>
any_pod(const T& value)
{
reinterpret_cast<T2&>(data) = value;
*this = std::bit_cast<any_pod>(value);
}

template <typename T, typename T2 = TT<T>, typename = std::enable_if_t<std::is_pod<T2>::value && sizeof(T2) == S && alignof(T2) <= A>>
template <typename T, typename T2 = TT<T>, typename = std::enable_if_t<std::is_trivially_copyable_v<T> && sizeof(T2) == S && alignof(T2) <= A>>
T2& as()
{
return reinterpret_cast<T2&>(data);
}

template <typename T, typename T2 = TT<T>, typename = std::enable_if_t<std::is_pod<T2>::value && sizeof(T2) == S && alignof(T2) <= A>>
template <typename T, typename T2 = TT<T>, typename = std::enable_if_t<std::is_trivially_copyable_v<T> && sizeof(T2) == S && alignof(T2) <= A>>
const T2& as() const
{
return reinterpret_cast<const T2&>(data);
Expand Down Expand Up @@ -899,7 +899,7 @@ struct cmd64 : any64
}
};

static_assert(sizeof(cmd64) == 8 && std::is_pod<cmd64>::value, "Incorrect cmd64 type");
static_assert(sizeof(cmd64) == 8 && std::is_trivially_copyable_v<cmd64>, "Incorrect cmd64 type");

// Error code type (return type), implements error reporting. Could be a template.
struct error_code
Expand Down
9 changes: 3 additions & 6 deletions rpcs3/Emu/CPU/CPUThread.cpp
Expand Up @@ -84,12 +84,11 @@ struct cpu_prof
void print(u32 id) const
{
// Make reversed map: sample_count -> name
std::multimap<u64, u64> chart;
std::multimap<u64, u64, std::greater<u64>> chart;

for (auto& [name, count] : freq)
{
// Inverse bits to sort in descending order
chart.emplace(~count, name);
chart.emplace(count, name);
}

// Print results
Expand All @@ -99,10 +98,8 @@ struct cpu_prof
// Fraction of non-idle samples
const f64 busy = 1. * (samples - idle) / samples;

for (auto& [rcount, name] : chart)
for (auto& [count, name] : chart)
{
// Get correct count value
const u64 count = ~rcount;
const f64 _frac = count / busy / samples;

// Print only 7 hash characters out of 11 (which covers roughly 48 bits)
Expand Down
15 changes: 15 additions & 0 deletions rpcs3/Emu/Cell/SPUThread.cpp
Expand Up @@ -1014,6 +1014,21 @@ std::string spu_thread::dump() const
std::string ret = cpu_thread::dump();

fmt::append(ret, "\nBlock Weight: %u (Retreats: %u)", block_counter, block_failure);

if (g_cfg.core.spu_prof)
{
// Get short function hash
const u64 name = atomic_storage<u64>::load(block_hash);

fmt::append(ret, "\nCurrent block: %s", fmt::base57(be_t<u64>{name}));

// Print only 7 hash characters out of 11 (which covers roughly 48 bits)
ret.resize(ret.size() - 4);

// Print chunk address from lowest 16 bits
fmt::append(ret, "...chunk-0x%05x", (name & 0xffff) * 4);
}

fmt::append(ret, "\n[%s]", ch_mfc_cmd);
fmt::append(ret, "\nLocal Storage: 0x%08x..0x%08x", offset, offset + 0x3ffff);
fmt::append(ret, "\nTag Mask: 0x%08x", ch_tag_mask);
Expand Down