How can I initialize the data to the DRAM in gem5? - gem5

I'm new to gem5 and having a problem with initializing the data to the DRAM.
I want to preload the data in the hex file to the particular address on the DRAM.
Is there any way to do this?
I appreciate your help in advance.

DRAM in gem5 inherit the class AbstractMemory(abstract_mem.cc), the correponding .py provide a parameter called 'image_file' to initialize the memory.
So you can write the following code in the config file, such as se.py:
system.mem_ctrls[0].dram.image_file = /path/to/your/file
Only the binary data format file are supported, transfer your original hex file.

Related

Gshare branch predictor for gem5

I want to use Gshare in gem5. I have found the source code and instructions here. Unfortunately, the GshareBP option didn’t appeared on gem5’s branch predictor list.
Any ideas?
The list is generated from the Python classes. The author forgot to add the Python declarations of the parameter classes, so you will have to do that yourself.
For example, GShareBP needs the parameters localPredictorSize and localCtrBits, so you will need to add the following class src/cpu/pred/BranchPredictor.py (this is just an example; I don't know the actual values of the parameters):
class GShareBP(BranchPredictor):
type = 'GShareBP'
cxx_class = 'GShareBP'
cxx_header = "cpu/pred/gshare.hh"
localPredictorSize = Param.Unsigned(2048, "Size of local predictor")
localCtrBits = Param.Unsigned(2, "Bits per counter")
You will also need to inform that gshare.cc must be compiled (in src/cpu/pred/SConscript):
Source('gshare.cc')
You will face a lot of errors after doing that; that code was written for 2014's gem5.
Things you may also need to do:
Add the following to gshare.cc #include "params/GShareBP.hh"
Add typedef GShareBPParams Params; to gshare.hh
Rename SatCounter as SatCounter8
For more information, you may find the book Learning gem5 helpful

is there any way to make this class file generated by byte buddy contains LocalVariableTable?

I am using byte buddy to print logs of methods automaticly,but i found that if i use byte buddy to regenerate class files,the LocalVariableTable will be overwritten and disappear.and that will make springmvc unfunctional because springmvc uses LocalVariableTable to get the names of args of methods,and if there is no LocalVariableTable, the programme will go wrong.so how can byte buddy generate a class file with LocalVariableTable?
here is how I used it:
DynamicType.Builder<?>.method((isPublic()
.and(not(isEquals()))
.and(not(isClone()))
.and(not(isToString()))
.and(not(isHashCode()))
.and(not(isDefaultMethod()))
.and(not(isDefaultConstructor()))
.and(not(isDefaultFinalizer()))
.and(not(isAbstract()))
.and(not(isStatic()))
.and(not(isSetter().or(isGetter()))))
.or(isAnnotatedWith(Hook.class)))
.intercept(Advice.to(MethodHooks.class));
If you use interception, you are defining a new method and the old method is backed-up to another location for being able to invoke it. This includes the debug table where this information is stored. You can however compile a class using the -parameters parameter. This more official information is retained by Byte Buddy.

Java read variable number values from text file and assign to declared program variables

Is there a way in Java to have text file with listed a=10.35 b=20.57 c=30.79 and get program to only read the variable decimal values and assign them to declared variables a, b, c in the program.
Searched youtube found nothing.
Do not know if it is possible.
Do not know.
Got it working.
You can certainly read in the contents of the text file and parse it down to the chars and doubles.
If you are referring to declaring named variables based on the file, there is no way to do this directly at runtime. You can, however, use a data structure like a dictionary or map to store the data and access it using the name as a key.
If you could provide more details about what you are trying to do, that would make it easier to answer your question more specifically.

Dask DataFrame to_parquet return bytes instead of writing to file

Is it possible to write dask/pandas DataFrame to parquet and than return bytes string? I know that is not possible with to_parquet() function which accepts file path. Maybe, you have some other ways to do it. If there is no possibility to do something like this, is it makes sense to add such functionality? Ideally, it should be like this:
parquet_bytes = df.to_parquet() # bytes string is returned
Thanks!
There has been work undertaken to allow such a thing, but it's not currently a one-line thing like you suggest.
Firstly, if you have data which can fit in memory, you can use fastparquet's write() method, and supply an open= argument. This must be a function that creates a file-like object in binary-write mode, in your case a BytesIO() would do.
To make this work directly with dask, you could make use of the MemoryFileSystem from the filesystem_spec project. You would need to add the class to Dask and write as following:
dask.bytes.core._filesystems['memory'] = fsspec.implementations.memory.MemoryFileSystem
df.to_parquet('memory://name.parquet')
When done, MemoryFileSystem.store, which is a class attribute, will contain keys that are like filenames, and values which are BytesIO objects containing data.

writing module to .bc bitcode file

i've assumed that dumping a .bc file from a module was a trivial operation, but now,
first time i have to actually do it from code, for the life of me i
can't find one missing step in the process:
static void WriteModule ( const Module * M, BitstreamWriter & Stream )
http://llvm.org/docs/doxygen/html/BitcodeWriter_8cpp.html#a828cec7a8fed9d232556420efef7ae89
to write that module, first i need a BistreamWriter
BitstreamWriter::BitstreamWriter (SmallVectorImpl< char > &O)
http://llvm.org/docs/doxygen/html/classllvm_1_1BitstreamWriter.html
and for a BitstreamWriter i need a SmallVectorImpl. But, what next?
Should i write the content of the SmallVectorImpl byte by byte on a
file handler myself? is there a llvm api for this? do i need something
else?
The WriteModule function is static within lib/Bitcode/Writer/BitcodeWriter.cpp, which means it's not there for outside consumption (you can't even access it).
The same file has another function, however, called WriteBitcodeToFile, with this interface:
/// WriteBitcodeToFile - Write the specified module to the specified output
/// stream.
void llvm::WriteBitcodeToFile(const Module *M, raw_ostream &Out);
I can't imagine a more convenient interface. The header file declaring it is ./include/llvm/Bitcode/ReaderWriter.h, by the way.
I use following code :
std::error_code EC;
llvm::raw_fd_ostream OS("module", EC, llvm::sys::fs::F_None);
WriteBitcodeToFile(pBiFModule, OS);
OS.flush();
and then disassemble using llvm-dis.