1 # Intellij and Clion
2
3 ----
4 * [Contents](hat-00.md)
5 * Build Babylon and HAT
6 * [Quick Install](hat-01-quick-install.md)
7 * [Building Babylon with jtreg](hat-01-02-building-babylon.md)
8 * [Building HAT with jtreg](hat-01-03-building-hat.md)
9 * [Enabling the NVIDIA CUDA Backend](hat-01-05-building-hat-for-cuda.md)
10 * [Testing Framework](hat-02-testing-framework.md)
11 * [Running Examples](hat-03-examples.md)
12 * [HAT Programming Model](hat-03-programming-model.md)
13 * Interface Mapping
14 * [Interface Mapping Overview](hat-04-01-interface-mapping.md)
15 * [Cascade Interface Mapping](hat-04-02-cascade-interface-mapping.md)
16 * Development
17 * [Project Layout](hat-01-01-project-layout.md)
18 * Implementation Details
19 * [Walkthrough Of Accelerator.compute()](hat-accelerator-compute.md)
20 * [How we minimize buffer transfers](hat-minimizing-buffer-transfers.md)
21 * [Running HAT with Docker on NVIDIA GPUs](hat-07-docker-build-nvidia.md)
22 ---
23
24 ## Intellij and Clion
25
26 We can use JetBrains' `IntelliJ` and `Clion` for dev work and
27 decided to leave some project artifacts in the repo.
28
29 Care must be taken with Intellij and Clion
30 as these tools do not play well together,
31 specifically we cannot have `Clion` and `Intellij`
32 project artifacts rooted under each other or in the same dir.
33
34 ### Intellij
35 The `intellij` subdir under the root HAT directory
36 contains the `.idea` project dir and the various `*.iml` files
37 for each of the various `modules`
38 (note the use of `Intellji`'s meaning of the word of module here)
39
40 As you will note the `intellij` dir is somewhat self contained. the various `*.iml`
41 files refer to the source dirs using relative paths.
42
43 I tend to add `Intellij` modules by hand. There are gotchas ;)
44
45 As with every intellij project, `.idea/modules.xml` 'points' to the iml files for each module (intellij's notion of module ;) )
46 ```xml
47 <!--
48 └──hat
49 └── intellij
50 └── .idea
51 └── modules.xml
52 -->
53 <modules>
54 <module fileurl="file://$PROJECT_DIR$/hat.iml" />
55 <module fileurl="file://$PROJECT_DIR$/backend_opencl.iml" />
56 <!-- yada yada -->
57 </modules>
58
59 ```
60
61 The various `.iml` files then have relative paths to their source/resource dirs roots.
62
63 ```xml
64 <module type="JAVA_MODULE" version="4">
65 <component name="NewModuleRootManager" inherit-compiler-output="true">
66 <exclude-output />
67 <content url="file://$MODULE_DIR$/../../../hat/src/java">
68 <sourceFolder url="file://$MODULE_DIR$/../../../hat/src/java" isTestSource="false" />
69 </content>
70 <orderEntry type="inheritedJdk" />
71 <orderEntry type="sourceFolder" forTests="false" />
72 <orderEntry type="module" module-name="hat" />
73 </component>
74 </module>
75
76 ```
77
78 Making run configurations available to other developers is probably `a bridge too far`
79
80 But with some careful XML tooling we can make it easier to add 'run configurations'.
81
82 ### How intellij stores run configurations
83
84 I also tend to hand hack run configurations so will leave this here for reference
85
86 ```xml
87 <component name="RunManager" selected="Application.MandelTest">
88 <configuration name="Mandel" type="Application"
89 factoryName="Application" temporary="true"
90 nameIsGenerated="true">
91 <option name="MAIN_CLASS_NAME" value="mandel.Mandel" />
92 <module name="mandel" />
93 <option name="VM_PARAMETERS" value="
94 --enable-preview
95 --add-exports=java.base/java.lang.foreign.mapper=ALL-UNNAMED
96 --patch-module=java.base=$PROJECT_DIR$/out/production/java_base_patch
97 -Djava.lang.foreign.mapper.debug=true" />
98 <extension name="coverage">
99 <pattern>
100 <option name="PATTERN" value="mandel.*" />
101 <option name="ENABLED" value="true" />
102 </pattern>
103 </extension>
104 <method v="2">
105 <option name="Make" enabled="true" />
106 </method>
107 </configuration>
108 <!-- more configs -->
109 </component>
110 ```
111
112 ### Clion
113
114 Thankfully Clion uses cmake, so we get to re-use the CMakeLists.txt in the various backends to build.
115
116 The intent is that these cmake artifacts can be run standalone (using cmake in the appropriate dir),
117 from within Clion and can be used by maven. So the CMakeLists.txt files have some extra variables to
118 help us use them in these three modes.
119
120
121
122