OpenXiangShan / XiangShan

Open-source high-performance RISC-V processor
https://xiangshan.cc
Other
4.94k stars 668 forks source link

question about benchmark #2543

Closed menglinhan closed 11 months ago

menglinhan commented 11 months ago

您好,请问你们在南湖上有跑过linpack和whetstone这两个benchmark吗?我在跑自己找的benchmark时,发现缺少一些函数(例如fabs),不知道你们是怎么解决的?

Hello!have you run the benchmark of linpack and whetstone in Nanhu? when I run these two benchmarks which found from opensource, some functions were missing. How did you solve this problem?

menglinhan commented 11 months ago

或者说,需要include哪个头文件才能包括相关的数学函数库?比如sin和cos,log函数

[TRANSLATION] To include the relevant mathematical function library, which header file(s) are needed? For instance, for functions like sin, cos, and log.

cebarobot commented 11 months ago

我们没有在香山上运行过 linpack 或者 whetstone。有关 linpack 或者 whetstone 编译运行相关的问题是纯软件问题,这与香山处理器关系不大,需要您自行解决。

We have not run Linpack or Whetstone on XiangShan. Issues related to compiling and running Linpack or Whetstone are purely software-related and are not significantly related to the XiangShan processor. You will need to resolve these matters on your own.

menglinhan commented 11 months ago

好的,多谢。 再咨询一下,香山官方提供的 gcc-riscv64-linux-gnu编译器看起来是不能识别cos,log这些函数的,麻烦确认一下,不知道是我使用的问题,还是说原本就不支持这些数学函数。

[TRANSLATION] Thanks. I have another question. It seems that the gcc-riscv64-linux-gnu compiler provided by XiangShan does not recognize functions like cos and log. Could you please confirm whether this is due to my usage or if these mathematical functions are not supported originally?

cebarobot commented 11 months ago

首先,riscv64-linux-gnu-gcc 编译器是由 gnu 提供的 RISC-V 工具链的一部分。它不是由香山提供的。 其次,要在 C 语言中使用 cos()log() 等数学函数并用 GCC 编译(无论是 x86 还是 RISC-V 平台),您需要:

Firstly, the riscv64-linux-gnu-gcc compiler is part of the GNU RISC-V toolchain, NOT provided by XiangShan. Secondly, to use mathematical functions like cos() and log() in the C language and compile with GCC (whether on x86 or RISC-V platforms), you need to:

menglinhan commented 11 months ago

我们是这样做的,但还是无法识别,在nexus-am/Makefile.compile文件中的CCFLAGS和编译的地方均添加了,所以怀疑是不是编译器无法识别这些函数。

[TRANSLATION] This is what we did, but it still cannot be recognized. We added CCFLAGS in the nexus-am/Makefile.compile file and also during compilation. So, we suspect that the compiler might not be able to recognize these functions.

CFLAGS   += -O2 -MMD -Wall -Werror -ggdb $(INCLUDES) \
            -D__ISA__=\"$(ISA)\" -D__ISA_$(shell echo $(ISA) | tr a-z A-Z)__ \
            -D__PLATFORM__=\"$(PLATFORM)\" -D__PLATFORM_$(shell echo $(PLATFORM) | tr a-z A-Z)__ \
            -D__ARCH__=$(ARCH) -D__ARCH_$(shell echo $(ARCH) | tr a-z A-Z | tr - _) \
            -DARCH_H=\"arch/$(ARCH).h\" \
            -fno-asynchronous-unwind-tables -fno-builtin -fno-stack-protector  -Wno-strict-aliasing -lm \
            -Wno-main

$(DST_DIR)/%.o: %.c
    @mkdir -p $(dir $@) && echo + CC $<
    @$(CC) -std=gnu11 $(CFLAGS) -c -o $@ $(realpath $<) -lm  
cebarobot commented 11 months ago

请提供您编译的源代码文件和报错信息。 Please provide the source code files you tried to compile and the error messages.

menglinhan commented 11 months ago

报错信息如下: Error Messages:

riscv64-linux-gnu-ld: ****/xs-env-master/nexus-am/apps/whetstone/whetstone.c:239: undefined reference to `sin'
riscv64-linux-gnu-ld: ****/xs-env-master/nexus-am/apps/whetstone/whetstone.c:240: undefined reference to `cos'
riscv64-linux-gnu-ld: ****/xs-env-master/nexus-am/apps/whetstone/whetstone.c:240: undefined reference to `cos'

使用的源代码在这个位置: Using source code from here: https://github.com/mollybuild/RISCV-Measurement/blob/master/Benchmarks/Whetstone/whetstone.c

cebarobot commented 11 months ago

我不确定您是如何使用 nexus-am 编译 whetstone 的,请提供更多有关您如何移植 whetstone 至 nexus-am 框架的信息。 但值得一提的是,nexus-am 在通过 make 生成内存镜像 bin 文件时,编译和链接是分开完成的。您可能需要在 LDFLAGS 或相关参数中添加 -lm

[TRANSLATION] I'm not sure how you compile Whetstone using nexus-am. Please provide more information on how you ported Whetstone to the nexus-am framework. However, it's worth noting that in nexus-am, when generating a memory image bin file through 'make', compilation and linking are performed separately. You might need to add -lm in LDFLAGS or related parameters during the process.

chenguokai commented 11 months ago

建议您使用工具链提供的gcc直接编译含数学函数的最小测试用例,如果gcc -lm能够正常编译,那么工具链没有问题。应用程序的移植问题是另一个独立的问题,我们无法提供相关支持,您需要自行解决。

You should try compiling a minimal test case with math functions using gcc provided by the toolchain. If gcc -lm compiles well, the toolchain should be fine. Porting applications to nexus-am is another issue that should be resolved yourself.

menglinhan commented 11 months ago

关于LDFLAGS后加-lm,编译出现问题。 好的,那这些问题我自己这边会继续看的,多谢你们的支持。 最后我想问一下,你们有使用过cos,log这些函数用指定的编译器编译吗?

[TRANSLATION] Regarding adding -lm after LDFLAGS, I encountered some issues during compilation. Okay, I'll continue to investigate these issues on my end. Thank you for your support. Lastly, I wanted to ask if you've used cos, log, or similar functions compiled with a specific compiler?

cebarobot commented 11 months ago

我们有用过 riscv64 的工具链编译 cos、log 等数学函数,他们能正常工作。 We have used the riscv64 toolchain to compile mathematical functions like cos and log, and they work properly.

menglinhan commented 11 months ago

好的,多谢

menglinhan commented 11 months ago

方便给一下你们安装的riscv64的开源链接吗?我也安装一个相同的 [TRANSLATION] Could you please provide the open-source link for the RISC-V64 toolchain that you've installed? I'd like to install the same one.

cebarobot commented 11 months ago

方便给一下你们安装的riscv64的开源链接吗?我也安装一个相同的 [TRANSLATION] Could you please provide the open-source link for the RISC-V64 toolchain that you've installed? I'd like to install the same one.

请参考:https://xiangshan-doc.readthedocs.io/zh-cn/latest/compiler/gnu_toolchain/ Please refer to https://xiangshan-doc.readthedocs.io/zh-cn/latest/compiler/gnu_toolchain/

请注意,RISC-V 工具链不由香山提供,香山也无法提供任何支持。 Please note that the RISC-V toolchain is not provided by XiangShan, and XiangShan cannot offer any support regarding it.

menglinhan commented 11 months ago

好的,多谢支持