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

"mlir-opt: not found" while executing scripts #5

Open
BabaNogdev opened this issue Aug 30, 2024 · 13 comments
Open

"mlir-opt: not found" while executing scripts #5

BabaNogdev opened this issue Aug 30, 2024 · 13 comments

Comments

@BabaNogdev
Copy link

BabaNogdev commented Aug 30, 2024

Hi. I'm trying to run your project on my machine using the Docker image you've provided. I've managed to get the basic setup down, and have gotten around the directory structure of the project.

However, when I'm trying to run the script.sh from the baseline in demo, it shows me the following errors:

script.sh: 2: mlir-opt: not found
script.sh: 5: mlir-opt: not found
script.sh: 8: soda-opt: not found
script.sh: 11: soda-opt: not found
script.sh: 14: soda-opt: not found
script.sh: 17: soda-opt: not found
script.sh: 20: soda-opt: not found
script.sh: 21: soda-opt: not found
script.sh: 24: mlir-translate: not found
script.sh: 25: mlir-translate: not found
script.sh: 28: llc: not found
script.sh: 29: llc: not found

Similar errors occur when I try to run the script4x4.sh file from the MiniLM's baseline folder.

script4x4.sh: 2: mlir-opt: not found
script4x4.sh: 5: mlir-opt: not found
script4x4.sh: 8: soda-opt: not found
script4x4.sh: 11: soda-opt: not found
script4x4.sh: 14: soda-opt: not found
script4x4.sh: 17: soda-opt: not found
script4x4.sh: 20: soda-opt: not found
script4x4.sh: 21: soda-opt: not found
script4x4.sh: 27: mlir-translate: not found
script4x4.sh: 28: mlir-translate: not found
script4x4.sh: 31: llc: not found
script4x4.sh: 32: llc: not found
clang: error: no such file or directory: '11-model-4.o'
clang: error: no such file or directory: '12-accel-4.o'

I understand that mlir-opt and soda-opt are supposed to be in the PATH variable (you've mentioned so in the README.md), which I've tried doing with the following commands:

export PATH=$PATH:/llvm-project/mlir/tools/mlir-opt
export PATH=$PATH:/llvm-project/mlir/test/mlir-opt
export PATH=$PATH:/llvm-project/mlir/lib/Tools/mlir-opt
export PATH=$PATH:/llvm-project/build/bin/mlir-opt
export PATH=$PATH:/llvm-project/mlir/include/mlir/Tools/mlir-opt
export PATH=$PATH:/llvm-project/build/tools/mlir/tools/mlir-opt
export PATH=$PATH:/llvm-project/build/tools/mlir/test/mlir-opt
export PATH=$PATH:/llvm-project/build/tools/mlir/lib/Tools/mlir-opt

export PATH=$PATH:/mlir-cgra/tools/soda-opt
export PATH=$PATH:/mlir-cgra/test/soda-opt
export PATH=$PATH:/mlir-cgra/build/bin/soda-opt
export PATH=$PATH:/mlir-cgra/build/tools/soda-opt
export PATH=$PATH:/mlir-cgra/build/test/soda-opt

Using the echo $PATH, I get this as output:

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/llvm-project/build/bin/mlir-opt:/mlir-cgra/build/bin/soda-opt:/llvm-project/mlir/tools/mlir-opt:/llvm-project/mlir/tools/mlir-opt:/llvm-project/mlir/test/mlir-opt:/llvm-project/mlir/lib/Tools/mlir-opt:/llvm-project/mlir/include/mlir/Tools/mlir-opt:/llvm-project/build/tools/mlir/tools/mlir-opt:/llvm-project/build/tools/mlir/test/mlir-opt:/llvm-project/build/tools/mlir/lib/Tools/mlir-opt:/mlir-cgra/tools/soda-opt:/mlir-cgra/test/soda-opt:/mlir-cgra/build/tools/soda-opt:/mlir-cgra/build/test/soda-opt

And yet, the project refuses to run. I've also tried installing llvm-12-tools within Docker as an added attempt, but it's already there. What am I doing wrong here?

@tancheng
Copy link
Owner

tancheng commented Sep 3, 2024

Hi, please do:

source /setup.sh

The script would setup the environment for you, in my case, echo $PATH shows:

/llvm-project/build/bin:/mlir-cgra/build/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

@BabaNogdev
Copy link
Author

This got rid of the not found errors, but I got a warning now instead with the 04-finalized.mlir in the script.sh of both the baseline and cgra, which is also where the execution stops.

For baseline folder:

04-finalized.mlir:3:3: warning:
  func.func @main_graph(%arg0: memref<16x32xf32>, %arg1: memref<32x16xf32>, %arg2: memref<16x16xf32>, %arg3: memref<16x16xf32>, %arg4: memref<16x16xf32>) attributes {input_names = ["X0", "X1", "X2", "X3"], output_names = ["Z0"]} {
  ^
04-finalized.mlir:3:3: note: see current operation: func.func @main_graph(%arg0: memref<16x32xf32>, %arg1: memref<32x16xf32>, %arg2: memref<16x16xf32>, %arg3: memref<16x16xf32>, %arg4: memref<16x16xf32>) attributes {input_names = ["X0", "X1", "X2", "X3"], output_names = ["Z0"]} {
  %cst = arith.constant 0.000000e+00 : f32
  %0 = memref.alloc() {alignment = 128 : i64} : memref<16x16xf32>
  linalg.fill ins(%cst : f32) outs(%0 : memref<16x16xf32>)
  %1 = memref.alloc() {alignment = 128 : i64} : memref<16x16xf32>
  memref.copy %0, %1 : memref<16x16xf32> to memref<16x16xf32>
  memref.dealloc %0 : memref<16x16xf32>
  linalg.matmul {_internal_linalg_transform_ = "MatmulOpTilable"} ins(%arg0, %arg1 : memref<16x32xf32>, memref<32x16xf32>) outs(%1 : memref<16x16xf32>)
  %2 = memref.alloc() {alignment = 128 : i64} : memref<16x16xf32>
  linalg.generic {indexing_maps = [affine_map<(d0, d1) -> (d0, d1)>, affine_map<(d0, d1) -> (d0, d1)>, affine_map<(d0, d1) -> (d0, d1)>, affine_map<(d0, d1) -> (d0, d1)>], iterator_types = ["parallel", "parallel"]} ins(%1, %arg2, %arg3 : memref<16x16xf32>, memref<16x16xf32>, memref<16x16xf32>) outs(%2 : memref<16x16xf32>) attrs =  {_internal_linalg_transform_ = "GenericOpTilable"} {
  ^bb0(%arg5: f32, %arg6: f32, %arg7: f32, %arg8: f32):
    %3 = arith.addf %arg5, %arg6 : f32
    %4 = arith.maxf %3, %cst : f32
    %5 = arith.addf %4, %arg7 : f32
    linalg.yield %5 : f32
  }
  memref.dealloc %1 : memref<16x16xf32>
  memref.copy %2, %arg4 : memref<16x16xf32> to memref<16x16xf32>
  return
}

For CGRA folder:

04-finalized.mlir:3:3: warning:
  func.func @main_graph(%arg0: memref<16x32xf32>, %arg1: memref<32x16xf32>, %arg2: memref<16x16xf32>, %arg3: memref<16x16xf32>, %arg4: memref<16x16xf32>) attributes {input_names = ["X0", "X1", "X2", "X3"], output_names = ["Z0"]} {
  ^
04-finalized.mlir:3:3: note: see current operation: func.func @main_graph(%arg0: memref<16x32xf32>, %arg1: memref<32x16xf32>, %arg2: memref<16x16xf32>, %arg3: memref<16x16xf32>, %arg4: memref<16x16xf32>) attributes {input_names = ["X0", "X1", "X2", "X3"], output_names = ["Z0"]} {
  %cst = arith.constant 0.000000e+00 : f32
  %0 = memref.alloc() {alignment = 128 : i64} : memref<16x16xf32>
  linalg.fill ins(%cst : f32) outs(%0 : memref<16x16xf32>)
  %1 = memref.alloc() {alignment = 128 : i64} : memref<16x16xf32>
  memref.copy %0, %1 : memref<16x16xf32> to memref<16x16xf32>
  memref.dealloc %0 : memref<16x16xf32>
  linalg.matmul {_internal_linalg_transform_ = "MatmulOpTilable"} ins(%arg0, %arg1 : memref<16x32xf32>, memref<32x16xf32>) outs(%1 : memref<16x16xf32>)
  %2 = memref.alloc() {alignment = 128 : i64} : memref<16x16xf32>
  linalg.generic {indexing_maps = [affine_map<(d0, d1) -> (d0, d1)>, affine_map<(d0, d1) -> (d0, d1)>, affine_map<(d0, d1) -> (d0, d1)>, affine_map<(d0, d1) -> (d0, d1)>], iterator_types = ["parallel", "parallel"]} ins(%1, %arg2, %arg3 : memref<16x16xf32>, memref<16x16xf32>, memref<16x16xf32>) outs(%2 : memref<16x16xf32>) attrs =  {_internal_linalg_transform_ = "GenericOpTilable"} {
  ^bb0(%arg5: f32, %arg6: f32, %arg7: f32, %arg8: f32):
    %3 = arith.addf %arg5, %arg6 : f32
    %4 = arith.maxf %3, %cst : f32
    %5 = arith.addf %4, %arg7 : f32
    linalg.yield %5 : f32
  }
  memref.dealloc %1 : memref<16x16xf32>
  memref.copy %2, %arg4 : memref<16x16xf32> to memref<16x16xf32>
  return
}

From what I understand, this error pertains to an argument passed to a function, and it's the same argument for both warnings. I'm not sure what it is though.

@tancheng
Copy link
Owner

tancheng commented Sep 4, 2024

You mean MiniLM baseline script stop execution due to that warning? Can you cleanup your $PATH and retry?

@BabaNogdev
Copy link
Author

I'm not sure what you mean by cleaning up the $PATH variable. It looks like this currently (after executing setup.sh once):

# Separated by line break for reading convenience.
/llvm-project/build/bin
:/mlir-cgra/build/bin
:/usr/local/sbin
:/usr/local/bin
:/usr/sbin
:/usr/bin
:/sbin
:/bin

I was trying to run the files in the demo folder when I encountered the errors. Both scripts in baseline and cgra were showing the same warning before halting execution.

As for running the model in MiniLM folder, I get a similar warning message about 04-finalized.mlir. This happens after I run the MiniLM.py file in the model folder, move the 02-linalg.mlir file to the cgra folder, and try to run the script4x4.sh script in the cgra folder. To be specific, this is the error I get:

04-finalized.mlir:129:3: warning:
  func.func @forward(%arg0: memref<1x12xi64>, %arg1: memref<1x2xf32>) {
  ^
04-finalized.mlir:129:3: note: see current operation: func.func @forward(%arg0: memref<1x12xi64>, %arg1: memref<1x2xf32>) 
{...}}

, followed by a very long block of (I'm guessing) object code within the curly braces.

@tancheng
Copy link
Owner

tancheng commented Sep 6, 2024

Mine did pass 04 stage. I guess sth wrong with your re-install stuff or the path. Plz make sure ur path is same as mine:

/llvm-project/build/bin:/mlir-cgra/build/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

Try again or re-download the docker.

@BabaNogdev
Copy link
Author

That's odd. My PATH's the same as yours, as I've posted above. I've also tried reinstalling Docker and pulling the image again, but it gave me the same result.

@BabaNogdev
Copy link
Author

That's odd. My PATH's the same as yours, as I've posted above. I've also tried reinstalling Docker and pulling the image again, but it gave me the same result.

Tried a couple random things after this, but still the same issue. Any suggestions?

@tancheng
Copy link
Owner

Hi @Yiran-ASU, please help reproduce and triage this issue, thanks!

@Yiran-ASU
Copy link
Collaborator

Hello, Dr. Tan @tancheng , I also got the 04-finalized.mlir:3:3: warning by running sh script.sh in baseline.

Then I run ./simulate, and got check result and total cycles:
Check result: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 Total cycles: 3296

Also, my $PATH is the same: /llvm-project/build/bin:/mlir-cgra/build/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

Then, I found in /mlir-cgra/experiments/MiniLM/model directory, there is only bert.py, not MiniLM.py. After I run python 3.9 bert.py, I got bert.milr. So I guess the script4x4.sh in cgra folder need to be modified.

@tancheng
Copy link
Owner

So you are able to generate the simulate binary and run it, though there is warnings, right?

@Yiran-ASU
Copy link
Collaborator

yes, I think so

@Vedgon
Copy link

Vedgon commented Oct 18, 2024

Hello. I haven't been able to solve this issue, and I had kinda given up on it for the time being.
However, I had noticed something which I'd like to bring your attention towards. When I run any of the scripts in baseline or cgra, I don't get to see an end to the execution of that script. Since all I get is a warning, the script should finish its execution and return to the terminal for letting the user input other commands. In my case however, I never get to that finishing point. I have to manually stop the execution with Ctrl+C, which basically interrupts the script. That's why nothing happens for me whenever I execute the ./simulate command, I think.
Are there high system resource requirements for executing this project? I'm currently on a laptop which has 16 GB of RAM and 4 GB of Nvidia RTX 3050 GPU. Is this configuration enough for running this project?

@tancheng
Copy link
Owner

Hi @Vedgon, I think 16GB is enough, just make sure the docker get enough memory via --memory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants