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

[HIPIFY] compile texture_driver #1029

Closed
ywj55555 opened this issue Sep 19, 2023 · 5 comments
Closed

[HIPIFY] compile texture_driver #1029

ywj55555 opened this issue Sep 19, 2023 · 5 comments
Assignees
Labels
CUDA CUDA-related question Further information is requested

Comments

@ywj55555
Copy link

Excuse me, how to compile HIPIFY/tests/unit_tests/samples/2_Cookbook
/11_texture_driver/ this test. Mainly how to compile and generate tex2dKernel.code. Thanks

@emankov emankov self-assigned this Sep 19, 2023
@emankov emankov changed the title compile texture_driver [HIPIFY] compile texture_driver Sep 19, 2023
@emankov emankov added question Further information is requested CUDA CUDA-related labels Sep 19, 2023
@emankov
Copy link
Collaborator

emankov commented Sep 19, 2023

Are you asking about compiling the CUDA source file or the hipified HIP source file?

@ywj55555
Copy link
Author

Hello, file HIPIFY/tests/unit_tests/samples/2_Cookbook/11_texture_driver
/tex2dKernel.cpp, this is the cuda source code from HIP to CUDA. It can be compiled using nvcc, but there is an extern variable in this file: extern texture<float, 2, cudaReadModeElementType> tex; I want to know how to use NVCC or hipcc to compile and generate tex2dKernel .code, thinks.

@ywj55555
Copy link
Author

Hello, file HIPIFY/tests/unit_tests/samples/2_Cookbook/11_texture_driver /tex2dKernel.cpp, this is the cuda source code from HIP to CUDA. It can be compiled using nvcc, but there is an extern variable in this file: extern texture<float, 2, cudaReadModeElementType> tex; I want to know how to use NVCC or hipcc to compile and generate tex2dKernel .code, thinks.

I changed "extern texture<float, 2, cudaReadModeElementType> tex; "in tex2dKernel.cpp to "#if CUDA_VERSION < 12000 texture<float, 2, cudaReadModeElementType> tex;#endif" which is in texture2dDrv.cpp, then delete the definition of the variable tex in texture2dDrv.cpp, and then convert it into a HIP program. Using the hipcc --genco tex2dKernel.cpp -o tex2dKernel .code command to compile successfully, but if using extern variables in tex2dKernel.cpp, I don’t know how to generate tex2dKernel .code. How can I achieve this? Thanks.

@ywj55555
Copy link
Author

The tex variable is not used in texture2dDrv.cpp. texture2dDrv.cpp only obtains tex in the form of a string through cuModuleGetTexRef(&texref, Module, "tex"); therefore, should the declaration and definition of tex be placed in tex2dKernel. cpp file? Thanks.

@emankov
Copy link
Collaborator

emankov commented Sep 25, 2023

It is unclear, why you want to compile this particular hipify-clang unit test, which is dedicated to internal hipification testing only, and doesn't even have an entry point.

Anyway, you may do it by the following additional steps:

  1. Add an entry point to the tex2dKernel.cpp, for instance:
int main(int argc, char** argv) {
  float out = 0.f;
  tex2dKernel<<<512, 512>>>(&out, 128, 128);
  return 0;
}
  1. Compile the tex2dKernel.cpp by nvcc < 12.0.0 (because of the deleted texture support in CUDA 12.0):

    a) without additional options to obtain executable;
    b) with --cubin to generate a Cubin from PTX intermediate file;
    c) with --fatbin to generate a Fat binary from the source.

or:

  1. Hipify the changed tex2dKernel.cpp source by hipify-clang.
  2. Compile the hipified tex2dKernel.cpp.hip either by hipcc script or directly by clang.

@emankov emankov closed this as completed Sep 25, 2023
emankov added a commit to emankov/HIPIFY that referenced this issue Sep 25, 2023
+ Added an entry point to the test source
+ [Reason] hipify-clang outer users are trying to compile hipify-clang unit tests
+ [ToDo][long-term]
  - Segregate compilable tests
  - Start to compile the segregated tests (after hipification) on a regular basis
  - Mark explicitly the rest of the non-compilable tests as synthetic (dedicated for hipification testing only)
  [very-long-term]
  - Run the successfully hipified and compiled tests on:
    -- AMD GPU
    -- NVIDIA GPU
emankov added a commit that referenced this issue Sep 25, 2023
[HIPIFY][#1029][tests] Updated the `tex2dKernel` test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CUDA CUDA-related question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants