|
| 1 | +//===- compile-minimal-test.c ---------------------------------------------===// |
| 2 | +// |
| 3 | +// Part of Comgr, under the Apache License v2.0 with LLVM Exceptions. See |
| 4 | +// amd/comgr/LICENSE.TXT in this repository for license information. |
| 5 | +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | +// |
| 7 | +//===----------------------------------------------------------------------===// |
| 8 | + |
| 9 | +#include "amd_comgr.h" |
| 10 | +#include "common.h" |
| 11 | +#include <stdio.h> |
| 12 | +#include <stdlib.h> |
| 13 | +#include <string.h> |
| 14 | + |
| 15 | +int main(int argc, char *argv[]) { |
| 16 | + amd_comgr_action_info_t DataAction; |
| 17 | + amd_comgr_(create_action_info(&DataAction)); |
| 18 | + |
| 19 | + // ---- set_language, get_language |
| 20 | + amd_comgr_language_t Language; |
| 21 | + amd_comgr_( |
| 22 | + action_info_set_language(DataAction, AMD_COMGR_LANGUAGE_NONE)); |
| 23 | + amd_comgr_(action_info_get_language(DataAction, &Language)); |
| 24 | + if (Language != AMD_COMGR_LANGUAGE_NONE) |
| 25 | + fail("AMD_COMGR_LANGUAGE_NONE not returned!"); |
| 26 | + |
| 27 | + amd_comgr_( |
| 28 | + action_info_set_language(DataAction, AMD_COMGR_LANGUAGE_OPENCL_1_2)); |
| 29 | + amd_comgr_(action_info_get_language(DataAction, &Language)); |
| 30 | + if (Language != AMD_COMGR_LANGUAGE_OPENCL_1_2) |
| 31 | + fail("AMD_COMGR_LANGUAGE_OPENCL_1_2 not returned!"); |
| 32 | + |
| 33 | + amd_comgr_( |
| 34 | + action_info_set_language(DataAction, AMD_COMGR_LANGUAGE_OPENCL_2_0)); |
| 35 | + amd_comgr_(action_info_get_language(DataAction, &Language)); |
| 36 | + if (Language != AMD_COMGR_LANGUAGE_OPENCL_2_0) |
| 37 | + fail("AMD_COMGR_LANGUAGE_OPENCL_2_0 not returned!"); |
| 38 | + |
| 39 | + amd_comgr_( |
| 40 | + action_info_set_language(DataAction, AMD_COMGR_LANGUAGE_HIP)); |
| 41 | + amd_comgr_(action_info_get_language(DataAction, &Language)); |
| 42 | + if (Language != AMD_COMGR_LANGUAGE_HIP) |
| 43 | + fail("AMD_COMGR_LANGUAGE_HIP not returned!"); |
| 44 | + |
| 45 | + amd_comgr_( |
| 46 | + action_info_set_language(DataAction, AMD_COMGR_LANGUAGE_LLVM_IR)); |
| 47 | + amd_comgr_(action_info_get_language(DataAction, &Language)); |
| 48 | + if (Language != AMD_COMGR_LANGUAGE_LLVM_IR) |
| 49 | + fail("AMD_COMGR_LANGUAGE_LLVM_IR not returned!"); |
| 50 | + |
| 51 | + // ---- set_isa_name, get_isa_name |
| 52 | + // Tested in comgr/test/get_data_isa_name_test.c |
| 53 | + |
| 54 | + // ---- set_option_list, get_option_list_count, get_option_list_item |
| 55 | + const char *Options[] = {"foo", "bar", "bazqux", "aaaaaaaaaaaaaaaaaaaaa"}; |
| 56 | + size_t OptionsCount = sizeof(Options) / sizeof(Options[0]); |
| 57 | + |
| 58 | + amd_comgr_(action_info_set_option_list(DataAction, Options, OptionsCount)); |
| 59 | + |
| 60 | + size_t ActualCount; |
| 61 | + amd_comgr_(action_info_get_option_list_count(DataAction, &ActualCount)); |
| 62 | + |
| 63 | + if (OptionsCount != ActualCount) { |
| 64 | + fail("incorrect option count: expected %zu, saw %zu", OptionsCount, |
| 65 | + ActualCount); |
| 66 | + } |
| 67 | + |
| 68 | + size_t Size; |
| 69 | + for (size_t I = 0; I < OptionsCount; ++I) { |
| 70 | + amd_comgr_(action_info_get_option_list_item(DataAction, I, &Size, NULL)); |
| 71 | + |
| 72 | + char *Option = calloc(Size, sizeof(char)); |
| 73 | + amd_comgr_(action_info_get_option_list_item(DataAction, I, &Size, Option)); |
| 74 | + |
| 75 | + if (strcmp(Options[I], Option)) { |
| 76 | + fail("incorrect option string: expected '%s', saw '%s'", Options[I], |
| 77 | + Option); |
| 78 | + } |
| 79 | + free(Option); |
| 80 | + } |
| 81 | + |
| 82 | + fail_amd_comgr_(action_info_get_option_list_item(DataAction, OptionsCount, |
| 83 | + &Size, NULL)); |
| 84 | + fail_amd_comgr_(action_info_get_option_list_count(DataAction, NULL)); |
| 85 | + fail_amd_comgr_(action_info_get_option_list_item(DataAction, 0, NULL, NULL)); |
| 86 | + |
| 87 | + // ---- set_bundle_entry_ids, get_bundle_entry_id_count, get_bundle_entry_id |
| 88 | + // Tested in comgr/test/unbundle-hip-test.c |
| 89 | + |
| 90 | + // ---- set_working_directory_path, get_working_directory_path |
| 91 | + const char *Path = "/path/to/my/directory"; |
| 92 | + amd_comgr_(action_info_set_working_directory_path(DataAction, Path)); |
| 93 | + |
| 94 | + amd_comgr_(action_info_get_working_directory_path(DataAction, &Size, |
| 95 | + NULL)); |
| 96 | + char *GetPath = calloc(Size, sizeof(char)); |
| 97 | + amd_comgr_(action_info_get_working_directory_path(DataAction, &Size, |
| 98 | + GetPath)); |
| 99 | + |
| 100 | + if (strcmp(Path, GetPath)) |
| 101 | + fail("incorrect path string: expected '%s', saw '%s'", Path, GetPath); |
| 102 | + free(GetPath); |
| 103 | + |
| 104 | + // ---- set_logging, get_logging |
| 105 | + amd_comgr_(action_info_set_logging(DataAction, true)); |
| 106 | + |
| 107 | + bool GetLogging; |
| 108 | + amd_comgr_(action_info_get_logging(DataAction, &GetLogging)); |
| 109 | + |
| 110 | + if (!GetLogging) |
| 111 | + fail("incorrect logging boolean: expected 'true', saw 'false'"); |
| 112 | + |
| 113 | + amd_comgr_(action_info_set_logging(DataAction, false)); |
| 114 | + amd_comgr_(action_info_get_logging(DataAction, &GetLogging)); |
| 115 | + |
| 116 | + if (GetLogging) |
| 117 | + fail("incorrect logging boolean: expected 'false', saw 'true'"); |
| 118 | + |
| 119 | + // ---- set_device_lib_linking |
| 120 | + amd_comgr_(action_info_set_device_lib_linking(DataAction, true)); |
| 121 | + amd_comgr_(action_info_set_device_lib_linking(DataAction, false)); |
| 122 | + |
| 123 | + // ---- set_vfs |
| 124 | + amd_comgr_(action_info_set_vfs(DataAction, true)); |
| 125 | + amd_comgr_(action_info_set_vfs(DataAction, false)); |
| 126 | + |
| 127 | + amd_comgr_(destroy_action_info(DataAction)); |
| 128 | + return 0; |
| 129 | +} |
0 commit comments