Browse Source

Merge pull request #2097 from riscv-software-src/fix-werror

Actually use -Werror in CI again
pull/2095/head
Andrew Waterman 10 months ago
committed by GitHub
parent
commit
38eec3f323
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 4
      ci-tests/build-spike
  2. 17
      riscv/bulknormdot.h
  3. 2
      riscv/csrs.cc
  4. 20
      riscv/interactive.cc

4
ci-tests/build-spike

@ -8,7 +8,9 @@ rm -rf build
mkdir build mkdir build
cd build cd build
mkdir install mkdir install
CXXFLAGS="-Wnon-virtual-dtor" CFLAGS="-Werror -Wall -Wextra -Wvla" $DIR/../configure --prefix=`pwd`/install CFLAGS="-Werror -Wall -Wextra -Wvla"
CXXFLAGS="-Wnon-virtual-dtor $CFLAGS"
CXXFLAGS="$CXXFLAGS" CFLAGS="$CFLAGS" $DIR/../configure --prefix=`pwd`/install
make -j"$(nproc 2> /dev/null || sysctl -n hw.ncpu)" make -j"$(nproc 2> /dev/null || sysctl -n hw.ncpu)"
make check make check
make install install-hdrs-list.h make install install-hdrs-list.h

17
riscv/bulknormdot.h

@ -2,7 +2,7 @@
#define _RISCV_BULKNORMDOT_H #define _RISCV_BULKNORMDOT_H
#include <cstdint> #include <cstdint>
#include <iostream> #include <vector>
#include "softfloat.h" #include "softfloat.h"
struct bulk_norm_out_t { struct bulk_norm_out_t {
@ -56,6 +56,9 @@ template <typename U, typename M, typename E> class FloatFormat {
virtual bool nan() const = 0; virtual bool nan() const = 0;
virtual bool sigNan() const = 0; virtual bool sigNan() const = 0;
virtual bool special() const = 0; virtual bool special() const = 0;
public:
virtual ~FloatFormat() = default;
}; };
/** Template for an IEEE-754 floating-point format class */ /** Template for an IEEE-754 floating-point format class */
@ -178,8 +181,8 @@ class ofp8_e4m3 final : public IEEEFloatFormat<uint8_t, uint8_t, uint8_t, 4, 3>
*/ */
template<typename ValueTypeLHS, typename ValueTypeRHS, typename SigProdType> bulk_norm_out_t bulk_norm_dot_no_mult(const DotConfig cfg, const ValueTypeLHS* a, const ValueTypeRHS* b, const SigProdType* prod_sigs) template<typename ValueTypeLHS, typename ValueTypeRHS, typename SigProdType> bulk_norm_out_t bulk_norm_dot_no_mult(const DotConfig cfg, const ValueTypeLHS* a, const ValueTypeRHS* b, const SigProdType* prod_sigs)
{ {
int approx_prod_exp[cfg.n]; std::vector<int> approx_prod_exp(cfg.n);
int flushed_prods[cfg.n]; std::vector<int> flushed_prods(cfg.n);
bool any_pos_inf = false; bool any_pos_inf = false;
bool any_neg_inf = false; bool any_neg_inf = false;
@ -299,27 +302,27 @@ template<typename ValueTypeLHS, typename ValueTypeRHS, typename SigProdType> bul
static inline bulk_norm_out_t bulk_norm_dot_bf16(const DotConfig cfg, const bf16_t* a, const bf16_t* b) static inline bulk_norm_out_t bulk_norm_dot_bf16(const DotConfig cfg, const bf16_t* a, const bf16_t* b)
{ {
// product are extracted so that the no-mult version can be more easily matched against the RTL implementation // product are extracted so that the no-mult version can be more easily matched against the RTL implementation
uint16_t prod_sigs[cfg.n]; std::vector<uint16_t> prod_sigs(cfg.n);
// compute products, normalize to largest exponent, accumulate // compute products, normalize to largest exponent, accumulate
for (int i = 0; i < cfg.n; i++) { for (int i = 0; i < cfg.n; i++) {
prod_sigs[i] = a[i].sig() * (uint16_t) b[i].sig(); prod_sigs[i] = a[i].sig() * (uint16_t) b[i].sig();
} }
return bulk_norm_dot_no_mult<bf16_t, bf16_t, uint16_t>(cfg, a, b, prod_sigs); return bulk_norm_dot_no_mult<bf16_t, bf16_t, uint16_t>(cfg, a, b, &prod_sigs[0]);
} }
template <typename L, typename R> template <typename L, typename R>
bulk_norm_out_t bulk_norm_dot_ofp8(const DotConfig cfg, const L* a, const R* b) bulk_norm_out_t bulk_norm_dot_ofp8(const DotConfig cfg, const L* a, const R* b)
{ {
// products are extracted so that the no-mult version can be more easily matched against the RTL implementation // products are extracted so that the no-mult version can be more easily matched against the RTL implementation
uint16_t prod_sigs[cfg.n]; std::vector<uint16_t> prod_sigs(cfg.n);
// compute products, normalize to largest exponent, accumulate // compute products, normalize to largest exponent, accumulate
for (int i = 0; i < cfg.n; i++) { for (int i = 0; i < cfg.n; i++) {
prod_sigs[i] = a[i].sig() * (uint16_t) b[i].sig(); prod_sigs[i] = a[i].sig() * (uint16_t) b[i].sig();
} }
return bulk_norm_dot_no_mult<L, R, uint16_t>(cfg, a, b, prod_sigs); return bulk_norm_dot_no_mult<L, R, uint16_t>(cfg, a, b, &prod_sigs[0]);
} }
#endif #endif

2
riscv/csrs.cc

@ -2141,7 +2141,7 @@ inaccessible_csr_t::inaccessible_csr_t(processor_t* const proc, const reg_t addr
csr_t(proc, addr) { csr_t(proc, addr) {
} }
void inaccessible_csr_t::verify_permissions(insn_t insn, bool write) const { void inaccessible_csr_t::verify_permissions(insn_t insn, bool UNUSED write) const {
if (state->v) if (state->v)
throw trap_virtual_instruction(insn.bits()); throw trap_virtual_instruction(insn.bits());
else else

20
riscv/interactive.cc

@ -72,6 +72,12 @@ processor_t *sim_t::get_core(const std::string& i)
return get_core(p); return get_core(p);
} }
static void do_write(int fd, const void* buf, size_t n)
{
auto res = write(fd, buf, n);
(void) res;
}
static void clear_str(bool noncanonical, int fd, std::string target_str) static void clear_str(bool noncanonical, int fd, std::string target_str)
{ {
if (noncanonical) if (noncanonical)
@ -83,7 +89,7 @@ static void clear_str(bool noncanonical, int fd, std::string target_str)
clear_motion += ' '; clear_motion += ' ';
} }
clear_motion += '\r'; clear_motion += '\r';
(void) write(fd, clear_motion.c_str(), clear_motion.size() + 1); do_write(fd, clear_motion.c_str(), clear_motion.size() + 1);
} }
} }
@ -96,7 +102,7 @@ static void send_key(bool noncanonical, int fd, keybuffer_t key_code, const int
{ {
key_motion += (char) ((key_code >> (i * BITS_PER_CHAR)) & 0xff); key_motion += (char) ((key_code >> (i * BITS_PER_CHAR)) & 0xff);
} }
(void) write(fd, key_motion.c_str(), len); do_write(fd, key_motion.c_str(), len);
} }
} }
@ -144,7 +150,7 @@ static std::string readline(int fd)
cursor_pos--; cursor_pos--;
s.erase(cursor_pos, 1); s.erase(cursor_pos, 1);
if (noncanonical) if (noncanonical)
(void) write(fd, s.c_str(), s.size() + 1); do_write(fd, s.c_str(), s.size() + 1);
// move cursor by left arrow key // move cursor by left arrow key
for (unsigned i = 0; i < s.size() - cursor_pos; i++) { for (unsigned i = 0; i < s.size() - cursor_pos; i++) {
send_key(noncanonical, fd, KEYCODE_LEFT, 3); send_key(noncanonical, fd, KEYCODE_LEFT, 3);
@ -176,7 +182,7 @@ static std::string readline(int fd)
history_index = std::min(history_commands.size(), history_index + 1); history_index = std::min(history_commands.size(), history_index + 1);
s = history_commands[history_commands.size() - history_index]; s = history_commands[history_commands.size() - history_index];
if (noncanonical) if (noncanonical)
(void) write(fd, s.c_str(), s.size() + 1); do_write(fd, s.c_str(), s.size() + 1);
cursor_pos = s.size(); cursor_pos = s.size();
} }
key_buffer = 0; key_buffer = 0;
@ -192,7 +198,7 @@ static std::string readline(int fd)
s = history_commands[history_commands.size() - history_index]; s = history_commands[history_commands.size() - history_index];
} }
if (noncanonical) if (noncanonical)
(void) write(fd, s.c_str(), s.size() + 1); do_write(fd, s.c_str(), s.size() + 1);
cursor_pos = s.size(); cursor_pos = s.size();
} }
key_buffer = 0; key_buffer = 0;
@ -221,7 +227,7 @@ static std::string readline(int fd)
break; break;
case KEYCODE_ENTER: case KEYCODE_ENTER:
if (noncanonical) if (noncanonical)
(void) write(fd, &ch, 1); do_write(fd, &ch, 1);
if (s.size() > initial_s_len && (history_commands.size() == 0 || s != history_commands[history_commands.size() - 1])) { if (s.size() > initial_s_len && (history_commands.size() == 0 || s != history_commands[history_commands.size() - 1])) {
history_commands.push_back(s); history_commands.push_back(s);
} }
@ -236,7 +242,7 @@ static std::string readline(int fd)
s.insert(cursor_pos, 1, ch); s.insert(cursor_pos, 1, ch);
cursor_pos++; cursor_pos++;
if (noncanonical) if (noncanonical)
(void) write(fd, s.c_str(), s.size() + 1); do_write(fd, s.c_str(), s.size() + 1);
// send left arrow key to move cursor // send left arrow key to move cursor
for (unsigned i = 0; i < s.size() - cursor_pos; i++) { for (unsigned i = 0; i < s.size() - cursor_pos; i++) {
send_key(noncanonical, fd, KEYCODE_LEFT, 3); send_key(noncanonical, fd, KEYCODE_LEFT, 3);

Loading…
Cancel
Save