@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.10)
2
2
project (hiprt)
3
3
4
4
# Options
5
- option (BAKE_KERNEL "enable the use of encrypted and baked kernels" OFF )
5
+ option (BAKE_KERNEL "Enable the use of encrypted and baked kernels" OFF )
6
6
option (BITCODE "Enable bitcode linking" OFF )
7
7
option (PRECOMPILE "Precompile kernels" OFF )
8
8
option (HIPRTEW "Use hiprtew" OFF )
@@ -31,6 +31,9 @@ add_definitions(-DGTEST_HAS_TR1_TUPLE=0)
31
31
32
32
33
33
34
+
35
+
36
+
34
37
# Functions
35
38
function (copy_dir src_dir dst_dir pattern)
36
39
file (GLOB_RECURSE files "${src_dir} /${pattern} " )
@@ -252,8 +255,13 @@ endif()
252
255
add_definitions (-D__USE_HIP__)
253
256
254
257
258
+ # this define is to identify that we are on the public repository of HIPRT.
259
+ # it helps AMD to maintain both a public and a private repo for experimentation.
260
+ add_definitions (-DHIPRT_PUBLIC_REPO)
261
+
262
+
255
263
# Enable CUDA if possible
256
- include (${CMAKE_SOURCE_DIR } /contrib/Orochi/Orochi/enable_cuew.cmake)
264
+ include (${CMAKE_CURRENT_SOURCE_DIR } /contrib/Orochi/Orochi/enable_cuew.cmake)
257
265
258
266
259
267
@@ -282,8 +290,8 @@ endif()
282
290
283
291
# Write version info
284
292
set (version_str_ "UNDEF" )
285
- write_version_info("${CMAKE_SOURCE_DIR } /hiprt/hiprt.h.in" "${CMAKE_SOURCE_DIR } /hiprt/hiprt.h" "${CMAKE_SOURCE_DIR } /version.txt" version_str_)
286
- write_version_info("${CMAKE_SOURCE_DIR } /hiprt/hiprtew.h.in" "${CMAKE_SOURCE_DIR } /hiprt/hiprtew.h" "${CMAKE_SOURCE_DIR } /version.txt" version_str_)
293
+ write_version_info("${CMAKE_CURRENT_SOURCE_DIR } /hiprt/hiprt.h.in" "${CMAKE_CURRENT_SOURCE_DIR } /hiprt/hiprt.h" "${CMAKE_CURRENT_SOURCE_DIR } /version.txt" version_str_)
294
+ write_version_info("${CMAKE_CURRENT_SOURCE_DIR } /hiprt/hiprtew.h.in" "${CMAKE_CURRENT_SOURCE_DIR } /hiprt/hiprtew.h" "${CMAKE_CURRENT_SOURCE_DIR } /version.txt" version_str_)
287
295
288
296
289
297
set (HIPRT_NAME "hiprt${version_str_} " )
@@ -321,13 +329,13 @@ endif()
321
329
if (PRECOMPILE)
322
330
execute_process (
323
331
COMMAND python compile.py --nvidia --hipSdkPath ${HIP_PATH}
324
- WORKING_DIRECTORY ${CMAKE_SOURCE_DIR } /scripts/bitcodes
332
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR } /scripts/bitcodes
325
333
)
326
334
327
335
if (NOT NO_UNITTEST)
328
336
execute_process (
329
337
COMMAND python precompile_bitcode.py --nvidia --hipSdkPath ${HIP_PATH}
330
- WORKING_DIRECTORY ${CMAKE_SOURCE_DIR } /scripts/bitcodes
338
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR } /scripts/bitcodes
331
339
)
332
340
endif ()
333
341
@@ -337,32 +345,46 @@ endif()
337
345
if (BAKE_KERNEL OR GENERATE_BAKE_KERNEL)
338
346
message (">> BakeKernel Executed" )
339
347
if (WIN32 )
340
- execute_process (COMMAND mkdir -p ${CMAKE_SOURCE_DIR} /hiprt/cache )
341
- execute_process (COMMAND ${CMAKE_SOURCE_DIR} /tools/bakeKernel.bat)
348
+ execute_process (
349
+ COMMAND mkdir -p ${CMAKE_CURRENT_SOURCE_DIR} /hiprt/cache
350
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
351
+ )
352
+ execute_process (
353
+ COMMAND ${CMAKE_CURRENT_SOURCE_DIR} /tools/bakeKernel.bat
354
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
355
+ )
342
356
else ()
343
- execute_process (COMMAND mkdir -p ${CMAKE_SOURCE_DIR} /hiprt/cache )
344
- execute_process (COMMAND ${CMAKE_SOURCE_DIR} /tools/bakeKernel.sh)
357
+ execute_process (
358
+ COMMAND mkdir -p ${CMAKE_CURRENT_SOURCE_DIR} /hiprt/cache
359
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
360
+ )
361
+ execute_process (
362
+ COMMAND ${CMAKE_CURRENT_SOURCE_DIR} /tools/bakeKernel.sh
363
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
364
+ )
345
365
endif ()
346
366
347
- if (BAKE_KERNEL)
348
- target_compile_definitions (${HIPRT_NAME} PRIVATE HIPRT_LOAD_FROM_STRING ORO_PP_LOAD_FROM_STRING)
349
- endif ()
350
-
351
367
target_compile_definitions (${HIPRT_NAME} PRIVATE HIPRT_BAKE_KERNEL_GENERATED)
352
-
368
+
369
+ endif ()
370
+
371
+ if (BAKE_KERNEL)
372
+ target_compile_definitions (${HIPRT_NAME} PRIVATE HIPRT_LOAD_FROM_STRING ORO_PP_LOAD_FROM_STRING)
353
373
endif ()
354
374
375
+
376
+
355
377
if (WIN32 )
356
378
target_link_libraries (${HIPRT_NAME} version )
357
379
endif ()
358
380
359
381
360
- target_include_directories (${HIPRT_NAME} PRIVATE ${CMAKE_SOURCE_DIR } )
361
- target_include_directories (${HIPRT_NAME} PRIVATE ${CMAKE_SOURCE_DIR } /contrib/Orochi)
382
+ target_include_directories (${HIPRT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR } )
383
+ target_include_directories (${HIPRT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR } /contrib/Orochi)
362
384
363
- file (GLOB_RECURSE hiprt_sources "${CMAKE_SOURCE_DIR } /hiprt/*.h" "${CMAKE_SOURCE_DIR } /hiprt/*.cpp" "${CMAKE_SOURCE_DIR } /hiprt/*.inl" )
385
+ file (GLOB_RECURSE hiprt_sources "${CMAKE_CURRENT_SOURCE_DIR } /hiprt/*.h" "${CMAKE_CURRENT_SOURCE_DIR } /hiprt/*.cpp" "${CMAKE_CURRENT_SOURCE_DIR } /hiprt/*.inl" )
364
386
list (FILTER hiprt_sources EXCLUDE REGEX "hiprt/bitcodes/.*" )
365
- file (GLOB_RECURSE orochi_sources "${CMAKE_SOURCE_DIR } /contrib/Orochi/Orochi/*.h" "${CMAKE_SOURCE_DIR } /contrib/Orochi/Orochi/*.cpp" "${CMAKE_SOURCE_DIR } /contrib/Orochi/contrib/cuew/*.h" "${CMAKE_SOURCE_DIR } /contrib/Orochi/contrib/cuew/*.cpp" "${CMAKE_SOURCE_DIR } /contrib/Orochi/contrib/hipew/*.h" "${CMAKE_SOURCE_DIR } /contrib/Orochi/contrib/hipew/*.cpp" "${CMAKE_SOURCE_DIR } /contrib/Orochi/ParallelPrimitives/*.h" "${CMAKE_SOURCE_DIR } /contrib/Orochi/ParallelPrimitives/*.cpp" )
387
+ file (GLOB_RECURSE orochi_sources "${CMAKE_CURRENT_SOURCE_DIR } /contrib/Orochi/Orochi/*.h" "${CMAKE_CURRENT_SOURCE_DIR } /contrib/Orochi/Orochi/*.cpp" "${CMAKE_CURRENT_SOURCE_DIR } /contrib/Orochi/contrib/cuew/*.h" "${CMAKE_CURRENT_SOURCE_DIR } /contrib/Orochi/contrib/cuew/*.cpp" "${CMAKE_CURRENT_SOURCE_DIR } /contrib/Orochi/contrib/hipew/*.h" "${CMAKE_CURRENT_SOURCE_DIR } /contrib/Orochi/contrib/hipew/*.cpp" "${CMAKE_CURRENT_SOURCE_DIR } /contrib/Orochi/ParallelPrimitives/*.h" "${CMAKE_CURRENT_SOURCE_DIR } /contrib/Orochi/ParallelPrimitives/*.cpp" )
366
388
target_sources (${HIPRT_NAME} PRIVATE ${hiprt_sources} ${orochi_sources} )
367
389
368
390
@@ -375,10 +397,20 @@ target_sources(${HIPRT_NAME} PRIVATE ${hiprt_sources} ${orochi_sources})
375
397
install (TARGETS ${HIPRT_NAME} DESTINATION bin)
376
398
377
399
# add header files
378
- file (GLOB HIPRT_HEADERS "${CMAKE_SOURCE_DIR } /hiprt/*.h" )
400
+ file (GLOB HIPRT_HEADERS "${CMAKE_CURRENT_SOURCE_DIR } /hiprt/*.h" )
379
401
install (FILES ${HIPRT_HEADERS}
380
402
DESTINATION include /hiprt)
381
403
404
+ # add header files from implementation folder
405
+ file (GLOB HIPRT_IMPL_HEADERS "${CMAKE_CURRENT_SOURCE_DIR} /hiprt/impl/*.h" )
406
+ install (FILES ${HIPRT_IMPL_HEADERS}
407
+ DESTINATION include /hiprt/impl)
408
+
409
+ # add some header files from Orochi
410
+ file (GLOB HIPRT_ORO_HEADERS "${CMAKE_CURRENT_SOURCE_DIR} /contrib/Orochi/ParallelPrimitives/*.h" )
411
+ install (FILES ${HIPRT_ORO_HEADERS}
412
+ DESTINATION include /contrib/Orochi/ParallelPrimitives)
413
+
382
414
# add hipfb files
383
415
file (GLOB HIPRT_HIPFB_FILES "${BASE_OUTPUT_DIR} /${CMAKE_BUILD_TYPE} /*.hipfb" )
384
416
install (FILES ${HIPRT_HIPFB_FILES}
@@ -407,40 +439,40 @@ if(NOT NO_UNITTEST)
407
439
endif ()
408
440
409
441
410
- target_include_directories (unittest PRIVATE ${CMAKE_SOURCE_DIR } ${CMAKE_SOURCE_DIR } /contrib/Orochi)
442
+ target_include_directories (unittest PRIVATE ${CMAKE_CURRENT_SOURCE_DIR } ${CMAKE_CURRENT_SOURCE_DIR } /contrib/Orochi)
411
443
target_link_libraries (unittest PRIVATE ${HIPRT_NAME} )
412
444
413
445
if (UNIX )
414
446
target_link_libraries (unittest PRIVATE pthread dl)
415
447
endif ()
416
448
417
- file (GLOB_RECURSE unittest_sources "${CMAKE_SOURCE_DIR } /test/hiprtT*.h" "${CMAKE_SOURCE_DIR } /test/hiprtT*.cpp" "${CMAKE_SOURCE_DIR } /test/shared.h" "${CMAKE_SOURCE_DIR } /test/main.cpp" "${CMAKE_SOURCE_DIR } /test/CornellBox.h" "${CMAKE_SOURCE_DIR } /test/kernels/*.h" "${CMAKE_SOURCE_DIR } /contrib/gtest-1.6.0/gtest-all.cc" )
449
+ file (GLOB_RECURSE unittest_sources "${CMAKE_CURRENT_SOURCE_DIR } /test/hiprtT*.h" "${CMAKE_CURRENT_SOURCE_DIR } /test/hiprtT*.cpp" "${CMAKE_CURRENT_SOURCE_DIR } /test/shared.h" "${CMAKE_CURRENT_SOURCE_DIR } /test/main.cpp" "${CMAKE_CURRENT_SOURCE_DIR } /test/CornellBox.h" "${CMAKE_CURRENT_SOURCE_DIR } /test/kernels/*.h" "${CMAKE_CURRENT_SOURCE_DIR } /contrib/gtest-1.6.0/gtest-all.cc" )
418
450
419
451
420
452
target_sources (unittest PRIVATE ${unittest_sources} ${orochi_sources} )
421
453
422
- target_include_directories (unittest PRIVATE ${CMAKE_SOURCE_DIR } /contrib/gtest-1.6.0 ${CMAKE_SOURCE_DIR } /contrib/embree/include )
454
+ target_include_directories (unittest PRIVATE ${CMAKE_CURRENT_SOURCE_DIR } /contrib/gtest-1.6.0 ${CMAKE_CURRENT_SOURCE_DIR } /contrib/embree/include )
423
455
424
456
425
457
if (WIN32 )
426
458
427
459
# Use target_link_directories to specify additional library directories
428
- target_link_directories (unittest PRIVATE ${CMAKE_SOURCE_DIR } /contrib/embree/win)
429
- target_link_directories (unittest PRIVATE ${CMAKE_SOURCE_DIR } /contrib/bin/win64)
460
+ target_link_directories (unittest PRIVATE ${CMAKE_CURRENT_SOURCE_DIR } /contrib/embree/win)
461
+ target_link_directories (unittest PRIVATE ${CMAKE_CURRENT_SOURCE_DIR } /contrib/bin/win64)
430
462
431
- copy_dir(${CMAKE_SOURCE_DIR } /contrib/embree/win ${CMAKE_SOURCE_DIR } /dist/bin/Release "*.dll" )
432
- copy_dir(${CMAKE_SOURCE_DIR } /contrib/embree/win ${CMAKE_SOURCE_DIR } /dist/bin/Debug "*.dll" )
433
- copy_dir(${CMAKE_SOURCE_DIR } /contrib/Orochi/contrib/bin/win64 ${CMAKE_SOURCE_DIR } /dist/bin/Release "*.dll" )
434
- copy_dir(${CMAKE_SOURCE_DIR } /contrib/Orochi/contrib/bin/win64 ${CMAKE_SOURCE_DIR } /dist/bin/Debug "*.dll" )
463
+ copy_dir(${CMAKE_CURRENT_SOURCE_DIR } /contrib/embree/win ${CMAKE_CURRENT_SOURCE_DIR } /dist/bin/Release "*.dll" )
464
+ copy_dir(${CMAKE_CURRENT_SOURCE_DIR } /contrib/embree/win ${CMAKE_CURRENT_SOURCE_DIR } /dist/bin/Debug "*.dll" )
465
+ copy_dir(${CMAKE_CURRENT_SOURCE_DIR } /contrib/Orochi/contrib/bin/win64 ${CMAKE_CURRENT_SOURCE_DIR } /dist/bin/Release "*.dll" )
466
+ copy_dir(${CMAKE_CURRENT_SOURCE_DIR } /contrib/Orochi/contrib/bin/win64 ${CMAKE_CURRENT_SOURCE_DIR } /dist/bin/Debug "*.dll" )
435
467
436
468
# Explicitly link libraries from contrib/embree/win and contrib/bin/win64
437
- target_link_libraries (unittest PRIVATE ${CMAKE_SOURCE_DIR } /contrib/embree/win/embree4.lib)
469
+ target_link_libraries (unittest PRIVATE ${CMAKE_CURRENT_SOURCE_DIR } /contrib/embree/win/embree4.lib)
438
470
439
471
endif ()
440
472
441
473
442
474
if (UNIX )
443
- target_link_directories (unittest PRIVATE ${CMAKE_SOURCE_DIR } /contrib/embree/linux)
475
+ target_link_directories (unittest PRIVATE ${CMAKE_CURRENT_SOURCE_DIR } /contrib/embree/linux)
444
476
endif ()
445
477
446
478
target_link_libraries (unittest PRIVATE embree4 tbb)
@@ -458,15 +490,15 @@ if(HIPRTEW)
458
490
target_link_libraries (hiprtewtest PRIVATE version )
459
491
endif ()
460
492
461
- target_include_directories (hiprtewtest PRIVATE ${CMAKE_SOURCE_DIR } ${CMAKE_SOURCE_DIR } /contrib/Orochi)
493
+ target_include_directories (hiprtewtest PRIVATE ${CMAKE_CURRENT_SOURCE_DIR } ${CMAKE_CURRENT_SOURCE_DIR } /contrib/Orochi)
462
494
if (UNIX )
463
495
target_link_libraries (hiprtewtest PRIVATE pthread dl)
464
496
endif ()
465
497
466
- file (GLOB_RECURSE hiprtewtest_sources "${CMAKE_SOURCE_DIR } /test/hiprtewTest.h" "${CMAKE_SOURCE_DIR } /test/hiprtewTest.cpp" "${CMAKE_SOURCE_DIR } /contrib/gtest-1.6.0/gtest-all.cc" )
498
+ file (GLOB_RECURSE hiprtewtest_sources "${CMAKE_CURRENT_SOURCE_DIR } /test/hiprtewTest.h" "${CMAKE_CURRENT_SOURCE_DIR } /test/hiprtewTest.cpp" "${CMAKE_CURRENT_SOURCE_DIR } /contrib/gtest-1.6.0/gtest-all.cc" )
467
499
target_sources (hiprtewtest PRIVATE ${hiprtewtest_sources} ${orochi_sources} )
468
500
469
- target_include_directories (hiprtewtest PRIVATE ${CMAKE_SOURCE_DIR } /contrib/gtest-1.6.0)
501
+ target_include_directories (hiprtewtest PRIVATE ${CMAKE_CURRENT_SOURCE_DIR } /contrib/gtest-1.6.0)
470
502
471
503
target_compile_definitions (hiprtewtest PRIVATE GTEST_HAS_TR1_TUPLE=0)
472
504
endif ()
0 commit comments