NVIDIA / jitify

A single-header C++ library for simplifying the use of CUDA Runtime Compilation (NVRTC).
BSD 3-Clause "New" or "Revised" License
518 stars 64 forks source link

[Help]How to include <cuda_fp16.h> in jitify? #116

Open FdyCN opened 1 year ago

FdyCN commented 1 year ago

I tried to include in my kernel string like: "#include " or make a header named "JITFP16.cuh" and pass into jitify::Program::program() functions. can't work.

so how can i include these standard header like cuda_fp16.h ???

Please help!

FdyCN commented 1 year ago

i know it can be added in this way:

jitify::Program program = kernel_cache.program(
      program1,                          // Code string specified above
      {example_headers_my_header1_cuh},  // Code string generated by stringify
      {"--use_fast_math", "-I" ${where cuda_fp16.h is}}, file_callback);

howerver, i want to include in "my_header.cuh" because i need to add some operator overloading in my_header.cuh but when i add like this:

#pragma once
// JITFP16_cuh.cuh
const char *const JITFP16_cuh =
    "JITFP16.cuh\n"
    "#pragma once\n"
    "#include \"cuda_fp16.h\"\n"
    "..... some codes";

// called in jitify:
jitify::Program program = kernel_cache.program(
      program1,                          // Code string specified above
      {JITFP16_cuh},  // Code string generated by stringify
      {"--use_fast_math", "-I" ${where cuda_fp16.h is}}, file_callback);

it will come this error :

my_program(2): warning: cuda_fp16.h: [jitify] File not found
---------------------------------------------------
--- JIT compile log for my_program ---
---------------------------------------------------
JITFP16.cuh(4): error: identifier "half" is undefined
JITFP16.cuh(5): error: identifier "half" is undefined
JITFP16.cuh(6): error: identifier "half" is undefined
JITFP16.cuh(7): error: identifier "half" is undefined
JITFP16.cuh(9): error: identifier "half" is undefined
JITFP16.cuh(9): error: identifier "half" is undefined

i don't know how to include in my header and include my header when creating jitify program??or it's impossible?

Please take a look, thanks so much. @benbarsdell

benbarsdell commented 1 year ago

I think this should work, as long as the -I option has the correct path (e.g., "/usr/local/cuda/include"). If it's still not working for you, could you provide a full reproducer for me to try out.

FdyCN commented 1 year ago

I think this should work, as long as the -I option has the correct path (e.g., "/usr/local/cuda/include"). If it's still not working for you, could you provide a full reproducer for me to try out.

i found out the reason. when i add a space before I like this: " -I", then it works. Without the space like "-I", it will be wrong.

@benbarsdell thank you for your reply. BTW, Is jitify still on updating?