Skip to content

Commit

Permalink
Merge pull request #2267 from sstsimulator/devel
Browse files Browse the repository at this point in the history
Automatically Merged using SST Master Branch Merger
  • Loading branch information
sst-autotester authored Oct 31, 2023
2 parents ebee81a + a8104cc commit a4561e3
Show file tree
Hide file tree
Showing 14 changed files with 335 additions and 117 deletions.
44 changes: 44 additions & 0 deletions src/sst/elements/vanadis/decoder/vriscv64decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -1376,6 +1376,50 @@ class VanadisRISCV64Decoder : public VanadisDecoder
decode_fault = false;
}
} break;
case 0x20:
{
if(LIKELY(op_width != 0)) {
// AMO.OR
output->verbose(CALL_INFO, 16, 0,
"-----> AMOOR 0x%llx / thr: %" PRIu32 " / %" PRIu16 " <- memory[ %" PRIu16 " ] <- %" PRIu16
" / width: %" PRIu32 " / aq: %s / rl: %s\n",
ins_address, hw_thr, rd, rs1, rs2, op_width, perform_aq ? "yes" : "no", perform_rl ? "yes" : "no");

if(LIKELY(perform_aq)) {
bundle->addInstruction(new VanadisFenceInstruction(ins_address, hw_thr, options, VANADIS_LOAD_STORE_FENCE));
}

// implement a micro-op sequence for AMOADD
// (r1) -> rd
bundle->addInstruction(new VanadisLoadInstruction(
ins_address, hw_thr, options, rs1, 0, rd, op_width,
true, MEM_TRANSACTION_LLSC_LOAD,
LOAD_INT_REGISTER));

// rd | rs2 -> r32
bundle->addInstruction(
new VanadisOrInstruction(
ins_address, hw_thr, options, 32, rd, rs2));

// r32 -> (rs1) and place success code in r33
// 0 is a success, 1 is a failure
bundle->addInstruction(new VanadisStoreConditionalInstruction(
ins_address, hw_thr, options, rs1, 0, 32, /* success code */ 33, op_width,
STORE_INT_REGISTER, 0, 1));

// branch back to this instruction address IF r33 == 1 (which means the store failed)
bundle->addInstruction(new VanadisBranchRegCompareImmInstruction<int64_t, REG_COMPARE_EQ>(
ins_address, hw_thr, options, 4, 33, 1,
/* offset is 0 so we replay this instruction */ 0, VANADIS_NO_DELAY_SLOT
));

if(LIKELY(perform_rl)) {
bundle->addInstruction(new VanadisFenceInstruction(ins_address, hw_thr, options, VANADIS_LOAD_STORE_FENCE));
}

decode_fault = false;
}
} break;
case 0x8:
{
if ( rs2 == 0 ) {
Expand Down
7 changes: 2 additions & 5 deletions src/sst/elements/vanadis/os/callev/voscallfutex.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ class VanadisSyscallFutexEvent : public VanadisSyscallEvent {
VanadisSyscallFutexEvent(uint32_t core, uint32_t thr, VanadisOSBitType bittype, uint64_t addr, int32_t op, uint32_t val, uint64_t time_addr, uint64_t stack_ptr)
: VanadisSyscallEvent(core, thr, bittype), addr(addr), op(op), val(val), time_addr(time_addr), stack_ptr(stack_ptr) {}
VanadisSyscallFutexEvent(uint32_t core, uint32_t thr, VanadisOSBitType bittype, uint64_t addr, int32_t op, uint32_t val, uint64_t time_addr,
uint32_t val2, uint64_t addr2, uint32_t val3)
: VanadisSyscallEvent(core, thr, bittype), addr(addr), op(op), val(val), time_addr(time_addr), stack_ptr(0), val2(val2), addr2(addr2), val3(val3) {}
uint64_t addr2, uint32_t val3)
: VanadisSyscallEvent(core, thr, bittype), addr(addr), op(op), val(val), time_addr(time_addr), stack_ptr(0), addr2(addr2), val3(val3) {}


VanadisSyscallOp getOperation() override { return SYSCALL_OP_FUTEX; }
Expand All @@ -37,7 +37,6 @@ class VanadisSyscallFutexEvent : public VanadisSyscallEvent {
uint64_t getAddr2() const { return addr2; }
int32_t getOp() const { return op; }
uint32_t getVal() const { return val; }
uint32_t getVal2() const { return val2; }
uint32_t getVal3() const { return val3; }
uint64_t getTimeAddr() const { return time_addr; }
uint64_t getStackPtr() const { return stack_ptr; }
Expand All @@ -49,7 +48,6 @@ class VanadisSyscallFutexEvent : public VanadisSyscallEvent {
ser& addr2;
ser& op;
ser& val;
ser& val2;
ser& val3;
ser& time_addr;
ser& stack_ptr;
Expand All @@ -60,7 +58,6 @@ class VanadisSyscallFutexEvent : public VanadisSyscallEvent {
uint64_t addr2;
int32_t op;
uint32_t val;
uint32_t val2;
uint32_t val3;

uint64_t time_addr;
Expand Down
42 changes: 33 additions & 9 deletions src/sst/elements/vanadis/os/include/fdTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,21 @@ class FileDescriptor {
//printf("%s() %s oldfd=%d flags=%#x mode=%#x newfd=%d\n",__func__,path.c_str(), obj.fd,flags,buf.st_mode,fd);
}

FileDescriptor(std::string& file_path, int flags, mode_t mode) : path(file_path)
FileDescriptor(std::string& file_path, int flags, mode_t mode, bool lazy) : path(file_path), flags(flags), mode(mode)
{
fd = open(file_path.c_str(), flags, mode );
if ( -1 == fd ) {
printf("%s() FAILED: %s flags=%#x mode=%#x\n",__func__,path.c_str(),flags,mode);
throw errno;
if ( ! lazy ) {
fd = open(file_path.c_str(), flags, mode );
if ( -1 == fd ) {
printf("%s() FAILED: %s flags=%#x mode=%#x\n",__func__,path.c_str(),flags,mode);
throw errno;
}
} else {
fd = -1;
}
//printf("%s() %s flags=%#x mode=%#x fd=%d\n",__func__,path.c_str(),flags,mode,fd);
}

FileDescriptor(std::string& file_path, int dirfd, int flags, mode_t mode) : path(file_path)
FileDescriptor(std::string& file_path, int dirfd, int flags, mode_t mode) : path(file_path), fd( -1 )
{
fd = openat(dirfd, file_path.c_str(), flags, mode );
if ( -1 == fd ) {
Expand All @@ -78,7 +82,20 @@ class FileDescriptor {
}

~FileDescriptor() {
close(fd);
if ( -1 != fd ) {
close(fd);
}
}

int openLate() {
fd = open(path.c_str(), flags, mode );
if ( -1 == fd ) {
printf("%s() FAILED: %s flags=%#x mode=%#x\n",__func__,path.c_str(),flags,mode);
throw errno;
} else {
printf("%s() %s flags=%#x mode=%#x\n",__func__,path.c_str(),flags,mode);
}
return fd;
}

std::string getPath() const {
Expand All @@ -92,6 +109,8 @@ class FileDescriptor {
protected:
std::string path;
int fd;
int flags;
mode_t mode;
};

class FileDescriptorTable {
Expand Down Expand Up @@ -137,7 +156,8 @@ class FileDescriptorTable {
}
if ( fd >= 0 ) {
try {
m_fileDescriptors[fd] = new FileDescriptor(file_path,flags,mode);
// m_fileDescriptors[fd] = new FileDescriptor(file_path,flags,mode, fd <= 2 );
m_fileDescriptors[fd] = new FileDescriptor(file_path,flags,mode, false );
} catch ( int err ) {
fd = -err;
}
Expand Down Expand Up @@ -173,7 +193,11 @@ class FileDescriptorTable {
if (iter == m_fileDescriptors.end()) {
return -1;
}
return iter->second->getFileDescriptor();
auto fd = iter->second->getFileDescriptor();
if ( -1 == fd ) {
fd = iter->second->openLate();
}
return fd;
}

std::string getPath( uint32_t handle ) {
Expand Down
9 changes: 6 additions & 3 deletions src/sst/elements/vanadis/os/include/virtMemMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,11 @@ struct MemoryRegion {
~MemoryRegion() {
for ( auto kv: m_virtToPhysMap) {
auto page = kv.second;
if ( 0 == page->decRefCnt() ) {
delete page;
// don't delete text pages because they are in the page cache
if ( name.compare("text" ) ) {
if ( 0 == page->decRefCnt() ) {
delete page;
}
}
}
}
Expand Down Expand Up @@ -243,7 +246,7 @@ class VirtMemMap {
}

uint64_t mmap( size_t length, uint32_t perms, Device* dev ) {
std::string name;
std::string name("mmap");
MemoryBacking* backing = nullptr;
if ( dev ) {
backing = new MemoryBacking( dev );
Expand Down
Loading

0 comments on commit a4561e3

Please sign in to comment.