Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Support Windows x86 & x64 #2

Open
Xemorph opened this issue Aug 26, 2021 · 5 comments
Open

[Feature] Support Windows x86 & x64 #2

Xemorph opened this issue Aug 26, 2021 · 5 comments

Comments

@Xemorph
Copy link

Xemorph commented Aug 26, 2021

Hello,
@Dr-Noob , you might know me already. I was so kind and built the source code under Windows and provide here the 64Bit and 32Bit variant.

Of course I would like to share my experiences with you. CUDA & NVML can only be compiled under Windows with Microsoft's BuildTools (aka MSVC); MinGW doesn't seem to support Nvidia's libraries … Therefore I have rebuilt the source code a bit and compiled it so far and tested it myself (see photo).

For further questions I am at your disposal.

image


HowTo use gpufetch under Windows

  1. 64 bit:
    Unpack the 64 bit archive and execute gpufetch. Be aware that the DLL is required!

  2. 32 bit:
    Currently, Nvidia's libraries do not support 32 bit Windows architecture.


A big thank you to @Dr-Noob for developing such great tools & improving them more and more

gpufetch_x64.zip

@Dr-Noob
Copy link
Owner

Dr-Noob commented Aug 26, 2021

Thank you very much for your time, Xemorph.

First of all, my first idea with gpufetch was to make it work with different GPUs (NVIDIA, AMD, iGPU, ARM, etc) and then start working with the OS compatibility. That said, I was also interested in making gpufetch work in Windows ASAP since I was interested in running the program on some PCs with windows.

What changes did you make to the source code/Makefile to make it build with MSVC? I will look at the changes and I'll make a decision, but I will need time because I have never worked with MSVC so far.

PS: Nice GPU btw!

@Xemorph
Copy link
Author

Xemorph commented Aug 26, 2021

Hi,
first of all many thanks for the compliments :) I must confess that I have not touched the Makefile at first at all … I know that Microsoft supports Makefiles with their tool NMake, but I also know that there were always problems between GNUMake & NMake.

I didn't change too much. The huge if-else code blocks in uarch.cpp and pci.cpp I had to replace with a switch-case, because Microsoft doesn't allow more than 128 nestings and every else-if block counts twice … And no, you can't suppress this error.
Otherwise I just added getopt.c & getopt.h again, because of course they don't exist under Windows.

I'll try to list the changes here later, maybe I'll have a working Makefile together by then.

I still have a brand new AMD graphics card, to be exact: PowerColor Liquid Devil 6800XT, lying around 🤣 I could support you with the AMD port.

@Xemorph
Copy link
Author

Xemorph commented Aug 26, 2021

I did a bit of web searching and looked at how NMake files are written. I can only recommend one: Keep your hands off NMake.

As an example, I've included the contents of the NMake file. You can use this NMake file to compile gpufetch on Windows.

# Define macros
CXX = $(CXX)
CUDA_PATH = $(CUDA_PATH)

CXXFLAGS     = /EHsc /Wall /W4 /WL /TD
SANITY_FLAGS = /O2 /std:c++17 /nologo
INCLUDES = /I $(CUDA_PATH)/common/inc /I $(CUDA_PATH)/include
LINK_FLAGS =

# Paths
SRC_COMMON = src/common/
SRC_CUDA   = src/cuda/
# Common source files
COMMON_SRC = $(SRC_COMMON)main.cpp $(SRC_COMMON)getopt.c  $(SRC_COMMON)gpu.cpp $(SRC_COMMON)args.cpp $(SRC_COMMON)global.cpp $(SRC_COMMON)printer.cpp
COMMON_HDR = $(SRC_COMMON)ascii.hpp $(SRC_COMMON)getopt.h $(SRC_COMMON)gpu.hpp $(SRC_COMMON)args.hpp $(SRC_COMMON)global.hpp $(SRC_COMMON)printer.hpp

# CUDA source files
CUDA_SRC = $(SRC_CUDA)cuda.cpp $(SRC_CUDA)uarch.cpp $(SRC_CUDA)pci.cpp $(SRC_CUDA)nvmlb.cpp
CUDA_HDR = $(SRC_CUDA)cuda.hpp $(SRC_CUDA)uarch.hpp $(SRC_CUDA)pci.hpp $(SRC_CUDA)nvmlb.hpp $(SRC_CUDA)chips.hpp

SOURCE = $(COMMON_SRC) $(CUDA_SRC)
HEADERS = $(COMMON_HDR) $(CUDA_HDR)

EXECUTABLE_NAME=gpufetch_x64_windows.exe



!IF "$(OS)" == "Windows_NT"
!IF "$(PROCESSOR_ARCHITEW6432)" == "AMD64"
# Use 64 bit
LINK_FLAGS = /LIBPATH:$(CUDA_PATH)/lib/x64 cudart.lib nvml.lib
!ELSE
!IF "$(PROCESSOR_ARCHITECTURE)" == "AMD64"
#Use 64 bit
LINK_FLAGS = /LIBPATH:$(CUDA_PATH)/lib/x64 cudart.lib nvml.lib
!ENDIF
!IF "$(PROCESSOR_ARCHITECTURE)" == "x86"
#Use 32 bit
#LINK_FLAGS += /LIBPATH:$(CUDA_PATH)/lib/Win32
#$(warning Unsupported arch detected: $(PROCESSOR_ARCHITECTURE).)
#$(warning Hold up! You are using a Windows 32 bit architecture, unfortunately we cannot offer this through third parties.)
#$(error Aborting compilation)
!ENDIF
!ENDIF
!ENDIF

$(EXECUTABLE_NAME) : $(SOURCE) $(HEADERS)
	$(CXX) $(CXXFLAGS) $(SANITY_FLAGS) $(INCLUDES) $(SOURCE) /link /MACHINE:X64 $(LINK_FLAGS) /OUT:$(EXECUTABLE_NAME)

# build application
gpufetch: $(EXECUTABLE_NAME)

all: gpufetch

@Dr-Noob
Copy link
Owner

Dr-Noob commented Aug 29, 2021

I have been working on this, and the first thing I wanted to try, before looking at the work you did, is to check why MinGW does not work with CUDA. So I tried to compile gpufetch with MinGW, and it worked. I don't know why you assumed that it did not work, but it does. At least, with my changes, it compiles and runs perfectly.

I had a problem when linking against cudart because the compiler complained that there were undefined references to CUDA stuff. I was compiling against cudart.lib files, which do not contain the lib but a reference to a .dll. I don't know much about windows compiling so I just compiled against the .dll (cudart64_110.dll) directly, and it worked.

I'm not going to upload the Makefile yet since it's a bit hacky and I want to remove the NVML dependency first. But the thing is, MinGW works with CUDA. So I don't think that I will make any changes to the project to make it compile with MSVC since it works with MinGW (although changes have to be made).

@Xemorph
Copy link
Author

Xemorph commented Aug 30, 2021

I apologize for my stubborn statement about MinGW & CUDA. The tool NVCC (Nvidia CUDA Compiler) works under Windows only with CL (MSVC), Nvidia has already said often enough that they do not plan to support MinGW.

I didn't even try to compile the project with MinGW, instead I went directly to MSVC. Proper shader programming / complex 3D models should not work with MinGW (according to Nvidia), because they need be compiled with NVCC.

The goal should really be to remove unnecessary dependencies & support AMD GPUs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants