[gem5-users] Re: GEM5 within SystemC build issue

2023-07-19 Thread G via gem5-users
Looks like this JIRA is low priority and has no progress since 2021.
Thanks a lot!


| |
G
|
|
ginger...@163.com
|
 Replied Message 
| From | Yu-hsin Wang |
| Date | 7/20/2023 10:47 |
| To | G |
| Cc | gem5-users@gem5.org |
| Subject | Re: [gem5-users] Re: GEM5 within SystemC build issue |
Hi Ginger,


We didn't try to run gem5 as dynamic lib inside SystemC. You may need to reach 
the maintainers. Here's a ticket you can refer. 
https://gem5.atlassian.net/browse/GEM5-874


Thanks.


On Wed, Jul 19, 2023 at 4:43 PM G  wrote:

Hi Yu-hsin,


Thanks for the reply, I'm trying to run gem5 as dynamic lib inside SystemC.
Did tried and can pass build without this option, but hit below assertion so I 
suspect it has to go with cxx-config portion.
main.cc:280: fatal: Config problem in sim object root: No sim object type Root 
is available




| |
G
|
|
ginger...@163.com
|
 Replied Message 
| From | Yu-hsin Wang |
| Date | 7/19/2023 15:32 |
| To | G |
| Cc | gem5-users@gem5.org |
| Subject | Re: [gem5-users] Re: GEM5 within SystemC build issue |
Hi Ginger,


I think the issue is --with-cxx-config only works in SimObject case. However 
the Gem5-TLM bridges are all sc_modules instead of SimObject. I can get compile 
success without --with-cxx-config.
Is that option required in your case?


Thanks.


On Wed, Jul 19, 2023 at 2:43 PM G  wrote:

Hello Yu-hsin,


Just saw you are the main edtor of tlm bridge to sysc, maybe you are the right 
person? :)


In the bridge, this->create() will return a Gem5ToTlmBridge type which is 
incompatible with SimObject as below declared, any comments? Thanks a lot!


SimObject *
Gem5ToTlmBridge32CxxConfigParams::simObjectCreate()
{
return this->create();
}


| |
G
|
|


|
 Replied Message 
| From | G via gem5-users |
| Date | 7/14/2023 17:24 |
| To | gem5-users@gem5.org |
| Cc | G |
| Subject | [gem5-users] Re: GEM5 within SystemC build issue |
Hello, Anyone hit same issue when building "GEM5 within SystemC"? Or just 
succeeding?


| |
G
|
|
ginger...@163.com
|
 Replied Message 
| From | G via gem5-users |
| Date | 7/3/2023 10:35 |
| To | gem5-users@gem5.org |
| Cc | gingerluo |
| Subject | [gem5-users] GEM5 within SystemC build issue |
Hello,


Anyone went well with GEM5 and SystemC integration?


I triied to build libgem5_debug.so so I can integrate GEM5 in a standalone 
systemc environment with below commandline:


 python3 `which scons` --with-cxx-config --without-python --without-tcmalloc 
USE_SYSTEMC=1 build/RISCV/libgem5_$(BUILD_TYPE).so -j 32


But I got below issue with "--with-cxx-config" option.


build/RISCV/cxx_config/Gem5ToTlmBridge32.cc: In member function ‘virtual 
gem5::SimObject* gem5::Gem5ToTlmBridge32CxxConfigParams::simObjectCreate()’:
build/RISCV/cxx_config/Gem5ToTlmBridge32.cc:149:24: error: cannot convert 
‘sc_gem5::Gem5ToTlmBridge<32>*’ to ‘gem5::SimObject*’ in return
  149 | return this->create();
  | ^~
  | |
  | sc_gem5::Gem5ToTlmBridge<32>*


 if I do without this option, assertion fired in below, complaining:


main.cc:280: fatal: Config problem in sim object root: No sim object type Root 
is available






| |
G
|
|
ginger...@163.com
|___
gem5-users mailing list -- gem5-users@gem5.org
To unsubscribe send an email to gem5-users-le...@gem5.org


[gem5-users] Re: How se mode implements system calls for riscv

2023-07-19 Thread Srikanta Chaitanya via gem5-users
Thanks, I'll check them out.

On Thu, Jul 20, 2023, 12:01 AM Ayaz Akram  wrote:

> Hi Srikanta,
>
> You can find the implementation of system calls in src/sim/syscall_emul.cc
> (and related files in the same directory). You can use the "strace" tool to
> find out the syscalls used by a binary.
>
> As far as multithreading is concerned, I think SE mode is not suitable for
> that purpose and you might want to use FS mode of gem5.
>
> -Ayaz
>
> On Sun, Jul 16, 2023 at 9:59 PM Srikanta Chaitanya via gem5-users <
> gem5-users@gem5.org> wrote:
>
>> Hi ,
>> I am simulating muticore riscv but when i fork threads it count is less
>> than my spawn count ,
>>
>> I just want to read code of system calls , how they are implemented in
>> gem5
>>
>> Please share me file names
>>
>> Let me know how to identify the system call from elf
>>
>> Please
>> Thanks srikanta
>> ___
>> gem5-users mailing list -- gem5-users@gem5.org
>> To unsubscribe send an email to gem5-users-le...@gem5.org
>>
>
___
gem5-users mailing list -- gem5-users@gem5.org
To unsubscribe send an email to gem5-users-le...@gem5.org


[gem5-users] Re: How se mode implements system calls for riscv

2023-07-19 Thread Ayaz Akram via gem5-users
Hi Srikanta,

You can find the implementation of system calls in src/sim/syscall_emul.cc
(and related files in the same directory). You can use the "strace" tool to
find out the syscalls used by a binary.

As far as multithreading is concerned, I think SE mode is not suitable for
that purpose and you might want to use FS mode of gem5.

-Ayaz

On Sun, Jul 16, 2023 at 9:59 PM Srikanta Chaitanya via gem5-users <
gem5-users@gem5.org> wrote:

> Hi ,
> I am simulating muticore riscv but when i fork threads it count is less
> than my spawn count ,
>
> I just want to read code of system calls , how they are implemented in
> gem5
>
> Please share me file names
>
> Let me know how to identify the system call from elf
>
> Please
> Thanks srikanta
> ___
> gem5-users mailing list -- gem5-users@gem5.org
> To unsubscribe send an email to gem5-users-le...@gem5.org
>
___
gem5-users mailing list -- gem5-users@gem5.org
To unsubscribe send an email to gem5-users-le...@gem5.org


[gem5-users] Re: Exception when running libtorch simulation in SE mode

2023-07-19 Thread Bobby Bruce via gem5-users
I tried to reproduce this for myself but I failed to do so (using v23.0.0.1, `build/ALL/gem5.opt`).. Attached is a tarball of the files i used. The steps I carried out can be found on the the "README.md" file. I'm not sure what I'm missing but my execution prints "Hello World" successfully.The host was an X86 Ubuntu 20.04.6 OS and everything was compiled if GCC 9.4.0.

reproduction.tar.gz
Description: GNU Zip compressed data

--Dr. Bobby R. BruceRoom 3050,Kemper Hall, UC DavisDavis,CA, 95616 web: https://www.bobbybruce.net

On Jul 18, 2023, at 6:08 PM, Matt Sinclair  wrote:For what it's worth, one of the students working with me (Marco, CC'd) is having the same failure right now for the head of develop (plus this fix: https://github.com/gem5/gem5/pull/99), except for a tiny GPU microbenchmark that definitely is not using PyTorch or any higher level library.We are working on getting a backtrace to understand what's going on for us (and then push a fix as applicable), and it's possible our problems have the same symptom but a different root cause.  But just wanted to chime in that there are multiple cases where this error is happening on develop right now with SE mode.MattOn Tue, Jul 18, 2023 at 7:58 PM Bobby Bruce via gem5-users  wrote:I’m afraid I don’t know exactly what’s causing this error, but just to make sure, the binary you built and as a `CustomResource` executes on your host? This looks like an error coming from PyTorch, not the simulator. That being said, I don’t understand why "build/X86/sim/faults.cc:61: panic: panic condition !FullSystem occurred: fault (General-Protection) detected @ PC “ is occurring after either, that could also be the issue. Personally, I’m always a bit scared linking to dynamic libraries on the host as well,If you want to get around this the annoying advice is to use FS mode. It’s slower, and requires creation of a disk image, but it isn’t nearly as error-prone as SE mode. If your binary works on your host then you should be able to get it to work in FS mode. Using checkpoints and (if you have the right hardware and are using X86) KVM cores can speed things up for you too.Also, as a sidenote: If you’re wanting to simulate PyTorch, don’t you want to simulate a GPU too?
--Dr. Bobby R. BruceRoom 3050,Kemper Hall, UC DavisDavis,CA, 95616 web: https://www.bobbybruce.net

On Jul 14, 2023, at 3:02 AM, Caio Vieira via gem5-users  wrote:
  


  
  

Hi everyone,
  
  
  I'm trying to execute gem5 simulations using libtorch in SE mode.
  However, I get the following error message:
  
  
  --- Error message ---
  
  ...
  
  terminate called after throwing an instance of
  'std::runtime_error'
  
    what():  expected eof but found 'ident' here:
  
  aten::quantized_lstm.inpr input, Tensor[]
  orch.classes.rnn.CellPara[] params, bool has_biases, int
  num_layers, float dropout, bool train, bool bidirectional, bool
  batch_first, *, ScalarType? dtype=None, bool use_dynamic=False) dy
  
  namic=False) -> (Tensor, Tensor, Tenso Tensor, Tensor)
  
    ~ <--- HERE
  
  
  build/X86/sim/syscall_emul.cc:86: warn: ignoring syscall
  rt_sigprocmask(...)
  
    (further warnings will be suppressed)
  
  build/X86/sim/syscall_emul.cc:86: warn: ignoring syscall
  rt_sigaction(...)
  
    (further warnings will be suppressed)
  
  build/X86/sim/faults.cc:61: panic: panic condition !FullSystem
  occurred: fault (General-Protection) detected @ PC
  (0x7fff7a3d5898=>0x7fff7a3d5899).(0=>1)
  
  Memory Usage: 11842716 KBytes
  
  Program aborted at tick 294083905383
  
  --- BEGIN LIBC BACKTRACE ---
  
  ...
  
  
  The simulation fails before the first line of the main function. I
  believe that it is failing to load the libtorch library.
  
  Unfortunately, it is not possible to build libtorch with "-static"
  since their static builds is broken for quiet a long
  
  time: https://github.com/pytorch/pytorch/issues/21737
I've tested with gem5 v22.1.0.0
  and also 22.0.0.2. I've also tested using different GCC versions
  to build the simulated binary.
  
  For anyone interested in reproducing the error, I'm sending a
  "setup.sh" script to create a minimal reproducible environment.
  
  Simply copy and paste the script below and name it as "setup.sh"
  in a new directory, then:
  
  
  source setup.sh
  
  cmake --B build -S .
  
  cmake --build build
  
  ./ config.py build/main 




  Best regards,
  Caio Vieira
  
  --- setup.sh ---
  
  
  #!/bin/bash
  
  
  # Bash script to create minimal reproducible environment for
  libtorch simulation
  
  # bug. 

[gem5-users] Re: GEM5 within SystemC build issue

2023-07-19 Thread G via gem5-users
Hi Yu-hsin,


Thanks for the reply, I'm trying to run gem5 as dynamic lib inside SystemC.
Did tried and can pass build without this option, but hit below assertion so I 
suspect it has to go with cxx-config portion.
main.cc:280: fatal: Config problem in sim object root: No sim object type Root 
is available




| |
G
|
|
ginger...@163.com
|
 Replied Message 
| From | Yu-hsin Wang |
| Date | 7/19/2023 15:32 |
| To | G |
| Cc | gem5-users@gem5.org |
| Subject | Re: [gem5-users] Re: GEM5 within SystemC build issue |
Hi Ginger,


I think the issue is --with-cxx-config only works in SimObject case. However 
the Gem5-TLM bridges are all sc_modules instead of SimObject. I can get compile 
success without --with-cxx-config.
Is that option required in your case?


Thanks.


On Wed, Jul 19, 2023 at 2:43 PM G  wrote:

Hello Yu-hsin,


Just saw you are the main edtor of tlm bridge to sysc, maybe you are the right 
person? :)


In the bridge, this->create() will return a Gem5ToTlmBridge type which is 
incompatible with SimObject as below declared, any comments? Thanks a lot!


SimObject *
Gem5ToTlmBridge32CxxConfigParams::simObjectCreate()
{
return this->create();
}


| |
G
|
|


|
 Replied Message 
| From | G via gem5-users |
| Date | 7/14/2023 17:24 |
| To | gem5-users@gem5.org |
| Cc | G |
| Subject | [gem5-users] Re: GEM5 within SystemC build issue |
Hello, Anyone hit same issue when building "GEM5 within SystemC"? Or just 
succeeding?


| |
G
|
|
ginger...@163.com
|
 Replied Message 
| From | G via gem5-users |
| Date | 7/3/2023 10:35 |
| To | gem5-users@gem5.org |
| Cc | gingerluo |
| Subject | [gem5-users] GEM5 within SystemC build issue |
Hello,


Anyone went well with GEM5 and SystemC integration?


I triied to build libgem5_debug.so so I can integrate GEM5 in a standalone 
systemc environment with below commandline:


 python3 `which scons` --with-cxx-config --without-python --without-tcmalloc 
USE_SYSTEMC=1 build/RISCV/libgem5_$(BUILD_TYPE).so -j 32


But I got below issue with "--with-cxx-config" option.


build/RISCV/cxx_config/Gem5ToTlmBridge32.cc: In member function ‘virtual 
gem5::SimObject* gem5::Gem5ToTlmBridge32CxxConfigParams::simObjectCreate()’:
build/RISCV/cxx_config/Gem5ToTlmBridge32.cc:149:24: error: cannot convert 
‘sc_gem5::Gem5ToTlmBridge<32>*’ to ‘gem5::SimObject*’ in return
  149 | return this->create();
  | ^~
  | |
  | sc_gem5::Gem5ToTlmBridge<32>*


 if I do without this option, assertion fired in below, complaining:


main.cc:280: fatal: Config problem in sim object root: No sim object type Root 
is available






| |
G
|
|
ginger...@163.com
|___
gem5-users mailing list -- gem5-users@gem5.org
To unsubscribe send an email to gem5-users-le...@gem5.org


[gem5-users] Re: Exception when running libtorch simulation in SE mode

2023-07-19 Thread Caio Vieira via gem5-users

Hi,

Yes, the binary works correctly on my host. Also, I was able to load it 
in an Ubuntu 18 FS simulation using gem5.


Before the panic condition is triggered, an exception is thrown, which 
does not occur when running on host. I tried to debug gem5 by running it 
on gdb and using "catch throw" to intercept exceptions. However, the gdb 
only stopped at the panic condition and not when the exception was 
thrown, which makes me believe that the exception was thrown by libtorch.


"Also, as a sidenote: If you’re wanting to simulate PyTorch, don’t you 
want to simulate a GPU too?"


Maybe in the future. At the moment I'm focused on getting a basic 
simulation of CPU+libtorch working :)


On 19.07.23 02:55, Bobby Bruce via gem5-users wrote:
I’m afraid I don’t know exactly what’s causing this error, but just to 
make sure, the binary you built and as a `CustomResource` executes on 
your host? This looks like an error coming from PyTorch, not the 
simulator. That being said, I don’t understand why 
"build/X86/sim/faults.cc:61: panic: panic condition !FullSystem 
occurred: fault (General-Protection) detected @ PC “ is occurring 
after either, that could also be the issue. Personally, I’m always a 
bit scared linking to dynamic libraries on the host as well,


If you want to get around this the annoying advice is to use FS mode. 
It’s slower, and requires creation of a disk image, but it isn’t 
nearly as error-prone as SE mode. If your binary works on your host 
then you should be able to get it to work in FS mode. Using 
checkpoints and (if you have the right hardware and are using X86) KVM 
cores can speed things up for you too.


Also, as a sidenote: If you’re wanting to simulate PyTorch, don’t you 
want to simulate a GPU too?


--
Dr. Bobby R. Bruce
Room 3050,
Kemper Hall, UC Davis
Davis,
CA, 95616

web: https://www.bobbybruce.net

On Jul 14, 2023, at 3:02 AM, Caio Vieira via gem5-users 
 wrote:



Hi everyone,

I'm trying to execute gem5 simulations using libtorch in SE mode. 
However, I get the following error message:


--- Error message ---
...
terminate called after throwing an instance of 'std::runtime_error'
  what():  expected eof but found 'ident' here:
aten::quantized_lstm.inpr input, Tensor[] orch.classes.rnn.CellPara[] 
params, bool has_biases, int num_layers, float dropout, bool train, 
bool bidirectional, bool batch_first, *, ScalarType? dtype=None, bool 
use_dynamic=False) dy

namic=False) -> (Tensor, Tensor, Tenso Tensor, Tensor)
  ~ <--- HERE

build/X86/sim/syscall_emul.cc:86: warn: ignoring syscall 
rt_sigprocmask(...)

  (further warnings will be suppressed)
build/X86/sim/syscall_emul.cc:86: warn: ignoring syscall 
rt_sigaction(...)

  (further warnings will be suppressed)
build/X86/sim/faults.cc:61: panic: panic condition !FullSystem 
occurred: fault (General-Protection) detected @ PC 
(0x7fff7a3d5898=>0x7fff7a3d5899).(0=>1)

Memory Usage: 11842716 KBytes
Program aborted at tick 294083905383
--- BEGIN LIBC BACKTRACE ---
...

The simulation fails before the first line of the main function. I 
believe that it is failing to load the libtorch library.
Unfortunately, it is not possible to build libtorch with "-static" 
since their static builds is broken for quiet a long

time: https://github.com/pytorch/pytorch/issues/21737
I've tested with gem5 v22.1.0.0 and also 22.0.0.2. I've also tested 
using different GCC versions to build the simulated binary.


For anyone interested in reproducing the error, I'm sending a 
"setup.sh" script to create a minimal reproducible environment.
Simply copy and paste the script below and name it as "setup.sh" in a 
new directory, then:


source setup.sh
cmake --B build -S .
cmake --build build
./ config.py build/main

Best regards,
Caio Vieira

--- setup.sh ---

#!/bin/bash

# Bash script to create minimal reproducible environment for libtorch 
simulation
# bug. This script creates necessary files such as a CMakeLists.txt 
and a minimal
# main.cpp. The CMakeLists.txt file downloads and manages libtorch by 
saving it

# in a ""_deps"" folder. Steps to reproduce the bug:
# ./
# cmake -B build -S .
# cmake --build build
# ./ config.py build/main

function create_cmake() {
    cat > CMakeLists.txt <<- \EOF
cmake_minimum_required(VERSION 3.22 FATAL_ERROR)

# Download and manage libtorch dependency
set(DEPENDENCY_DIR "${CMAKE_CURRENT_LIST_DIR}/_deps")

file(MAKE_DIRECTORY "${DEPENDENCY_DIR}")
if(NOT EXISTS "${DEPENDENCY_DIR}/libtorch")
    file(DOWNLOAD
https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-2.0.0%2Bcpu.zip 


    "${DEPENDENCY_DIR}/libtorch.zip")
    file(ARCHIVE_EXTRACT
    INPUT "${DEPENDENCY_DIR}/libtorch.zip"
    DESTINATION "${DEPENDENCY_DIR}")
    file(REMOVE "${DEPENDENCY_DIR}/libtorch.zip")
endif()
set(CMAKE_PREFIX_PATH "${DEPENDENCY_DIR}/libtorch")
find_package(Torch REQUIRED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS}")

project(main)

# Create 

[gem5-users] Re: GEM5 within SystemC build issue

2023-07-19 Thread G via gem5-users
Hello Yu-hsin,


Just saw you are the main edtor of tlm bridge to sysc, maybe you are the right 
person? :)


In the bridge, this->create() will return a Gem5ToTlmBridge type which is 
incompatible with SimObject as below declared, any comments? Thanks a lot!


SimObject *
Gem5ToTlmBridge32CxxConfigParams::simObjectCreate()
{
return this->create();
}


| |
G
|
|


|
 Replied Message 
| From | G via gem5-users |
| Date | 7/14/2023 17:24 |
| To | gem5-users@gem5.org |
| Cc | G |
| Subject | [gem5-users] Re: GEM5 within SystemC build issue |
Hello, Anyone hit same issue when building "GEM5 within SystemC"? Or just 
succeeding?


| |
G
|
|
ginger...@163.com
|
 Replied Message 
| From | G via gem5-users |
| Date | 7/3/2023 10:35 |
| To | gem5-users@gem5.org |
| Cc | gingerluo |
| Subject | [gem5-users] GEM5 within SystemC build issue |
Hello,


Anyone went well with GEM5 and SystemC integration?


I triied to build libgem5_debug.so so I can integrate GEM5 in a standalone 
systemc environment with below commandline:


 python3 `which scons` --with-cxx-config --without-python --without-tcmalloc 
USE_SYSTEMC=1 build/RISCV/libgem5_$(BUILD_TYPE).so -j 32


But I got below issue with "--with-cxx-config" option.


build/RISCV/cxx_config/Gem5ToTlmBridge32.cc: In member function ‘virtual 
gem5::SimObject* gem5::Gem5ToTlmBridge32CxxConfigParams::simObjectCreate()’:
build/RISCV/cxx_config/Gem5ToTlmBridge32.cc:149:24: error: cannot convert 
‘sc_gem5::Gem5ToTlmBridge<32>*’ to ‘gem5::SimObject*’ in return
  149 | return this->create();
  | ^~
  | |
  | sc_gem5::Gem5ToTlmBridge<32>*


 if I do without this option, assertion fired in below, complaining:


main.cc:280: fatal: Config problem in sim object root: No sim object type Root 
is available






| |
G
|
|
ginger...@163.com
|___
gem5-users mailing list -- gem5-users@gem5.org
To unsubscribe send an email to gem5-users-le...@gem5.org