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

make codebase portable #167

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

make codebase portable #167

wants to merge 6 commits into from

Conversation

zeratax
Copy link
Owner

@zeratax zeratax commented Apr 28, 2020

specifically for MSVC and GCC

grafik

specifically for MSVC
@zeratax zeratax added the enhancement New feature or request label Apr 28, 2020
@zeratax zeratax added this to the v2 advanced executor milestone Apr 28, 2020
@zeratax zeratax marked this pull request as draft May 3, 2020 21:51
@zeratax zeratax self-assigned this May 3, 2020
Copy link
Owner Author

@zeratax zeratax left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mostly fine now, but some stuff is weird.
I need another opinion on this

example_saxpy segfaults directly when touching main() which doesn't make much sense for me and since there is no call stack idk how to even begin debugging that
example_program has the same experimental/iterator problem

Comment on lines +63 to +67
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
add_library(yacx STATIC ${SOURCES})
else()
add_library(yacx SHARED ${SOURCES})
endif()
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if we should just stick to STATIC for all compilers?


include_directories(include)
include_directories(include/yacx)
include_directories(${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES})

link_directories("${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}/../lib")
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
link_directories("${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}/../lib/x64")
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks weird, but works? not sure why this is necessary since link_libraries should be enough and is enough for nvrtc

Comment on lines +1 to +16
{
// See https://go.microsoft.com//fwlink//?linkid=834763 for more information about this file.
"configurations": [
{
"name": "x64-Debug",
"generator": "Ninja",
"configurationType": "Debug",
"inheritEnvironments": [ "msvc_x64_x64" ],
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "-v",
"ctestCommandArgs": ""
}
]
}
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe remove this file not sure

@@ -5,7 +5,7 @@ using yacx::loglevel;
int main(int argc, char const *const *const argv) {
yacx::handle_logging_args(argc, argv);

Logger(loglevel::ERROR) << "error message";
Logger(loglevel::ERR) << "error message";
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this sucks so bad, but msvc somewhere does this:

#define ERROR 0

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ich finde das ja sehr witzig, dass das schon vordefiniert ist

@@ -137,7 +137,7 @@ int main() {

// 2B. Set kernel string, header files and compile options
Headers headers;
headers.insert(Header{"cuda_runtime.h"});
// headers.insert(Header{"cuda_runtime.h"});
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm actually really unsure why this was here to begin with?
But I also can't find this file automatically under windows like I can under linux, so I just removed it.

@@ -109,7 +109,7 @@ class Logger {
current_loglevel = severity;
if (current_loglevel <= limit) {
std::stringstream prefix_ss;
prefix_ss << detail::get_color(severity) << get_datetime() << " "
prefix_ss /*<< get_color(severity)*/ << get_datetime() << " "
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not understand the error here, please help @LukasSiefke

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was ist denn die Fehlermeldung?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eh so ein hardcore segfault, weil irg wo bei xstring irg eine funktion out of bounds geht oder so

src/Exception.cpp Show resolved Hide resolved
src/Program.cpp Show resolved Hide resolved
@@ -14,6 +17,7 @@ using yacx::loglevel, yacx::detail::dynop, yacx::detail::opfn;

void yacx::detail::load_op(struct dynop *dest, std::string filename, std::string opSymbolName) {
//open libary
#ifndef _MSC_VER
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not the most elegant solution, but linking libraries is vastly different under windows. we could use something like this: https://github.com/alainfrisch/flexdll

not sure how to properly say "hey these functions don't work under windows" so for now they just do nothing

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@LukasSiefke this is so sad

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sollte wahrscheinlich halt ne not implemented exception werfen oder so

@@ -64,7 +65,7 @@ TEST_CASE("sumArray with implicit size", "[example_program]") {
double epsilon = 1.0E-8;
for (int i = 0; i < nElem; ++i) {
if (abs(hostRef[i] - gpuRef[i]) > epsilon) {
char *error_string;
char *error_string;
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess I should run clang format over this once.

@zeratax
Copy link
Owner Author

zeratax commented May 9, 2020

https://github.com/ZerataX/yacx/pull/167/checks?check_run_id=659121385#step:3:91
I assume this means that it is trying to include the replacement unistd.h?

Edit: yeah it did and I fixed it

@zeratax
Copy link
Owner Author

zeratax commented May 9, 2020

some of the tests also fail, mostly due to:

m_log: cuda_add(1): catastrophic error: cannot open source file "cuda_runtime.h"

where again I wonder if this is actually necessary at all.

Also of course lspci for getting the device name won't work under windows

Not really big stuff

Copy link
Owner Author

@zeratax zeratax left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now all tests pass under windows

Comment on lines +35 to +39
#if defined(_MSC_VER)
std::string name = exec("powershell -command \"wmic path win32_VideoController get name | "
"Select-String -Pattern 'NVIDIA ([a-zA-Z0-9\-]+)' "
"-AllMatches | % { $_.matches.groups[1].value }\"");
#else
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not exactly the same regex pattern, but I really don't remember why I used a lookahead stuff or w/e there. idk seems to work like this.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't think powershell regex supports lookahead/behind

@@ -33,15 +33,13 @@ TEST_CASE(
args.emplace_back(KernelArg(&datasize));

Headers headers;
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess I could have just removed the Headers headers as well, but seems fine to me like this.

@zeratax zeratax marked this pull request as ready for review May 9, 2020 17:00
@zeratax zeratax changed the title [WIP] make codebase portable make codebase portable May 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants