uuid_gen cleanup

This commit is contained in:
Blaise Tine 2024-06-08 01:57:38 -07:00
parent fa5590bbf7
commit 99eaaf6189
8 changed files with 14 additions and 79 deletions

View file

@ -21,8 +21,6 @@
#include "svdpi.h"
#include "verilated_vpi.h"
#include "uuid_gen.h"
#ifdef XLEN_64
#define iword_t int64_t
#define uword_t uint64_t
@ -50,7 +48,7 @@ extern "C" {
void dpi_trace_start();
void dpi_trace_stop();
uint64_t dpi_uuid_gen(bool reset, int wid, uint64_t PC);
uint64_t dpi_uuid_gen(bool reset, int wid);
}
bool sim_trace_enabled();
@ -209,22 +207,14 @@ void dpi_trace_stop() {
///////////////////////////////////////////////////////////////////////////////
std::unordered_map<uint32_t, std::shared_ptr<vortex::UUIDGenerator>> g_uuid_gens;
std::unordered_map<uint32_t, uint32_t> g_uuid_gens;
uint64_t dpi_uuid_gen(bool reset, int wid, uint64_t PC) {
uint64_t dpi_uuid_gen(bool reset, int wid) {
if (reset) {
g_uuid_gens.clear();
return 0;
}
std::shared_ptr<vortex::UUIDGenerator> uuid_gen;
auto it = g_uuid_gens.find(wid);
if (it == g_uuid_gens.end()) {
uuid_gen = std::make_shared<vortex::UUIDGenerator>();
g_uuid_gens.emplace(wid, uuid_gen);
} else {
uuid_gen = it->second;
}
uint32_t instr_uuid = uuid_gen->get_uuid(PC);
uint32_t instr_uuid = g_uuid_gens[wid]++;
uint64_t uuid = (uint64_t(wid) << 32) | instr_uuid;
return uuid;
}

View file

@ -1,10 +1,10 @@
// Copyright © 2019-2023
//
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -32,6 +32,6 @@ import "DPI-C" function void dpi_trace(input int level, input string format /*ve
import "DPI-C" function void dpi_trace_start();
import "DPI-C" function void dpi_trace_stop();
import "DPI-C" function longint dpi_uuid_gen(input logic reset, input int wid, input longint PC);
import "DPI-C" function longint dpi_uuid_gen(input logic reset, input int wid);
`endif

View file

@ -338,9 +338,9 @@ module VX_schedule import VX_gpu_pkg::*; #(
`ifdef SV_DPI
always @(posedge clk) begin
if (reset) begin
instr_uuid <= `UUID_WIDTH'(dpi_uuid_gen(1, 0, 0));
instr_uuid <= `UUID_WIDTH'(dpi_uuid_gen(1, 32'd0));
end else if (schedule_fire) begin
instr_uuid <= `UUID_WIDTH'(dpi_uuid_gen(0, 32'(g_wid), 64'(schedule_pc)));
instr_uuid <= `UUID_WIDTH'(dpi_uuid_gen(0, 32'(g_wid)));
end
end
`else

View file

@ -303,7 +303,7 @@
end
`INST_FPU_MISC: begin
if (op_args.fpu.fmt[0]) begin
case (op_args)
case (op_args.fpu.frm)
0: `TRACE(level, ("FSGNJ.D"));
1: `TRACE(level, ("FSGNJN.D"));
2: `TRACE(level, ("FSGNJX.D"));
@ -314,7 +314,7 @@
7: `TRACE(level, ("FMAX.D"));
endcase
end else begin
case (op_args)
case (op_args.fpu.frm)
0: `TRACE(level, ("FSGNJ.S"));
1: `TRACE(level, ("FSGNJN.S"));
2: `TRACE(level, ("FSGNJX.S"));

View file

@ -1,55 +0,0 @@
// Copyright © 2019-2023
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once
#include <unordered_map>
namespace vortex {
class UUIDGenerator {
public:
UUIDGenerator() : ids_(0) {}
virtual ~UUIDGenerator() {}
uint32_t get_uuid(uint64_t /*PC*/) {
/*uint16_t id;
uint16_t ref;
auto it = uuid_map_.find(PC);
if (it != uuid_map_.end()) {
uint32_t value = it->second;
ref = value & 0xffff;
id = value >> 16;
++ref;
} else {
ref = 0;
id = ids_++;
}
uint32_t ret = (uint32_t(id) << 16) | ref;
uuid_map_[PC] = ret;*/
return ids_++;
}
void reset() {
//uuid_map_.clear();
ids_ = 0;
}
private:
//std::unordered_map<uint64_t, uint32_t> uuid_map_;
uint16_t ids_;
};
}

View file

@ -44,6 +44,7 @@ Emulator::ipdom_entry_t::ipdom_entry_t(const ThreadMask &tmask)
Emulator::warp_t::warp_t(const Arch& arch)
: ireg_file(arch.num_threads(), std::vector<Word>(arch.num_regs()))
, freg_file(arch.num_threads(), std::vector<uint64_t>(arch.num_regs()))
, uuid(0)
{}
void Emulator::warp_t::clear(uint64_t startup_addr) {
@ -153,7 +154,7 @@ instr_trace_t* Emulator::step() {
assert(warp.tmask.any());
#ifndef NDEBUG
uint32_t instr_uuid = warp.uui_gen.get_uuid(warp.PC);
uint32_t instr_uuid = warp.uuid++;
uint32_t g_wid = core_->id() * arch_.num_warps() + scheduled_warp;
uint64_t uuid = (uint64_t(g_wid) << 32) | instr_uuid;
#else

View file

@ -75,7 +75,7 @@ private:
std::vector<std::vector<uint64_t>>freg_file;
std::stack<ipdom_entry_t> ipdom_stack;
Byte fcsr;
UUIDGenerator uui_gen;
uint32_t uuid;
};
struct wspawn_t {

View file

@ -22,7 +22,6 @@
#include <stringutil.h>
#include <VX_config.h>
#include <simobject.h>
#include "uuid_gen.h"
#include "debug.h"
namespace vortex {