<commit_before># Base test definition
# Perform code transformation and compare the output with a reference

set (CPU_DIR __cpu__)
set (GPU_DIR __gpu__)

# Define input and output file name
set (ORIGINAL_FILE ${CMAKE_CURRENT_SOURCE_DIR}/mo_column.f90)
set (OUTPUT_FILE_CPU ${CMAKE_CURRENT_SOURCE_DIR}/${CPU_DIR}/transformed_code_cpu.f90)
set (OUTPUT_FILE_GPU ${CMAKE_CURRENT_SOURCE_DIR}/${GPU_DIR}/transformed_code_gpu.f90)
set (MAIN_CPU ${CMAKE_CURRENT_SOURCE_DIR}/${CPU_DIR}/main.f90)
set (MAIN_GPU ${CMAKE_CURRENT_SOURCE_DIR}/${GPU_DIR}/main.f90)
set (REFERENCE_FILE_CPU ${CMAKE_CURRENT_SOURCE_DIR}/reference_cpu.f90)
set (REFERENCE_FILE_GPU ${CMAKE_CURRENT_SOURCE_DIR}/reference_gpu.f90)

# Define executable file name
set (EXECUTABLE_ORIGINAL original_code_${TEST_NAME})
set (EXECUTABLE_TRANSFORMED_CPU transformed_code_cpu_${TEST_NAME})
set (EXECUTABLE_TRANSFORMED_GPU transformed_code_gpu_${TEST_NAME})

# Define directory for build
set (XMOD_DIR __xmod__)
set (OMNI_TMP_DIR __omni_tmp__)

# Directory where OMNI xmod files will be placed
if (NOT EXISTS ${XMOD_DIR})
  file(MAKE_DIRECTORY ${XMOD_DIR})
endif()

if (NOT EXISTS ${XMOD_DIR})
  file(MAKE_DIRECTORY ${XMOD_DIR})
endif()

if (NOT EXISTS ${CPU_DIR})
  file(MAKE_DIRECTORY ${CPU_DIR})
endif()

if (NOT EXISTS ${GPU_DIR})
  file(MAKE_DIRECTORY ${GPU_DIR})
endif()

# Create intermediate representation in XcodeML Fortran format
if(${TEST_DEBUG}) # with debug option
  set(DEBUG_FLAG --debug)
endif()

add_custom_command(
  OUTPUT  ${MAIN_CPU}
  COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/main.f90 ${MAIN_CPU}
  COMMENT "Copy main.f90 to ${MAIN_CPU}"
)
add_custom_command(
  OUTPUT  ${MAIN_GPU}
  COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/main.f90 ${MAIN_GPU}
  COMMENT "Copy main.f90 to ${MAIN_GPU}"
)

# Execute the CLAW compiler for CPU target
add_custom_command(
  OUTPUT  ${OUTPUT_FILE_CPU}
  COMMAND touch ${ORIGINAL_FILE}
  COMMAND ${CLAWFC} ${OPTIONAL_FLAGS} --target=cpu ${DIRECTIVE_CPU} ${DEBUG_FLAG} -J ${XMOD_DIR} -o ${OUTPUT_FILE_CPU} ${ORIGINAL_FILE}
  WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  DEPENDS ${ORIGINAL_FILE}
  COMMENT "Translating CLAW directive with ${CLAWFC} for CPU target"
)

# Execute the CLAW compiler for GPU target
add_custom_command(
  OUTPUT  ${OUTPUT_FILE_GPU}
  COMMAND touch ${ORIGINAL_FILE}
  COMMAND ${CLAWFC} ${OPTIONAL_FLAGS} --target=gpu ${DIRECTIVE_GPU} ${DEBUG_FLAG} -J ${XMOD_DIR} -o ${OUTPUT_FILE_GPU} ${ORIGINAL_FILE}
  WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  DEPENDS ${ORIGINAL_FILE}
  COMMENT "Translating CLAW directive with ${CLAWFC} for GPU target"
)

# Target for the transformation
add_custom_target(
  transform-${TEST_NAME}
  DEPENDS ${MAIN_CPU} ${OUTPUT_FILE_CPU} ${MAIN_GPU} ${OUTPUT_FILE_GPU} ${EXECUTABLE_ORIGINAL} ${EXECUTABLE_TRANSFORMED_CPU} ${EXECUTABLE_TRANSFORMED_GPU}
)

# Target to clean the generated file (Output of clawfc)
add_custom_target(
  clean-${TEST_NAME}
  COMMAND rm -f ${OUTPUT_FILE_CPU} ${OUTPUT_FILE_GPU}
)

# Add target to the global build/clean target
add_dependencies(${BUILD_TEST_TARGET} transform-${TEST_NAME})
add_dependencies(${CLEAN_TEST_TARGET} clean-${TEST_NAME})

# Define additional compilation flags
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${CLAW_TEST_FFP_FLAGS}")

# Build the original code and the transformed code
add_executable (${EXECUTABLE_ORIGINAL} EXCLUDE_FROM_ALL "${ORIGINAL_FILE}" "main.f90")
add_executable (${EXECUTABLE_TRANSFORMED_CPU} EXCLUDE_FROM_ALL "${OUTPUT_FILE_CPU}" "${CMAKE_CURRENT_SOURCE_DIR}/${CPU_DIR}/main.f90")
target_compile_definitions(${EXECUTABLE_TRANSFORMED_CPU} PRIVATE -D_CLAW)
add_executable (${EXECUTABLE_TRANSFORMED_GPU} EXCLUDE_FROM_ALL "${OUTPUT_FILE_GPU}" "${CMAKE_CURRENT_SOURCE_DIR}/${GPU_DIR}/main.f90")
target_compile_definitions(${EXECUTABLE_TRANSFORMED_GPU} PRIVATE -D_CLAW)

# Set target specific compilation options
if(OPENACC_ENABLE)
  target_compile_options(${EXECUTABLE_TRANSFORMED_GPU} PUBLIC ${OPENACC_FLAGS})
elseif(OPENMP_ENABLE)
  target_compile_options(${EXECUTABLE_TRANSFORMED_GPU} PUBLIC ${OPENMP_FLAGS})
endif()
<commit_msg>Get rid of specific directory for CPU/GPU code<commit_after># Base test definition
# Perform code transformation and compare the output with a reference

# Define input and output file name
set (ORIGINAL_FILE ${CMAKE_CURRENT_SOURCE_DIR}/mo_column.f90)
set (OUTPUT_FILE_CPU ${CMAKE_CURRENT_SOURCE_DIR}/transformed_code_cpu.f90)
set (OUTPUT_FILE_GPU ${CMAKE_CURRENT_SOURCE_DIR}/transformed_code_gpu.f90)
set (REFERENCE_FILE_CPU ${CMAKE_CURRENT_SOURCE_DIR}/reference_cpu.f90)
set (REFERENCE_FILE_GPU ${CMAKE_CURRENT_SOURCE_DIR}/reference_gpu.f90)

# Define executable file name
set (EXECUTABLE_ORIGINAL original_code_${TEST_NAME})
set (EXECUTABLE_TRANSFORMED_CPU transformed_code_cpu_${TEST_NAME})
set (EXECUTABLE_TRANSFORMED_GPU transformed_code_gpu_${TEST_NAME})

# Define directory for build
set (XMOD_DIR __xmod__)
set (OMNI_TMP_DIR __omni_tmp__)

# Directory where OMNI xmod files will be placed
if (NOT EXISTS ${XMOD_DIR})
  file(MAKE_DIRECTORY ${XMOD_DIR})
endif()

# Create intermediate representation in XcodeML Fortran format
if(${TEST_DEBUG}) # with debug option
  set(DEBUG_FLAG --debug)
endif()

# Execute the CLAW compiler for CPU target
add_custom_command(
  OUTPUT  ${OUTPUT_FILE_CPU}
  COMMAND touch ${ORIGINAL_FILE}
  COMMAND ${CLAWFC} ${OPTIONAL_FLAGS} --target=cpu ${DIRECTIVE_CPU} ${DEBUG_FLAG} -J ${XMOD_DIR} -o ${OUTPUT_FILE_CPU} ${ORIGINAL_FILE}
  WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  DEPENDS ${ORIGINAL_FILE}
  COMMENT "Translating CLAW directive with ${CLAWFC} for CPU target"
)

# Execute the CLAW compiler for GPU target
add_custom_command(
  OUTPUT  ${OUTPUT_FILE_GPU}
  COMMAND touch ${ORIGINAL_FILE}
  COMMAND ${CLAWFC} ${OPTIONAL_FLAGS} --target=gpu ${DIRECTIVE_GPU} ${DEBUG_FLAG} -J ${XMOD_DIR} -o ${OUTPUT_FILE_GPU} ${ORIGINAL_FILE}
  WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  DEPENDS ${ORIGINAL_FILE}
  COMMENT "Translating CLAW directive with ${CLAWFC} for GPU target"
)

# Target for the transformation
add_custom_target(
  transform-${TEST_NAME}
  DEPENDS ${MAIN_CPU} ${OUTPUT_FILE_CPU} ${MAIN_GPU} ${OUTPUT_FILE_GPU} ${EXECUTABLE_ORIGINAL} ${EXECUTABLE_TRANSFORMED_CPU} ${EXECUTABLE_TRANSFORMED_GPU}
)

# Target to clean the generated file (Output of clawfc)
add_custom_target(
  clean-${TEST_NAME}
  COMMAND rm -f ${OUTPUT_FILE_CPU} ${OUTPUT_FILE_GPU}
)

# Add target to the global build/clean target
add_dependencies(${BUILD_TEST_TARGET} transform-${TEST_NAME})
add_dependencies(${CLEAN_TEST_TARGET} clean-${TEST_NAME})

# Define additional compilation flags
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${CLAW_TEST_FFP_FLAGS}")

# Build the original code and the transformed code
add_executable (${EXECUTABLE_ORIGINAL} EXCLUDE_FROM_ALL "${ORIGINAL_FILE}" "main.f90")
add_executable (${EXECUTABLE_TRANSFORMED_CPU} EXCLUDE_FROM_ALL "${OUTPUT_FILE_CPU}" "main.f90")
target_compile_definitions(${EXECUTABLE_TRANSFORMED_CPU} PRIVATE -D_CLAW)
add_executable (${EXECUTABLE_TRANSFORMED_GPU} EXCLUDE_FROM_ALL "${OUTPUT_FILE_GPU}" "main.f90")
target_compile_definitions(${EXECUTABLE_TRANSFORMED_GPU} PRIVATE -D_CLAW)

# Set target specific compilation options
if(OPENACC_ENABLE)
  target_compile_options(${EXECUTABLE_TRANSFORMED_GPU} PUBLIC ${OPENACC_FLAGS})
elseif(OPENMP_ENABLE)
  target_compile_options(${EXECUTABLE_TRANSFORMED_GPU} PUBLIC ${OPENMP_FLAGS})
endif()

{'fraction_non_alphanumeric': 0.10683012259194395, 'fraction_numerical': 0.005927522565000673, 'mean_word_length': 7.9338146811070995, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '624409', 'n_tokens_mistral': 2742, 'n_tokens_neox': 2645, 'n_words': 572}